实施使电路板上的LED闪烁两次所需的汇编语言代码:250 mS 在/ 250 mS关闭。你选择哪个LED会闪烁
所以我们需要编写这段代码,但经过四个小时的工作,班上没有人可以到任何地方。因为我们实际上并没有学习集会而且教授是meh。 这是我到目前为止的地方,真的需要帮助理解如何完成它或者我是否朝着正确的方向前进。
#include <PIC16f77a.inc>
TEMP_W EQU 0X20 ;Temporary location for W during interrupt
TEMP_STATUS EQU 0X21 ;Temporary location for Status during interrupt
TIMERCOUNT EQU 0X22
__CONFIG 0X0373A ;This is the control bits for CONFIG register with the
; watchdog timer enabled
ORG 0X0000 ;RESET or WDT reset vector
GOTO START
ORG 0X0004 ;Regular INT vector`START
CLRF PORTB
CLRF PORTC
BSF STATUS,RP0
MOVLW 0X05
MOVWF PIE1
MOVLW 0X05
MOVWF PIR1
MOVLW 0X02
MOVWF TRISB
MOVLW 0X04
MOVWF TRISC
BCF STATUS, PRO
MOVLW 0X80
MOVWF INTCON
MOVLW 0X04
MOVWF CCP1CON
MOVLW 0X0B
MOVWF CCP1CON,0X04
MOVLW 0X33
MOVWF T1CON`
答案 0 :(得分:1)
使用定时器每250 ms产生一次中断,然后在某个端口异或一位。
答案 1 :(得分:0)
#include <p16f877a.inc>
TEMP_W EQU 0X20 ;Temporary location for W during interrupt
TEMP_STATUS EQU 0X21 ;Temporary location for Status during interrupt
TIMERCOUNT EQU 0X22
__CONFIG 0X373A ;This is the control bits for CONFIG register with
the
; watchdog timer enabled
ORG 0X0000 ;RESET or WDT reset vector
GOTO START
ORG 0X0004 ;Regular INT vector
PUSH
; This stores the current W and STATUS registers in temporary locations during ISRS
MOVWF TEMP_W
SWAPF STATUS,W
MOVWF TEMP_STATUS
BTFSC PIR1, CCP1IF
GOTO TIMERINTR
POP
; This restores the original W and STATUS registers before returning to the
main program
SWAPF TEMP_STATUS,W
MOVWF STATUS
SWAPF TEMP_W,F
SWAPF TEMP_W,W
RETFIE
TIMERINTR
INCF TIMERCOUNT,F
BCF PIR1, CCP1IF
GOTO POP
START
CLRF TIMERCOUNT
BCF INTCON, GIE
CLRF PORTC
BSF STATUS,RP0
MOVLW 0X00
MOVWF TRISC
BSF PIE1, CCP1IE
BCF STATUS, RP0
BSF INTCON, PEIE
CLRF TMR1H
CLRF TMR1L
MOVLW 0X01
MOVWF T1CON
MOVLW 0X0B
MOVWF CCP1CON
MOVLW 0X13
MOVWF CCPR1H
MOVLW 0X88
MOVWF CCPR1L
BSF INTCON, GIE
LOOPTIME
MOVLW 0XFA
XORWF TIMERCOUNT, W
BTFSC STATUS, Z
GOTO OUTPUT
GOTO LOOPTIME
OUTPUT
MOVLW 0X80
XORWF PORTC, RC7
CLRF TIMERCOUNT
GOTO LOOPTIME
RETURN
END