亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 用pic12c509 控制led.txt

?? 單片機常用的程序30例
?? TXT
字號:

  PIC12C509 - Getting Around the Stack Limitation 
The 12C5 series PIC has only a two level stack which limits the number of nested subroutine calls to two. This may be a very serious limitation. 

(The 16C84 has an eight level stack which permits nested subroutines to eight deep. I can't imagine a program where this will not be sufficient). 

In the following programs an alternative user stack is presented which provides the programmer with alternative "call" and "return" capability. 

Note that a user stack is implemented using the highest data address. The idea is that the user stack grows down from 1FH, while user variables are assigned from 07H and up. Thus, the degree of nesting permitted using this approach is the full variable space (25) less the number of bytes which are used as variables in the program. 

There are two other limitations to this approach; 

1. Only the low byte of the program counter is saved on the user stack. Thus, this limits the calling of all functions and the implementation of the functions to the same page. 

However, this does not preclude one from splitting a program over several pages and implementing each called function on each page. Of course, the same implementation of functions on different pages must have different names. That is, one must be careful and think. But with the price of the 12C5XX declining to a mere $1.00 it pays to think! 

This approach of splitting a program is shown in another discussion dealing with the I2C bus. 

2. The FSR is used as the user defined stack pointer. Thus, if the FSR register is used elsewhere, one must be careful to save the user stack pointer in a temporary variable when using the FSR for other applications and of course, restoring it to the FSR when calls and returns are made using this approach. 

Please refer to program STACK_1.ASM which continually flashes an LED on and off. Note that the main calls routines SUB1, DELAY, SUB2 and DELAY and then loops back to repeat the process. 

The FSR register is intialized to the highest data location, 01FH. 

Each "call" consists of the following instructions. 


MOVF PCL, W ; fetch PCL to W
ADDWF OFFSET, W ; add 4 
MOVWF INDF ; save to location pointed to by FSR
DECF FSR, F ; for next subroutine
GOTO SUB1 ; turn LED on

RET_POINT1:
;... continuation of program

In the above, note that the current content of the low byte of the program counter is fetched. The address to return to (RET_POINT1) is calculated by adding 4 and this is saved to the location pointed to by the user stack pointer. The stack pointer is then decremented to accommodate the next return address. Finally, a jump to the function is executed. 

In the subroutine, the task is first performed. The "return" is then implemented using the following code. 


; task performed
INCF FSR, F ; return
MOVF INDF, W
MOVWF PCL

In the above, the user stack pointer is incremented so as to point to the location containing the value of the program counter which was stored in the calling routine. This is fetched and placed in the low byte of the program counter. Thus, execution continues at the return point in the calling routine. 


; STACK_1.ASM (12C509)
; 
; Illustrates how to use user stack to implement "calls" and "returns". 
; This is particularly important on the 12C509 as to stack is limited to
; two levels.
;
; Flashes LED on GPIO0, 250 ms on and 250 ms off.


LIST p=12c509
#include <p12c509.inc> 
__CONFIG 1AH

LOOP1 EQU 07H ; for timing loops
LOOP2 EQU 08H
OFFSET EQU 09H

ORG 000H

MOVLW 1FH ; intitialize FSR to point to top of "stack"
MOVWF FSR

MOVLW .4
MOVWF OFFSET ; offset initialized to 4

MOVLW 1EH ; least sign bit is an output
TRIS GPIO

TOP:
; save return address on stack
MOVF PCL, W ; fetch PCL, add 4 and save at location 
ADDWF OFFSET, W ; pointed to by FSR 
MOVWF INDF
DECF FSR, F ; dec stack pointer for next subroutine
GOTO SUB1 ; turn LED on

MOVF PCL, W
ADDWF OFFSET, W
MOVWF INDF
DECF FSR, F
GOTO DELAY ; 250 ms delay

MOVF PCL, W
ADDWF OFFSET, W
MOVWF INDF
DECF FSR, F
GOTO SUB2 ; turn LED off

MOVF PCL, W
ADDWF OFFSET, W
MOVWF INDF
DECF FSR, F
GOTO DELAY ; 250 ms delay

GOTO TOP

SUB1:
BCF GPIO, 0 ; logic zero turns LED on

; these three lines are the equiv of a return
INCF FSR, F ; increment FSR
MOVF INDF, W ; get return address
MOVWF PCL ; and put in program counter

SUB2:
BSF GPIO, 0 ; logic one turns LED off

INCF FSR, F ; return
MOVF INDF, W
MOVWF PCL

DELAY: ; when running set LOOP1 to .250 and LOOP2 to .110.
; this will result in 250 ms delay.
MOVLW .250
MOVWF LOOP1
OUTTER:
MOVLW .110 ; close to 1.0 msec delay when set to .110
MOVWF LOOP2
INNER:
NOP
NOP
DECFSZ LOOP2, F ; decrement and leave result in LOOP2 
; skip next statement if zero
GOTO INNER
DECFSZ LOOP1, F
GOTO OUTTER

INCF FSR, F ; return
MOVF INDF, W
MOVWF PCL

END 

In program STACK_2.ASM, the "calls" and "returns" are implemented using macros which have been labelled as GOSUB and RET. Note that macros make the program considerably more understandable. 


; STACK_2.ASM. 
;
; Same as STACK_1.ASM except implemented using macros.
;
; coyright, Peter H. Anderson, MSU, June 1, '97

LIST p=12c509
#include <p12c509.inc>
__CONFIG 1AH

; Macros defined
GOSUB MACRO arg1 ; uses user defined stack to save return address
MOVF PCL, W ; and jumps to specified routine.
ADDWF OFFSET, W
MOVWF INDF
DECF FSR, F
GOTO arg1

ENDM

RET MACRO ; fetches return address from stack
INCF FSR, F 
MOVF INDF, W
MOVWF PCL

ENDM

LOOP1 EQU 0CH ; for timing loops
LOOP2 EQU 0DH
OFFSET EQU 0EH

ORG 000H

MOVLW 1FH ; intitialize FSR to point to top of "stack"
MOVWF FSR

MOVLW .4
MOVWF OFFSET ; intialize OFFSET to 4

MOVLW 1EH
TRIS GPIO ; least sign bit is defined as output

TOP:
GOSUB SUB1
GOSUB DELAY
GOSUB SUB2
GOSUB DELAY

GOTO TOP

SUB1:
BCF GPIO, 0
RET
SUB2:
BSF GPIO, 0
RET

DELAY: ; when running set LOOP1 to .250 and LOOP2 to .110.
; this will result in 250 ms delay.
MOVLW .250
MOVWF LOOP1
OUTTER:
MOVLW .110 ; close to 1.0 msec delay when set to .110
MOVWF LOOP2
INNER:
NOP
NOP
DECFSZ LOOP2, F ; decrement and leave result in LOOP2 
; skip next statement if zero
GOTO INNER
DECFSZ LOOP1, F
GOTO OUTTER

RET 

END 
 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产综合久久福利软件| 中文字幕亚洲电影| 91精品国产综合久久久蜜臀图片 | 91精品久久久久久久91蜜桃| 91麻豆国产福利在线观看| 97久久超碰国产精品电影| 成人精品小蝌蚪| av一二三不卡影片| 色女孩综合影院| 91日韩在线专区| 欧美天堂一区二区三区| 欧美日韩国产综合视频在线观看| 欧美精品xxxxbbbb| 日韩欧美中文一区| 国产三级久久久| 亚洲免费观看高清完整版在线| 一区二区三区欧美在线观看| 亚洲第一搞黄网站| 美女视频一区二区| 成人性生交大片免费看在线播放| av一区二区三区在线| 欧美视频一区二区| 日韩精品一区二区三区视频 | 日本伊人色综合网| 久久99久久久久| 国产91丝袜在线观看| 日本道免费精品一区二区三区| 欧美丰满高潮xxxx喷水动漫| 久久一区二区三区国产精品| 国产精品国产三级国产专播品爱网 | 国产亚洲欧美日韩俺去了| 国产高清不卡二三区| 激情综合一区二区三区| 激情成人综合网| 国内精品视频666| 91日韩精品一区| 国产精品麻豆视频| 欧美性猛交xxxx乱大交退制版| 亚洲成人动漫av| www久久精品| 欧洲生活片亚洲生活在线观看| 日韩写真欧美这视频| 一区二区三区蜜桃| www.亚洲色图.com| 国产亚洲一区字幕| 奇米影视在线99精品| 91国产免费观看| 最好看的中文字幕久久| 国产高清不卡二三区| wwwwww.欧美系列| 久久精品99国产精品| 欧美福利视频一区| 天天综合日日夜夜精品| 在线日韩一区二区| 亚洲精品一二三| 91在线免费播放| 成人免费一区二区三区在线观看| 国产精品一区专区| 久久久精品影视| 国产精品资源网站| 国产亚洲va综合人人澡精品| 久久91精品国产91久久小草| 日韩一级欧美一级| 美女在线视频一区| 欧美电影精品一区二区| 精品在线观看免费| 精品国产百合女同互慰| 国产综合久久久久久久久久久久| 日韩免费观看2025年上映的电影| 麻豆国产91在线播放| 欧美成人艳星乳罩| 精彩视频一区二区| 久久精品国产99国产| 日韩欧美精品在线| 韩国女主播一区| 欧美高清在线视频| 成人精品视频.| 亚洲同性gay激情无套| 91蝌蚪porny| 亚洲综合激情小说| 欧美日韩国产乱码电影| 日韩和的一区二区| 日韩女优电影在线观看| 国产在线播放一区二区三区| 国产日韩在线不卡| 一本色道久久综合亚洲91| 亚洲国产美女搞黄色| 日韩一级高清毛片| 国产精品一区二区三区99| 国产精品麻豆视频| 欧美午夜精品久久久| 日韩国产欧美在线视频| 欧美成人精品二区三区99精品| 激情成人午夜视频| 中文字幕一区二区三区在线播放| 91国偷自产一区二区使用方法| 午夜一区二区三区在线观看| 日韩欧美精品在线视频| 国产成人综合网| 夜夜操天天操亚洲| 日韩免费视频线观看| 成人高清在线视频| 午夜精品免费在线观看| 精品久久久久香蕉网| 成人亚洲一区二区一| 亚洲成人av一区二区| 亚洲精品一线二线三线| 91女厕偷拍女厕偷拍高清| 日韩综合小视频| 国产欧美日韩中文久久| 欧美丝袜第三区| 国产一区二三区| 亚洲精品成人a在线观看| 3d动漫精品啪啪| 岛国av在线一区| 午夜不卡在线视频| 国产亚洲美州欧州综合国| 欧美色涩在线第一页| 国产一区激情在线| 亚洲一级电影视频| 久久久精品tv| 欧美精品一级二级三级| 丁香另类激情小说| 蜜臀av国产精品久久久久| 亚洲色图视频网| 精品日韩在线观看| 欧洲一区二区三区在线| 国产成人8x视频一区二区 | 国产成人精品在线看| 亚洲成人在线网站| 国产精品成人免费在线| 日韩欧美国产综合一区 | 午夜视频在线观看一区二区 | 2023国产精品自拍| 欧美日韩国产一区二区三区地区| 国产精品影视网| 日本一区中文字幕| 一区二区三区日韩欧美精品| 久久亚洲精品小早川怜子| 欧美精品tushy高清| 99re66热这里只有精品3直播 | 亚洲国产成人在线| 精品捆绑美女sm三区| 欧美天堂亚洲电影院在线播放| 成人激情动漫在线观看| 国产在线一区二区综合免费视频| 亚洲123区在线观看| 亚洲六月丁香色婷婷综合久久| 国产人成一区二区三区影院| 日韩三级高清在线| 欧美三级午夜理伦三级中视频| 91在线视频播放地址| 懂色av中文字幕一区二区三区| 激情综合网av| 美女精品自拍一二三四| 五月天一区二区| 一区二区免费在线| 亚洲日本中文字幕区| 国产精品高潮呻吟| 国产亲近乱来精品视频| 2021久久国产精品不只是精品| 日韩女优毛片在线| 欧美一二区视频| 日韩欧美美女一区二区三区| 69堂精品视频| 欧美精品v日韩精品v韩国精品v| 一本色道久久综合亚洲91| 99国产精品久久久久久久久久| 国产剧情一区二区三区| 极品瑜伽女神91| 国产一区二区三区四区五区入口 | 国产三级一区二区三区| 久久伊人蜜桃av一区二区| 日韩国产成人精品| 亚洲成人激情av| 日韩成人精品视频| 免费成人你懂的| 精品一区二区久久久| 国产综合久久久久影院| 国产伦理精品不卡| 国产成人日日夜夜| 成人激情图片网| 97se亚洲国产综合自在线不卡| 9l国产精品久久久久麻豆| 97久久超碰国产精品电影| 色悠久久久久综合欧美99| 日本黄色一区二区| 欧美色电影在线| 欧美一区二区在线免费播放 | 国产成人在线视频免费播放| 国产成人综合在线播放| 不卡的电视剧免费网站有什么| 99久久综合国产精品| 91福利国产成人精品照片| 欧美日韩在线电影| 欧美一级二级三级蜜桃| 久久综合av免费| 国产精品传媒入口麻豆| 一区二区三区精品在线观看| 婷婷综合五月天|