• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: PIC16F84A的IO無法pushdown.
#3
新會員
新會員


查看用戶資訊
多謝了! 問題真是出在ISR裡面。
另外, 我用的mplab v7.6, 有時指令會show 藍色, 有時show紫色, 是不是可以設定呢? 謝謝,

發表於: 2007/5/30 19:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC16F84A的IO無法pushdown.
#2
資深會員
資深會員


查看用戶資訊
你的PORTB寫入0fh, f0h,可是程式裡是寫入7FH, FEH,是不是量錯腳了?
你中斷裡的
movwf temp_w
movlw STATUS
movwf temp_status
寫錯了...應該是
movwf temp_w
SWAPF STATUS,W
movwf temp_status
...
...
SWAPF temp_status,F
SWAPF STATUS,W
MOVWF STATUS
SWAPF temp_status,W
RETFIE
也有可能是中斷時W的值被搗亂了,導致丟到PORTB的值都錯了。

發表於: 2007/5/30 9:42
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


PIC16F84A的IO無法pushdown.
#1
新會員
新會員


查看用戶資訊
我寫了一段程式, 邏輯沒錯, 卻無法正確執行, 我對portb寫入0, 量portb電位, 才發現portb的電位沒有拉到Low,請問是什麼原因, 我的程式只是寫入0fh, f0h而已, 如下:
__config _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF

list p=16F84A


; Include file, change directory if needed
include "p16f84a.inc"


;**********************************************************
;Variables
;**********************************************************
org 0x10
temp_a = H'0c'
temp_b = H'0d'
flash_bit = H'0e'
push_b = H'0f'
delay = H'10'
bit_count = H'11'
word_count = H'12'
rx = H'13'
user = H'14' ;user name: reserve 6 bytes for "BONBON"
id = H'1a' ;ID : reserve 8 bytes for "CR-V KEY"
succeed = H'22'
temp_status = H'23'
temp_w = H'24'
ten_time = H'25'


;**********************************************************
; Start at the reset vector
;**********************************************************
org 0x000
nop
goto Start
org 0x004
;========================================================
;Timer0
;========================================================
TIMER0
movwf temp_w
movlw STATUS
movwf temp_status

decfsz ten_time, 1
goto _ten_time

movlw H'ff'
xorwf flash_bit,1
_ten_time

bsf STATUS,RP0
btfss INTCON, T0IF
goto _End_TIMER0
bcf INTCON,T0IF ; 清除計時器中斷旗號


_End_TIMER0
bcf STATUS,RP0
movlw temp_status
movwf STATUS
movlw temp_w
retfie



;========================================================
;Initial Timer0
;========================================================
InitTimer
bsf STATUS,RP0
bcf OPTION_REG,T0CS ; 開始振盪器脈波輸入
bcf OPTION_REG,PSA ; 設定使用脈波預除器
bsf INTCON,GIE ; 打開全域中斷開關(中斷總開關)
bcf INTCON,T0IF ; 清除計時器中斷旗號
movlw H'00'
andwf OPTION_REG, 1
movlw H'04'
iorwf OPTION_REG, 1
bcf STATUS,RP0
retlw 0


;========================================================
;Start Timer0
;========================================================
StartTimer
bsf STATUS,RP0
bcf OPTION_REG,T0CS ; 設定振盪器脈波輸入(1/4 osc)
bsf INTCON,T0IE ; 打開計時器中斷
bcf STATUS,RP0
retlw 0
;**********************************************************
; Start at the reset vector
;**********************************************************
Start
bsf STATUS, RP0
movlw H'00'
movwf TRISB ;PORTB all outputs
movlw H'FF'
movwf TRISA ;PORTA ALL IN
bcf STATUS, RP0
movlw H'00'
movwf PORTB
movlw H'ff'
movwf PORTA

clrf INTCON
call InitTimer
call StartTimer ;Enable INT
_Main


btfsc flash_bit, 0
goto _rev
movlw H'7f'
movwf PORTB
goto _Main

_rev
movlw H'fe'
movwf PORTB
goto _Main ;Do it again

end


發表於: 2007/5/29 20:36
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------