发布网友 发布时间:2024-10-23 22:34
共2个回答
热心网友 时间:2024-11-21 16:45
//功 能:6位数码管动态扫描
#include <pic.h>
__CONFIG(0x3f32);
//================================================//
#define uchar unsigned char
uchar SMBL;
const uchar LED7[]={0x92,0x99,0xb0,0xa4,0xf9,0xc0};
//=================函数声明======================//
void main(void) //主函数
{
TRISA=0X00; //A口输出
TRISD=0X00; //B口输出
PORTA=0XFE; //A口输出高
ADCON1=0X07; //关A口AD
GIE=1; //开总中断
TMR0IE=1; //开定时器中断
OPTION=0X02; //设分频比
TMR0=0X00; //定时器赋初值
T0IF=0; //定时器中断标志置0
SMBL=0;
while(1) //循环
{
PORTD=LED7[SMBL];
}
}
//=======数码管动态显示01235中断显示函数=========//
void interrupt dsq(void)
{
T0IF=0; //清定时器中断标志
PORTD=0XFF; //熄灭数码管
asm("bsf status,0"); //请C标志位
asm("rlf porta,f"); //A口左移
if(++SMBL>=7) //数显变量+1,≠7跳过
{
PORTA=0B11111110;
SMBL=0;
}
TMR0=0X00; //定时器赋值
}
热心网友 时间:2024-11-21 16:47
定时器子程序
BANKSEL
BCF PIR1,TMR1IF
CLRF TMR1L
MOVLW 0X00
MOVWF TMR1H
MOVWF TMR1L
BANKSEL T1CON
MOVLW B00110000
MOVWF T1CON
BSF INTCON,PEIE
BANKSEL PIE1
CLRF PIE1
BSF PIE1,TMR1IE
BANKSEL PIR1
CLRF PIR1
BANKSEL PIR1
CLRF TMR1L
MOVLW 0X00
MOVWF TMR1L
MOVWF TMR1H
BSF T1CON,TMR1ON
BANKSEL INTCON
BSF INTCON,GIE
RETURN