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

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

?? 16c84的rb口中斷程序.txt

?? PIC單片機C源代碼集合
?? TXT
字號:

  Interrupts - Part II, Interrupt on RB Change 
Introduction 

This discussion deals with the interrupt on RB change feature. It assumes the reader is familiar with the general discussion dealing with interrupts. 

The PIC16C84 and most other PICs provide a feature where the program may be configured such that an interrupt occurs when there is a change on any of a number of inputs. With the 16C84 (and 16C554/558), the interrupt is caused when there is a change on the upper nibble of Port B, i.e., RB.4::RB.7. 

This might be used as a power saving technique. The processor is placed in the sleep mode and is activated only when the user changes the state of any on the four inputs. The processor then performs the defined task and goes back to sleep. 

We are planning to use this feature in a 2000 event, 4 Channel event data logger. An event causes a change on any of the four inputs, waking the processor. The processor determines which of the four channels on which the event occurred. It will then fetch a 32-bit elapsed time in seconds from a Dallas DS1602. 32-bits accommodates an elapsed time of some 125 years, which is a bit much. Thus, only the lower 30 elapsed time bits will be used and the two bits associated with the channel will be inserted in the bit 31 and 30 positions. These four bytes will be saved to a Microchip 24LC65 (8K by 8) EEPROM. 

Details 

The general format of configuring for the Wake Up on Change interrupt is the same as with the external or timer / counter overflow interrupts. When ready for this interrupt, bit RBIE in the INTCON register is set which specifically indentifies the type of interrrupt that will be entertained. The GIE bit is then set. 

On interrupt, the program vectors to location 004H. Note that interrupts are now disabled. The processor then performs the defined task, the RBIF is then cleared and the processor then returns from the interrupt service routine using the RETFIE command. Note that interrupts are now enabled. 

There is a subtlety associated with the wake-up on change. PORTB must be read. The processor then stores a copy of the high nibble. The RBIF is then set and interrupt occurs when the high nibble of PORTB differs from this copy. Thus, it is important that in the interrupt service routine that PORTB be read so as to update the copy. 

The following incorrect code in the interrupt service routine caused us to do a good deal of head scratching. 

BCF INTCON, RBIF
MOVF PORTB, W

Indeed, we were clearing the interrupt flag. However, as the state of the high nibble of PORTB still differed from the old copy, the processor immediately set the RBIF flag and on RETFIE, we were immediately interrupted. In fact, the MOVF PORTB, F did us no good whatever. 

The correct code was; 

MOVF PORTB, W
BCF INTCON, RBIF

What a difference! In performing the MOVF PORTB, W, the old copy of the high nibble of PORTB is updated with the current state. The flag is then cleared. Thus, interrupt will occur when the high nibble of PORTB again changes. 
In the following routine, the intent was to identify the "channel" on which the change occurred. Thus, in TOP, PORTB is fetched and saved in ORIGINAL. 

In the interrupt service routine, PORTB is fetched and saved in NEW. Thus, the processor now has the new value as the basis for establishing if a future change occurs. The program then ascertains the specific bit which changed, and flashes an LED at a rate depending on which bit caused the interrupt. The NEW then becomes the ORIGINAL, the RBIF is cleared and when RETFIE is executed, control passes back to the main program with interrupts enabled. It is important to note that PORTB is read, thus updating the processor's copy prior to clearing RBIF. 

Note that considerable time is spent flashing the LED in the interrupt service routine. If any of the four bits on the high nibble of PORTB should change prior to clearing RBIF, RBIF will again be set by the hardware as there is a change from the latest copy. Thus, on RETFIE, interupts are again enabled and another interrupt will occur. However, this is eactly what is desired; a bit on the high nibble of PORTB changed. 

I am none too certain I have been any too clear. Always read PORTB so as to update the processor's reference prior to clearing RBIF. Failure to do so may cause a false interrupt as the processor compares the current state of the high nibble of PORTB with the most recent read. That is, the same change, which is in fact no change, will cause an interrupt. 

Note that in this routine, the W and STATUS registers were not saved on entry into the interrupt service routine and restored prior to exit as there was nothing of value to save. Rather, the processor simply goes to sleep and awaits the interrupt. 



; WAKE_UP.ASM
;
; This program is intended to illustrate the WAKE-UP on change feature
; associated with many PICs.
; 
; RB interrupts are enabled and the processor goes into a sleep mode. 
; On interrupt, the specific RB interrupt which caused the interrupt
; is determined and an LED is flashed 10 times at a speed determined 
; the input which changed. 
;
; Copyright, Locksley Haynes, Morgan State University, Nov 22, '97

LIST p=16c84
#include <c:\mplab\p16c84.inc>
__CONFIG 11H

CONSTANT LED=0 ; PORTA pin for LED

CONSTANT CH3=7 ; CH3 corresponds to PORTB.7
CONSTANT CH2=6
CONSTANT CH1=5
CONSTANT CH0=4 ; CH0 corresponds to PORTB.4

CONSTANT VARS=0CH

LOOP1 EQU VARS+0 ; outter timing loop
LOOP2 EQU VARS+1 ; inner timing loop
LED_CNT EQU VARS+2 ; times LED is winked


ORIGINAL EQU VARS+3
NEW EQU VARS+4
CHANGE EQU VARS+5
N EQU VARS+6

ORG 000H

CLRWDT
GOTO TOP

ORG 004H

GOTO WAKE_UP

TOP:
BCF OPTION_REG, 7 ; enable internal pullups
BSF STATUS, RP0
MOVLW 0F0H ; RB.7 - RB.4 are inputs
MOVWF TRISB
BCF STATUS, RP1

BTFSS STATUS, NOT_TO ; not a watch dog timer reset
GOTO TOP_1

; sample PORTB before going to sleep
MOVF PORTB, W ; fetch the current state
MOVWF ORIGINAL ; current state in high nibble

TOP_1:
BSF INTCON, GIE ; enable general interupts
BSF INTCON, RBIE ; enable interrupt on change

L1:
SLEEP
NOP
GOTO L1

WAKE_UP: ; interrupt service routine
MOVF PORTB, W ; sample changed state of pins
MOVWF NEW ; this will become the new original
XORWF ORIGINAL, W
MOVWF CHANGE ; 1's now in high nibble now identifies
; the bit that has changed
CLRF N ; set index to 0
BTFSC CHANGE, CH0
GOTO BLINK

INCF N, F ; N=1
BTFSC CHANGE, CH1
GOTO BLINK

INCF N, F ; N=2
BTFSC CHANGE, CH2
GOTO BLINK

INCF N, F
GOTO BLINK

BLINK: ; N is either 0, 1, 2 or 3 corresponding to the channel
; this is now mapped into a delay

CALL DELAY_LOOKUP
MOVWF LOOP1 ; save the delay in LOOP1
GOTO BLINK_AT_SPEED

DELAY_LOOKUP: ; map N into 100, 150, 200 or 250 msecs
MOVF N, W
ADDWF PCL, F
DT .100, .150, .200, .250

BLINK_AT_SPEED:
MOVLW .10
MOVWF LED_CNT
L2:
BSF PORTA, LED
CALL DELAY
CALL DELAY
BCF PORTA, LED
CALL DELAY
CALL DELAY
DECFSZ LED_CNT, F
GOTO L2
MOVF NEW, W
MOVWF ORIGINAL ; new original states 
BCF INTCON, RBIF ; clear interrupt flag
RETFIE

DELAY: 
L3:
MOVLW .110
MOVLW LOOP2
L4:
CLRWDT
NOP
NOP
NOP
NOP
NOP
NOP
DECFSZ LOOP2, F
GOTO L4
DECFSZ LOOP1, F
GOTO L3
RETURN

END

 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美影院午夜播放| 欧美变态tickling挠脚心| 波多野结衣精品在线| www.爱久久.com| 欧美日韩久久久久久| 精品欧美久久久| 中文字幕一区二区三区不卡在线| 一区二区三区鲁丝不卡| 美国十次综合导航| 99久久综合色| 欧美va在线播放| 亚洲欧洲精品一区二区三区不卡| 午夜精品久久久久久久蜜桃app| 久久国产精品露脸对白| 91香蕉视频mp4| 日韩免费高清av| 亚洲视频资源在线| 韩国欧美国产一区| 欧美性视频一区二区三区| 久久免费国产精品| 一区二区欧美视频| 国产精品一二三四五| 欧美三级蜜桃2在线观看| 久久久精品欧美丰满| 无码av免费一区二区三区试看| 国产成人在线视频网址| 67194成人在线观看| 亚洲乱码国产乱码精品精可以看| 极品销魂美女一区二区三区| 欧美羞羞免费网站| 亚洲天堂久久久久久久| 国产一区二区在线视频| 欧美日韩亚洲丝袜制服| 国产精品福利一区| 国产麻豆一精品一av一免费| 91精品黄色片免费大全| 亚洲综合精品自拍| 99久久精品免费精品国产| 精品捆绑美女sm三区| 亚洲五码中文字幕| 色综合久久久久网| 国产精品色一区二区三区| 国产在线播放一区三区四| 日韩欧美视频一区| 日韩福利视频导航| 欧美日韩精品久久久| 亚洲女女做受ⅹxx高潮| www.av精品| 亚洲人成伊人成综合网小说| 成人免费毛片aaaaa**| 国产日韩欧美电影| 国产麻豆精品在线| 久久婷婷国产综合国色天香| 久久se精品一区精品二区| 欧美一区永久视频免费观看| 亚洲成在线观看| 欧美三级三级三级爽爽爽| 亚洲影视在线播放| 欧美影院午夜播放| 日韩专区中文字幕一区二区| 欧美日韩亚洲国产综合| 日韩中文字幕91| 日韩精品中文字幕一区| 激情五月播播久久久精品| 日韩免费观看高清完整版| 精品一区二区国语对白| 久久久久99精品一区| 成人午夜伦理影院| 国产精品久久一卡二卡| 99久久久国产精品免费蜜臀| 亚洲黄色av一区| 欧美日韩国产综合一区二区| 日韩在线一二三区| 欧美xxxxx裸体时装秀| 高清视频一区二区| 伊人一区二区三区| 欧美精品视频www在线观看| 青椒成人免费视频| 国产女人18水真多18精品一级做 | 亚洲美女视频在线观看| 在线观看免费亚洲| 免费成人你懂的| 久久久青草青青国产亚洲免观| 国产成人综合亚洲91猫咪| 中文字幕日韩一区| 欧美日韩一区二区电影| 亚洲第一搞黄网站| 久久久久高清精品| 欧美人xxxx| 91免费视频大全| 美女视频网站久久| 日韩欧美二区三区| k8久久久一区二区三区| 亚洲午夜免费视频| 精品国一区二区三区| 国产成人精品aa毛片| 亚洲欧美国产高清| 欧美一级高清片在线观看| 国产乱码精品1区2区3区| 中文字幕日韩av资源站| 精品欧美一区二区久久| 97久久久精品综合88久久| 狠狠色狠狠色综合系列| 亚洲国产欧美在线| 欧美韩国日本综合| 3d成人h动漫网站入口| 久久99国产精品久久99| 成人精品亚洲人成在线| 亚洲人成网站精品片在线观看| 91麻豆6部合集magnet| 一区二区三区成人| 日韩午夜精品视频| 粉嫩av一区二区三区| 亚洲狼人国产精品| 欧美情侣在线播放| 成人黄色小视频| 亚洲国产精品天堂| 久久嫩草精品久久久精品一| www.成人网.com| 日本美女一区二区| 国产精品第一页第二页第三页| 欧美午夜精品一区| 日本不卡123| 国产视频一区二区在线| 欧美色倩网站大全免费| 国产精品一二三在| 免费成人av在线| 中文字幕日韩一区二区| 精品国产乱码久久久久久浪潮 | 久久婷婷久久一区二区三区| 色噜噜狠狠色综合中国| 国产成a人亚洲精品| 久久99精品久久只有精品| 亚洲一区二区在线免费观看视频 | 欧美日韩久久久久久| av高清不卡在线| 国产成人免费9x9x人网站视频| 美国一区二区三区在线播放| 天天色天天爱天天射综合| 中文字幕一区二区三区在线不卡| 精品乱人伦小说| 日韩欧美中文一区二区| 欧美色图第一页| 欧美日韩精品欧美日韩精品| 色诱视频网站一区| 99在线精品免费| 波多野结衣中文字幕一区二区三区| 激情综合色丁香一区二区| 午夜精品福利视频网站| 亚洲午夜久久久久中文字幕久| 国产精品九色蝌蚪自拍| 国产欧美视频一区二区三区| 色综合咪咪久久| 91免费在线视频观看| 成人一区二区视频| 粉嫩嫩av羞羞动漫久久久| 成人免费高清在线| 99精品热视频| 91美女蜜桃在线| 91久久一区二区| 欧美性猛交xxxxxx富婆| 欧美性猛交xxxxxx富婆| 欧美亚洲日本国产| 在线91免费看| 日韩三级在线观看| 久久久久国产精品免费免费搜索| 色悠久久久久综合欧美99| 欧美系列在线观看| 欧美在线制服丝袜| 91浏览器在线视频| 99精品欧美一区| 色综合色狠狠天天综合色| 91免费观看视频| 欧美日韩精品系列| 欧美群妇大交群中文字幕| 91精品国产手机| 日韩欧美国产精品| 精品国产污污免费网站入口 | 欧美本精品男人aⅴ天堂| 日韩视频一区二区三区| 91精品免费观看| 日韩视频一区在线观看| 精品国产免费一区二区三区四区| 久久一区二区三区国产精品| 国产精品久久久久久久久晋中| 一区二区三区在线视频观看| 日韩影院在线观看| 国产成人在线视频网址| 在线亚洲精品福利网址导航| 色拍拍在线精品视频8848| 不卡一区二区中文字幕| 欧美另类一区二区三区| 久久久高清一区二区三区| 国产精品婷婷午夜在线观看| 亚洲午夜电影在线观看| 国产美女在线精品| 欧洲精品中文字幕| 精品国产欧美一区二区| 亚洲一区二区三区在线| 狠狠色丁香九九婷婷综合五月|