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


Browsing this Thread:   1 Anonymous Users






Re: 為何無法寫入count?!
#4
版主
版主


查看用戶資訊
將你的程式放到軟體模擬底下跑了一遍

1. 你的 Delay1mS 只有323uS @10MHz,加長一點吧

2. 1200bps 需 8.33mS 才能傳一個 Byte,這個Delay好像太短了。

3. 連續對同一個 I/O Port 動作建議加入一個 NOP

bcf     TRISC,6,
    nop
    bsf     TRISC
,7,0

發表於: 2004/11/2 17:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何無法寫入count?!
#3
高級會員
高級會員


查看用戶資訊
可以燒錄執行了...
而且...終於有波形囉!
可是...
波形好像就固定住..
沒有在跑動的跡象...
意思好像是..
送出第一個訊號後..
在delay時間到後也沒繼續再送出波形...
跟我期望的"經過一個delay時間就送一個訊號出去!"
並不一樣....
還沒找出為什麼會醬子?!
苦思中....

發表於: 2004/11/1 22:24
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 為何無法寫入count?!
#2
版主
版主


查看用戶資訊
建議一下,你可能要先了解一下PIC18F的架構,PIC18F是採用 Access Bank的觀念設計的所以對SFR暫存器是不用切換BANK,而且你只要把變數放在0x00 ~0x7F之間也不用切換 BANK。
是不是可以下載右邊的W400 教育訓練講義研讀一下Access Bank的使用方式並熟悉一下語法。底下是我修改過的程式我執行起來沒有問題,不知你是否了解??


list p=18F252 
        
#include <p18F252.INC>

number     equ .200
;
    
cblock 0x00  set the RAM variable atart address at 0x00
    count
    endc

;**********************
    
org 0x00
    nop
initial

    
movlw     .129 
    movwf     SPBRG 
    bsf    TXSTA
,TXEN 
    bcf     TXSTA
,SYNC 
    bsf     RCSTA
,SPEN  
    bsf     TXSTA
,TXEN 
    bsf    RCSTA
,CREN 
    bcf     TRISC
,6,
    bsf     TRISC
,7,

start
:        
    
btfss    TXSTA,TRMT     
    
goto    start    
    movlw    
B'11110000'    
    
movwf    TXREG     
    call    delay_1ms    
    
goto    start
;
delay_1ms:    
    
    
movlw    number    
    movwf    count      
write W to count 
dec_loop    
    nop    
    decfsz    count
,F     count=count-1
    
goto    dec_loop
    
return 
;              
      
end

發表於: 2004/11/1 17:46
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


為何無法寫入count?!
#1
高級會員
高級會員


查看用戶資訊
請問大家...
MPLAB IDE v6.60版..
我用Debugger -> Select Tool -> 3.MPLAB SIM 模擬程式..
所有的迴圈功能都正常...
如我所預期的一樣!
為什麼改用Debugger -> Select Tool -> 1.MPLAB ICD2模擬..
Q: 到了" movwf count,1 "這行..
卻無法寫入到count..
好奇怪喔!
到底是什麼原因呢?!
謝謝...
list    P=18F252
        
#include<P18F252.inc>
number    equ    .200
count    equ    0x80
;**********************
    
org    0x00
    nop
initial
:
        
banksel    SPBRG
        movlw    .129     
;Buad Rate=1200bps
        movwf    SPBRG
,0
        bsf    TXSTA
,TXEN,0
        bcf    TXSTA
,SYNC,0
        bcf    TXSTA
,BRGH,0
        bsf    RCSTA
,SPEN,0
        bsf    RCSTA
,CREN,0
        bcf    TRISC
,6,0
        bsf    TRISC
,7,0
start
:
        
banksel    PIR1
        btfss    TXSTA
,TRMT,0
        
goto    start
        movlw    
B'11110000'
        
movwf    TXREG,0
        call    delay_1ms
        
goto    start
delay_1ms
:
        
banksel    count
        movlw    number
        movwf    count
,1
dec_loop    nop
        decfsz    count
,1,1
        
goto    dec_loop
        
return
                     
end

發表於: 2004/11/1 11:52
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... ]

教育訓練中心

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