/************************************************************/
/************************************************************/
/************************************************************/
#define led_wei1 PC1
#define led_wei1_out TRISC1
#define led_wei2 PB0
#define led_wei2_out TRISB0
#define led_wei3 PB2
#define led_wei3_out TRISB2
#define led_a PB7
#define led_a_out TRISB7
#define led_b PB4
#define led_b_out TRISB4
#define led_c PB1
#define led_c_out TRISB1
#define led_d PA4
#define led_d_out TRISA4
//#define led_e PA2←←←←←←←←←←
//#define led_e_out TRISA2←←←←←←←←←←
#define led_e PC0
#define led_e_out TRISC0
#define led_f PA3
#define led_f_out TRISA3
#define led_g PB3
#define led_g_out TRISB3
#define led_h PA0
#define led_h_out TRISA0
/*#define led_1 PC0
#define led_1_out TRISC0
#define led_2 PA7
#define led_2_out TRISA7*/
#define shuchu PA1
#define shuchu_out TRISA1
#define anj_jia PA5
#define anj_jia_out TRISA5
#define anj_jia_shangla WPUA |=1 <<5
#define anj_shezhi PA6
#define anj_shezhi_out TRISA6
#define anj_shezhi_shangla WPUA |=1 <<6
#define anj_jian PB5
#define anj_jian_out TRISB5
#define anj_jian_shangla WPUB |=1 <<5
/************************************************************/
void xianshi_chushihua() //显示初始化
{
TIM4EN =1; //TIM4 模块时钟
SYSON =0; //睡眠模式下,系统时钟控制
T4ARPE =1; //计数周期的自动预装载
T4CKS1 =0; //00=Sysclk
T4CKS0 =0;
T4OPM =0; //单脉冲模式关闭
T4URS =1; //更新事件中断源计数器上溢
T4UDIS =0; //产生更新事件控制0=允许
T4CEN =1; //TIM4 计数器使能
T4PSC2 =1; //Timer4预分频器110 = 64
T4PSC1 =1;
T4PSC0 =0;
//T4CNT //Timer4计数值
TIM4ARR =103; //预装载值50HZ
//TIM4ARR =68; //预装载值75HZ
GIE =1; //全局中断
PEIE =1; //外设总中断
T4UIE =1; //Timer4 更新事件中断
//T4UG =1; //Timer4 更新事件软件中断
//T4UIF
led_wei1 =1; //消隐
led_wei2 =1;
led_wei3 =1;
led_a =0;
led_b =0;
led_c =0;
led_d =0;
led_e =0;
led_f =0;
led_g =0;
led_h =0;
led_wei1_out =0; //输出模式
led_wei2_out =0;
led_wei3_out =0;
led_a_out =0;
led_b_out =0;
led_c_out =0;
led_d_out =0;
led_e_out =0;
led_f_out =0;
led_g_out =0;
led_h_out =0;
}
/************************************************************/
volatile unsigned int xianshi_a1 =1;
volatile unsigned char xianshi_aa =1; //显示状态位
volatile unsigned char xianshi_b1 =1;
volatile unsigned char xianshi_b2 =2;
volatile unsigned char xianshi_b3 =3;
volatile unsigned char xianshi_c1 =0;
volatile unsigned char xianshi_c2 =0;
volatile unsigned char xianshi_c3 =0;
void xianshi_jisuan() //显示计算
{
xianshi_b1 =xianshi_a1 /100;
xianshi_b2 =xianshi_a1 %100/10;
xianshi_b3 =xianshi_a1 %10;
xianshi_c1 =biao[xianshi_b1];
xianshi_c2 =biao[xianshi_b2];
xianshi_c3 =biao[xianshi_b3];
}
/************************************************************/
void interrupt ISR(void)
{
#asm;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
NOP;//系统设置不可以删除和修改
#endasm;//系统设置不可以删除和修改
if(T4UIE&&T4UIF)
{
T4UIF =1;
if(xianshi_aa ==1)
{
led_wei1 =1; //消隐
led_wei2 =1;
led_wei3 =1;
if(xianshi_c1 &0b00000001){led_a =1;} else{led_a =0;}
if(xianshi_c1 &0b00000010){led_b =1;} else{led_b =0;}
if(xianshi_c1 &0b00000100){led_c =1;} else{led_c =0;}
if(xianshi_c1 &0b00001000){led_d =1;} else{led_d =0;}
if(xianshi_c1 &0b00010000){led_e =1;} else{led_e =0;}
if(xianshi_c1 &0b00100000){led_f =1;} else{led_f =0;}
if(xianshi_c1 &0b01000000){led_g =1;} else{led_g =0;}
if(xianshi_c1 &0b10000000){led_h =1;} else{led_h =0;}
led_wei1 =0;
led_wei2 =1;
led_wei3 =1;
}
if(xianshi_aa ==2)
{
led_wei1 =1;
led_wei2 =1;
led_wei3 =1;
if(xianshi_c2 &0b00000001){led_a =1;} else{led_a =0;}
if(xianshi_c2 &0b00000010){led_b =1;} else{led_b =0;}
if(xianshi_c2 &0b00000100){led_c =1;} else{led_c =0;}
if(xianshi_c2 &0b00001000){led_d =1;} else{led_d =0;}
if(xianshi_c2 &0b00010000){led_e =1;} else{led_e =0;}
if(xianshi_c2 &0b00100000){led_f =1;} else{led_f =0;}
if(xianshi_c2 &0b01000000){led_g =1;} else{led_g =0;}
if(xianshi_c2 &0b10000000){led_h =1;} else{led_h =0;}
led_wei1 =1;
led_wei2 =0;
led_wei3 =1;
}
if(xianshi_aa ==3)
{
led_wei1 =1;
led_wei2 =1;
led_wei3 =1;
if(xianshi_c3 &0b00000001){led_a =1;} else{led_a =0;}
if(xianshi_c3 &0b00000010){led_b =1;} else{led_b =0;}
if(xianshi_c3 &0b00000100){led_c =1;} else{led_c =0;}
if(xianshi_c3 &0b00001000){led_d =1;} else{led_d =0;}
if(xianshi_c3 &0b00010000){led_e =1;} else{led_e =0;}
if(xianshi_c3 &0b00100000){led_f =1;} else{led_f =0;}
if(xianshi_c3 &0b01000000){led_g =1;} else{led_g =0;}
if(xianshi_c3 &0b10000000){led_h =1;} else{led_h =0;}
led_wei1 =1;
led_wei2 =1;
led_wei3 =0;
}
xianshi_aa ++;
if(xianshi_aa >3){xianshi_aa =1;}
}
}
/************************************************************/
|