📄 main.c
字号:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
//#define Debug_Display
#include "main_asm.h" /* interface to the assembly module */
const unsigned char Led_Hc164[7]={0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,};
unsigned char Led_Seg[7];
void LedDisplay(unsigned char Led_Segment);
void MCU_init(void);
void main(void)
{
unsigned char i;
unsigned char j;
EnableInterrupts; /* enable interrupts */
/* include your code here */
i=0;
MCU_init();
asm_main(); /* call the assembly function */
Led_Seg[0]=0XC0;
Led_Seg[1]=0XF9;
Led_Seg[2]=0XA4;
Led_Seg[3]=0XB0;
Led_Seg[4]=0X99;
Led_Seg[5]=0X92;
Led_Seg[6]=0X82;
__RESET_WATCHDOG(); /* feeds the dog */
for (j=0; j<10; j++); //空循环
for(;;) {
LedDisplay(i);
i++;
if(i==7)
i=0;
} /* loop forever */
/* please make sure that you never leave main */
}
void LedDisplay(unsigned char Led_Segment)
{
unsigned char i, data;
PTB=0xFF;
#ifdef Debug_Display
PTD |=PTD_PTD0_MASK;
#endif
data=Led_Hc164[Led_Segment];
for( i = 0; i < 7; i++)
{
asm
{
rol data
bcc led_0
bset 1,PTD
bra led_1
led_0:
bclr 1,PTD
led_1:
bclr 4,PTD
bset 4,PTD
}
}
PTB=Led_Seg[Led_Segment];
#ifdef Debug_Display
if(Led_Seg[Led_Segment]&PTB_PTB0_MASK)
{
PTD|=PTD_PTD0_MASK;
}
else
{
PTD&=~PTD_PTD0_MASK;
}
#endif
}
void MCU_init(void)
{
CONFIG1=0x00;
CONFIG2=0x10;
COPCTL=0xFF;
SCC1=0x00;
(void)(SCS1 == 0);
(void)(SCS2 == 0);
(void)(SCDR == 0);
SCC3=0x00;
SCBR=0x20;
SCC1=0x5C;
SCC2=0x2E;
PTB=0xFF;
DDRB=0xFF;
PTA &=(unsigned char)~0xBC;
DDRA |=(unsigned char)0xBC;
#ifdef Degbug_Display
PTD |=(unsigned char)0x13;
DDRD |= (unsigned char)0x13;
#else
PTD |=(unsigned char)0x12;
DDRD |=(unsigned char)0x12;
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -