ADC大仙帮帮忙
uint ad_data;uchar ge,shi,bai,qian;
uint shu;
void wei();
void xianshi();
void hc595_out(unsigned char out_data);
uint ADC_Convert(void);
const unsigned char Data[]={0x3f,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6f};//,0x66, //0,1,2,3,4
//0x6D,0x7D,0x07,0x7F,0x6F, //5,6,7,8,9
//0x77,0x7C,0x39,0x5E,0x79,0x71};
int main(void)
{
DDRF&=0xfe;
ADMUX = 0X40;
ADCSRA = 0XE0;
DDRB=0xff;
PORTB=0xf8;
DDRC=0x80;
PORTC &=~ 0x80;
PORTB |= 0xf0;
PORTB&=~HC_595_SRCLk;
PORTB&=~HC_595_RCLK;
while(1)
{
ad_data =ADC_Convert();
wei();
xianshi();
}
}
void hc595_out(unsigned char data)
{
uchari,j;
j=0x80;
for(i=0;i<8;i++)
{
//PORTB=(0xf8&Data);
if((data&j)>0)
{
PORTB |= HC_595_SER;
}
else
{
PORTB &=~ HC_595_SER;
}
asm("nop");
j=j>>1;
asm("nop");
PORTB |=HC_595_SRCLk;
asm("nop");
PORTB &=~ HC_595_SRCLk;
}
PORTB |=HC_595_RCLK;
asm("nop");
asm("nop");
PORTB &=~ HC_595_RCLK;
}
void wei()
{
uint adc_result;
adc_result=(unsigned long)ad_data*5000/1024;
ge = adc_result%10;
shi = adc_result%100/10;
bai = adc_result%1000/100;
qian = adc_result/1000;
}
void xianshi()
{
_delay_ms(10);
PORTB &=~0XF0;
PORTB |= 1<<4;
hc595_out(Data);
_delay_ms(10);
PORTB &=~0XF0;
PORTB |= 1<<5;
hc595_out(Data);
_delay_ms(10);
PORTB &=~0XF0;
PORTB |= 1<<6;
hc595_out(Data);
_delay_ms(10);
PORTB &=~0XF0;
PORTB |= 1<<7;
hc595_out(Data);
}
uint ADC_Convert(void)
{
uint temp1,temp2;
temp1 = ADCL;
temp2 = ADCH;
temp2 = (temp2<<8)|temp1;
return (temp2);
}
大仙们。。。。。 程序出什么问题?你都不说问题我们怎么给你解答! LDHW 发表于 2013-5-14 15:57 static/image/common/back.gif
程序出什么问题?你都不说问题我们怎么给你解答!
帮忙看看程序对不对感谢
我用万用表量过pf0口电压显示的不对呢 大哥们来帮帮忙啊 你的程序有没有禁止模拟比较器。
页:
[1]