• 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: 偶又碰到問題啦....
#8
資深會員
資深會員


查看用戶資訊
大哥知了 3Q a lot.....笨鴨偶受益多多

發表於: 2005/10/12 0:22
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 偶又碰到問題啦....
#7
初級會員
初級會員


查看用戶資訊
Dear duck288,
請注意,最後的脈衝寬度是1.1ms 不是 1.0ms。如果,最後脈寬需要 1.0ms,可修改以下指令:
1. “movlw d'30';” 改為 “movlw d'31';”
2. “movlw d'10';” 改為 “movlw d'09';”

然而一般我們在程式中會避免直接引用常數,以免一但需要變更該常數時,就要「上窮碧落下黃泉」的到處找問題,因此多半在宣告區來處理常數。
程式可作以下修改:
; -------------------------------------------------------------------------
#define N_of_LongestPulse 40 ; 最長脈寬的 N
#define N_of_ShortestPulse 11 ; 最短脈寬的 N

#define ExcutionTimes N_of_LongestPulse- N_of_ShortestPulse+1
; 執行次數
#define Bias ShortestPulse-1 ; 偏壓值

於是程式碼就可以改成:
1. “movlw d'30';” 改為 “movlw ExcutionTimes;”
2. “movlw d'10';” 改為 “movlw Bias;”
; -------------------------------------------------------------------------
這樣,只須依需要修改 N_of_LongestPulse 及 N_of_ShortestPulse 數值,再組譯即可。實際執行次數及偏壓值的計算,可交由組譯器處理。

發表於: 2005/10/11 16:05
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 偶又碰到問題啦....
#6
資深會員
資深會員


查看用戶資訊
研究了一下午, 重新整理如下, 不知道有沒有對耶?
好像有給它懂一點點 , 程式一下子 瘦了100Kg...hahaha
用我的程式可以寫爆 12F508, 哈哈..真是有夠笨瓜耶..
待笨鴨偶重新整理整理, 在燒來試看看囉...3q lar.

;-----[Main routine]---------------------------------------------------------
start
movlw d'30' ;
movwf chDelay ;
sync_1
btfss GPIO,0 ; 等同步訊號
goto sync_1 ; No, check again ..
goto loop_1 ; Yes..
loop_1
movlw d'10' ;
addwf chDelay,w ;
movwf chInner_delay ;
call fnDelayNx100us ;
bsf GPIO,1 ; set GP1 to triger
call fnDelay100us ; set triger width =100us.
bcf GPIO,1 ; Clear triger
decfsz chDelay,1 ;
goto loop_1 ;
goto strart ;

;-----------------------------[Sub routine]-----------------------------------
fnDelay100us
movlw d'33'
movwf count
keep_1
decfsz count1,f
goto keep_1 ; Total delay 100us..
retlw 0
fnDelayNx100us
call fnDelay100us
decfsz chInner_delay ;
goto fnDelayNx100us ;
retlw 0

發表於: 2005/10/11 6:49
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 偶又碰到問題啦....
#5
資深會員
資深會員


查看用戶資訊
3Q 3Q +阿里阿多 ,abewu...
笨鴨我 了解程式能力還很低...
也沒學過組合語言,玩PIC純粹是興趣,
所以會問一些很笨, 很好笑的問題;
在這兒還真是能得到很多幫助.... thanks lar!
希望有機會能回台北參加教育訓練課程...
Well....我需要好好研究一陣子您的程式...
也就是說會有更多很笨, 很好笑的問題要請教,,lor ,hahaha..

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


Re: 偶又碰到問題啦....
#4
初級會員
初級會員


查看用戶資訊
Hi! Duck288,

很久沒有用組合語言了! 正好有個小程式要寫, 用你的問題來複習一下也好. 只是沒有試用, 希望沒有語法問題, 您使用前麻煩先 double check 一下語法.

您應該已經有 delay 0.1ms 的 routine. 假設它稱為 fnDelay100us 在程式中作為基本 delay.

另外寫了一個 routine 稱為 fnDelayNx100us, 它會呼叫 'fnDelay100us' N 次, N = 1 to 256, 呼叫此 routine 前先將 N 置於變數 'chInner_delay' 內. 當 N = 0 時會執行 256 次. 離開時 'chInner_delay' 會變為 0.


extern fnDelay100us ; 假設是您 delay 0.1ms 的 routine

chDelay RES 1 ; 變數宣告
chInner_delay RES 1 ; 變數宣告

Hi_I_start_here
movlw 30 ; My instruction
movwf chDelay ; My instruction
; Your instructions ----------------
loop_1 ; 你的 goto ... 看不大懂.
; 希望沒誤解
btfss GPIO,0 ; ---等同步訊號,
goto loop_1 ;假設同步信號是 '1'.
; ------------------------------------
movlw 10 ; My instruction
addwf chDelay, W ; My instruction
movwf chInner_delay ; My instruction
call fnDelayNx100us ; My instruction
; Your instructions ----------------
bsf GPIO,1 ;-----觸發訊號
call fnDelay100us ; 改名字了!!!
bcf GPIO,1
; ------------------------------------
decfsz chDelay, 1 ; My instruction
goto loop_1 ; My instruction
retlw 0 ; My instruction

fnDelayNx100us ; 新加的 routine
call fnDelay100us
decfsz chInner_delay,1
goto fnDelayNx100us
retlw 0

發表於: 2005/10/9 23:04
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 偶又碰到問題啦....
#3
初級會員
初級會員


查看用戶資訊
Hi! Duck288,

很久沒有用組合語言了! 正好有個小程式要寫, 用你的問題來複習一下也好. 只是沒有試用, 希望沒有語法問題, 您使用前麻煩先 double check 一下語法.

您應該已經有 delay 0.1ms 的 routine. 假設它稱為 fnDelay100us 在程式中作為基本 delay.

另外寫了一個 routine 稱為 fnDelayNx100us, 它會呼叫 'fnDelay100us' N 次, N = 1 to 256, 呼叫此 routine 前先將 N 置於變數 'chInner_delay' 內. 當 N = 0 時會執行 256 次. 離開時 'chInner_delay' 會變為 0.


extern fnDelay100us ; 假設是您 delay 0.1ms 的 routine

chDelay RES 1 ; 變數宣告
chInner_delay RES 1 ; 變數宣告

Hi_I_start_here
movlw 30 ; My instruction
movwf chDelay ; My instruction
; Your instructions ----------------
loop_1 ; 你的 goto ... 看不大懂.
; 希望沒誤解
btfss GPIO,0 ; ---等同步訊號,
goto loop_1 ;假設同步信號是 '1'.
; ------------------------------------
movlw 10 ; My instruction
addwf chDelay, W ; My instruction
movwf chInner_delay ; My instruction
call fnDelayNx100us ; My instruction
; Your instructions ----------------
bsf GPIO,1 ;-----觸發訊號
call fnDelay100us ; 改名字了!!!
bcf GPIO,1
; ------------------------------------
decfsz chDelay, 1 ; My instruction
goto loop_1 ; My instruction
retlw 0 ; My instruction

fnDelayNx100us ; 新加的 routine
call fnDelay100us
decfsz chInner_delay,1
goto fnDelayNx100us
retlw 0

發表於: 2005/10/9 23:03
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 偶又碰到問題啦....
#2
資深會員
資深會員


查看用戶資訊
我的笨程式也許是太長啦....
可否教偶如何瘦身呢?
我希望在收到同步訊號後Delay 4ms
再送出一個0.1ms的觸發訊號
然後收到下個同步訊號後送出一個的Delay 3.9ms觸發訊號
也就是說每收到同步訊號後會減少0.1ms
從Delay 4ms 直到 Delay 1ms
我現在是用CALL Delay 的方式來完成
所以我有3個 delay程式 delay 1ms, delay0.2ms,delay0.1ms
btfss GPIO,0 ---等同步訊號
goto.... ----check sync again
goto loop_1
loop_1
call delay_1ms
call delay_1ms
call delay_1ms
call delay_1ms -----total Delay 4ms
bsf GPIO,1 -----觸發訊號
call delay_0.1ms -----
bcf GPIO,1
btfss GPIO,0 ---等同步訊號
goto.... ----check sync again
goto loop_2
loop_2
call delay_1ms
call delay_1ms
call delay_1ms
call delay_0.2ms
call delay_0.2ms
call delay_0.2ms
call delay_0.2ms
call delay_0.1ms -----total Delay 3.9ms
bsf GPIO,1 -----觸發訊號
call delay_0.1ms -----
bcf GPIO,1
.
.
直到call delay_1ms -----total Delay 1ms
所以程式是又笨又臭又長
我想一定有比較簡單的方法來完成
不知是否有人教偶如何瘦身呢? 3Q 3Q 3Q lor!!!!

發表於: 2005/10/9 13:21
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


偶又碰到問題啦....
#1
資深會員
資深會員


查看用戶資訊
偶 用12F508 寫了個程式 在Build all 以後出現下列訊息

warring: Crossing page boundary -- ensure page bits are set.
warring: Address exceeds maximum range for this processor

是蝦咪意思呀???
但是 Build all 以後又出現是 build succeeded
不知該怎麼辦耶???如何 set page 呀 ????

發表於: 2005/10/8 5:54
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... ]

教育訓練中心

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