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

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

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

?? 單片機常用的程序30例
?? 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一区二区三区免费野_久草精品视频
亚洲日本va午夜在线影院| 国产电影一区在线| 一区二区三区在线观看网站| 国产清纯在线一区二区www| 精品欧美一区二区在线观看| 日韩美女视频在线| 欧美成人性福生活免费看| 欧美精品一区视频| 26uuu国产一区二区三区 | 亚洲国产高清aⅴ视频| 国产清纯在线一区二区www| 久久精品视频免费| 国产精品污www在线观看| 国产精品国产精品国产专区不蜜| 国产精品高清亚洲| 亚洲精品成人悠悠色影视| 亚洲图片欧美综合| 日本不卡视频在线| 国产美女在线观看一区| 国产91清纯白嫩初高中在线观看 | 欧美日本视频在线| 制服丝袜中文字幕一区| 欧美成va人片在线观看| 欧美极品xxx| 亚洲精品一二三| 偷窥国产亚洲免费视频| 久久福利视频一区二区| 成人综合婷婷国产精品久久免费| 91亚洲精品久久久蜜桃| 欧美日韩国产高清一区二区| 精品久久一二三区| 日韩毛片视频在线看| 天堂av在线一区| 国产一区二区美女诱惑| 91啪亚洲精品| 91.com视频| 国产日韩亚洲欧美综合| 一区二区免费在线播放| 久久成人综合网| 99久久99久久久精品齐齐| 欧美日韩国产美| 国产精品国产三级国产aⅴ入口 | 国产精品自拍av| 国产成人精品三级| 日本丶国产丶欧美色综合| 欧美一区二区三区四区高清| 久久久不卡网国产精品二区| 一区二区在线观看视频在线观看| 奇米四色…亚洲| 99久久免费精品| 日韩写真欧美这视频| 亚洲欧洲av一区二区三区久久| 亚洲成人精品一区| 大陆成人av片| 91麻豆精品国产91久久久使用方法| 久久―日本道色综合久久 | 色婷婷综合久久久| 精品日韩一区二区| 一区二区三区精品视频在线| 黄色日韩网站视频| 欧美男人的天堂一二区| 国产精品国产三级国产三级人妇 | 色老头久久综合| 欧美mv和日韩mv国产网站| 亚洲欧美aⅴ...| 国产乱子轮精品视频| 欧美三片在线视频观看| 奇米一区二区三区av| 欧美在线小视频| 欧美激情一区在线观看| 蜜臀va亚洲va欧美va天堂| 欧美影院一区二区三区| 国产精品久久久久一区| 韩国精品主播一区二区在线观看 | 日韩亚洲欧美综合| 亚洲一区二区欧美日韩| 北条麻妃国产九九精品视频| 久久久久久久久蜜桃| 蜜臀av在线播放一区二区三区| 91成人在线精品| 亚洲日本免费电影| 成人ar影院免费观看视频| 精品对白一区国产伦| 日本美女视频一区二区| 欧美性xxxxxxxx| 亚洲综合免费观看高清完整版 | 91猫先生在线| 国产精品视频九色porn| 国产精品主播直播| 精品国产乱码久久久久久久久| 偷拍亚洲欧洲综合| 欧美精品在线一区二区| 香港成人在线视频| 欧美群妇大交群中文字幕| 亚洲一区日韩精品中文字幕| 91国在线观看| 一区二区久久久久久| 色狠狠综合天天综合综合| 亚洲激情综合网| 欧洲一区在线观看| 亚洲一区二区三区免费视频| 精品视频在线免费观看| 亚洲国产成人va在线观看天堂| 欧美日韩一区二区三区在线| 亚洲超碰97人人做人人爱| 欧美日韩久久不卡| 日韩1区2区3区| 精品少妇一区二区| 国产精品中文字幕欧美| 日本一区二区三区高清不卡| 国产91富婆露脸刺激对白| 中文字幕国产一区| 97久久超碰精品国产| 一区二区三区精品视频| 欧美日韩中文精品| 久久爱另类一区二区小说| 久久综合久久久久88| 成人性色生活片| 亚洲欧洲综合另类| 欧美日韩午夜精品| 久久se这里有精品| 亚洲国产精品精华液ab| 色成年激情久久综合| 日本欧美一区二区在线观看| 亚洲精品在线免费播放| 成人av资源在线| 亚洲午夜久久久久久久久久久| 51久久夜色精品国产麻豆| 国产一区二区福利| 日韩美女视频19| 91精品国产综合久久国产大片| 国产自产高清不卡| 亚洲日本va午夜在线影院| 91精品国产综合久久香蕉麻豆 | 日韩西西人体444www| 国产iv一区二区三区| 亚洲美女电影在线| 精品奇米国产一区二区三区| 成人激情黄色小说| 亚洲1区2区3区4区| 亚洲国产精品精华液2区45| 欧美日韩性生活| 丰满亚洲少妇av| 亚洲成人1区2区| 欧美国产精品久久| 欧美人妇做爰xxxⅹ性高电影| 国产一区二区三区视频在线播放| 亚洲三级电影网站| 欧美mv和日韩mv的网站| 色域天天综合网| 精品亚洲成a人在线观看| 亚洲美女偷拍久久| 久久精品人人做人人爽人人| 91成人在线精品| 国产成人av资源| 亚洲123区在线观看| 国产欧美精品一区二区三区四区 | 日韩精品一区二区三区视频在线观看| 粉嫩av一区二区三区在线播放| 亚洲国产成人91porn| 中文字幕av资源一区| 欧美一区二区网站| 在线中文字幕不卡| 国产不卡视频一区二区三区| 日韩精品乱码av一区二区| 成人免费在线观看入口| 精品国产91久久久久久久妲己| 日本精品免费观看高清观看| 国产成人精品免费网站| 久久国内精品视频| 亚洲成年人影院| 亚洲另类春色国产| 欧美国产欧美综合| 综合久久久久综合| 日韩av中文字幕一区二区三区| 老色鬼精品视频在线观看播放| 在线观看欧美日本| 国产亚洲精品中文字幕| 精品嫩草影院久久| 日本大香伊一区二区三区| 国产成人av一区二区三区在线观看| 五月激情六月综合| 亚洲男帅同性gay1069| 国产区在线观看成人精品| 日韩欧美国产一区二区三区| 欧美人狂配大交3d怪物一区| 欧洲av在线精品| 99久久精品情趣| 大桥未久av一区二区三区中文| 国模大尺度一区二区三区| 免费av网站大全久久| 亚洲成人免费影院| 亚洲h精品动漫在线观看| 一区二区三区.www| 一区二区三区在线免费观看| 亚洲三级电影全部在线观看高清| 国产精品女同一区二区三区| 久久久精品国产99久久精品芒果| 精品久久久久一区| 精品久久久久久久人人人人传媒 |