• 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: PIC12F510的Delay_Time(組語)
#9
版主
版主


查看用戶資訊
參照:

hellowanz 寫道:
這就怪了,DataSheet Page15 Reset Vector寫的是0x000...還是我有漏看了什麼?


實際是從 0x3FF 猜始執行先行載入校正值到 W Reg 後,PC 在 Rollover 後會變成 0x000,所以說是從 0x000 是執行起點也是可以的。

不過以 PIC16C5x Base-Line 的 12-bit architecture,Reset 後 PC 就會在最後一個位址開始執行。底下以 PIC16C54 為例 :
list      p=16c54A            ; list directive to define processor
    
#include <p16c5x.inc>         ; processor specific variable definitions

    
__CONFIG   _CP_OFF _WDT_ON _RC_OSC

'__CONFIG' directive is used to embed configuration word within .asm file.
The lables following the directive are located in the respective .inc file
See respective data sheet for additional information on configuration word.




;***** 
VARIABLE DEFINITIONS
temp          EQU     0x07        
;example variable definition








;**********************************************************************
        
ORG     0x1FF             processor reset vector
        
goto    start
        ORG     0x000

發表於: 2009/4/2 10:19
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC12F510的Delay_Time(組語)
#8
資深會員
資深會員


查看用戶資訊
1. 使用太多 call (12f510 只有兩層 堆疊 )

2.timer 0 不是 timer ?

movlw .100
movwf time_x
movlw 0x82 ; tmr0 預除 8
option
clrf tmr0

while_t:

movf tmr0 ,f
btfss status , z ; over 1 ms ?
goto while_t
goto $ + 1
goto $ + 1
goto $ + 1
decfsz time_x , f
goto while_t ; not over 100 ms
movlw .100
movwf time_x

~~~~ your program.....
~~~~~
~~~~


~~ 不要超過 2000個指令時間

goto while_t


如時脈為8mhz , tmr0 預除 8  ( 256 * 8 = 2048 )
如 2000個指令時間 不夠用 也可將預除時間 加大 , time_x 的預設值減小........

發表於: 2009/4/1 18:01
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC12F510的Delay_Time(組語)
#7
資深會員
資深會員


查看用戶資訊
這就怪了,DataSheet Page15 Reset Vector寫的是0x000...還是我有漏看了什麼?

發表於: 2009/4/1 15:48
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC12F510的Delay_Time(組語)
#6
版主
版主


查看用戶資訊
在補充一下,PIC12F510 一開機時,Reset Vector 是在 0x3FF 的,Microchip 在12F510出廠時就將內部RC振盪器的校正值燒在0x3FF (MOVLW oxNN) 執行完此行指令後程式計數器自 0x3FF --> 0x000 歸零後就直接將校正值寫入 OSCCAL 暫存器。

發表於: 2009/4/1 10:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC12F510的Delay_Time(組語)
#5
資深會員
資深會員


查看用戶資訊
3FFH內存放OSCCAL的校正值,把校正值放到OSCCAL裡,MCU就可以固定RUN 1MIPS的速度。

發表於: 2009/3/31 17:21
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC12F510的Delay_Time(組語)
#4
初級會員
初級會員


查看用戶資訊
參照:

hellowanz 寫道:
1.請在movwf OSCCAL的前一行寫CALL 3FFH
2.有TMR0,可以用POLLING的方式數時間


請問為什麼要在OSCCAL前一行寫CALL 3FFH ???

發表於: 2009/3/31 17:09
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC12F510的Delay_Time(組語)
#3
版主
版主


查看用戶資訊
如果用軟體方式做 Delay 的話,建議使用MPLAB SIM 軟體模擬的方式來做,先選MPLAM SIM 並在 Setting 下設定工作頻率,配合中斷點的使用只要用 SOTPWATCH 視窗就可以輕鬆的算出軟體的執行時間了。當然 長時間的 Delay Routine 是需從最底層建立的,也許先建個 1mS 後確定時間正確再建 100mS 的 Delay 這樣一層一層疊上去。

當然用 Timer0 使用 Polling 的方式會比用純軟體方式來的有效率。

發表於: 2009/3/31 11:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC12F510的Delay_Time(組語)
#2
資深會員
資深會員


查看用戶資訊
1.請在movwf OSCCAL的前一行寫CALL 3FFH
2.有TMR0,可以用POLLING的方式數時間

發表於: 2009/3/31 9:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


PIC12F510的Delay_Time(組語)
#1
初級會員
初級會員


查看用戶資訊
使用PIC12F510寫PORT的控制。但Delay_Time一直寫不出。
如果我想delay100ms ~ 5000ms
請問又該如何寫呢??
(我主要要控制 GPIO,O 和 GPIO,1)
請各方高手幫忙求助,謝謝大家

PIC12F510好像沒有計數器吧??

============================
程式如下

list p=12F510
#include <p12F510.inc>
CONFIG MCLRE OFF CP OFF WDT OFF IntRC OSC IOSCFS ON

VAL_US equ .147
VAL_MS equ .100
count equ 0x20
count_ms equ 0x21
;----------------------------------
MAIN
 org 0x000
 movwf OSCCAL
 movlw 0x87
 OPTION
 movlw 
b'00111000'
 
TRIS GIPO;Register
 clrf GPIO
;----------------------------------
while_loop
 bsf GPIO
,0
 bcf GPIO
,1
 call delay_100ms   
<---可能會delay100ms到5000ms
 bcf GPIO
,0
 call while_loop
;-----------------------------
delay_100ms:
 
movlw VAL_MS
 movwf count_ms
loop_ms
:
 
call delay_1ms
 decfsz count_ms
,f
 
goto loop_ms
 
return
;-------------------------------
delay_1ms:
 
movlw VAL_US
 movwf count
dec_loop
 call D_short
 decfsz count
,f
 
goto dec_loop
 
return
;---------------------------
D_short
 call D_ret
 call D_ret
 nop
 nop
D_ret
 
return

 
end

發表於: 2009/3/30 22:36

Edited by Ryang on 2009年03月31日 11:07:26
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... ]

教育訓練中心

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