- UID
- 111868
- 性别
- 男
|
[em27][em27][em27][em27][em27][em27][em27][em27][em27]
我用的是JK3的片子想驱动共阳数码管,D口加一级8550驱动,B口做字符译码,大概程序如下,可是数码管全亮,问题到现在还没有找出来。请大虾帮忙。
#include /* for EnableInterrupts macro */
#include /* include peripheral declarations */
#define Enable EnableInterrupts
#define Disable DisableInterrupts
unsigned int RT;
unsigned int addr;
unsigned int value;
unsigned int Code[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
void sysinit(void)
{
Disable;
CONFIG1=0;
DDRB=0xFF;
PTB=0x00;
DDRD=0xF0;
PTD=0x00;
PDCR=0xFF;
ADICLK=0x70;
ADSCR=0x68;
}
void delay(void)
{
unsigned int i;
for(i=0;i<1000;i++);
}
void interrupt INT_ADC A()
{
RT=ADR;
}
void Sendled(addr,value)
{
switch(addr)
{
case 1:
{
DDRD=0X80;
DDRB=Code[value];
};break;
case 2:
{
DDRD=0X40;
DDRB=Code[value];
};break;
case 3:
{
DDRD=0X20;
DDRB=Code[value];
};break;
case 4:
{
DDRD=0X10;
DDRB=Code[value];
};break;
}
}
void Displayled(void)
{
Sendled(1,RT/1000);
delay();
Sendled(2,RT/100);
delay();
Sendled(3,RT/10);
delay();
Sendled(4,RT%10);
delay();
}
void main(void)
{
sysinit();
delay();
Enable;
while(1)
{
Displayled();
__RESET_WATCHDOG();
};
} |
|