初来乍到求高手指点
#define uchar unsigned char#include <avr/io.h>
#include <inttypes.h>
#include <util/delay.h>
#include <limits.h>
#include <avr/interrupt.h>
#define HC_595_SRCLR 0x08 //PORTB.3 10
#define HC_595_SER 0x04 //PORTB.2 14数据传送
#define HC_595_SRCLk 0x02 //PORTB.1 11
#define HC_595_RCLK 0x01 //POTRB.0 12
#define HC_595_OE 0x80 //PORTC.7 13
/*
0X01
#define uchar unsigned char
#include <avr/io.h>
#include <inttypes.h>
#include <util/delay.h>
#include <limits.h>
#include <avr/interrupt.h>
#define HC_595_SRCLR 0x08 //PORTB.3 10
#define HC_595_SER 0x04 //PORTB.2 14数据传送
#define HC_595_SRCLk 0x02 //PORTB.1 11
#define HC_595_RCLK 0x01 //POTRB.0 12
#define HC_595_OE 0x80 //PORTC.7 13
/*
0X01
____
0x20 | | 0x02
| |
0x40 ____
| |
0x10| | 0x04
____
0x08
*/
uchar ge,shi,bai,qian,shu,shu1;
void wei();
void hc595_out(unsigned char out_data);
const unsigned char Data[]={0x06,0x5B,0x4F,0x66,0x6D,0xFD,0x07,0xFF,0x67};//,0x66, //0,1,2,3,4
//0x6D,0x7D,0x07,0x7F,0x6F, //5,6,7,8,9
//0x77,0x7C,0x39,0x5E,0x79,0x71};
SIGNAL(SIG_OVERFLOWO)
{
TCNT0 = 0X06;
shu++;
if(shu==125)
{
shu=0;
shu1++;
}
if(shu1==10000)
{
shu1=0;
}
}
int main(void)
{
//unsigned char row_i ,row_p;//
TCCR0 = 0X06;
TCNT0 = 0X06;
TIMSK = 0X01;
SREG|=0X80;
DDRB=0xff;
PORTB=0xf8;
DDRC=0x80;
PORTC &=~ 0x80;
PORTB |= 0xf0;
PORTB&=~HC_595_SRCLk;
PORTB&=~HC_595_RCLK;
while(1)
{
void wei();
//for(row_i=0;row_i<4;row_i++)
//{
//row_p++;
//if(row_p>=9) row_p=0;
_delay_ms(6);
PORTB &=~0XF0;
PORTB |= 1<<4;
hc595_out(Data);
_delay_ms(6);
PORTB &=~0XF0;
PORTB |= 1<<5;
hc595_out(Data);
_delay_ms(6);
PORTB &=~0XF0;
PORTB |= 1<<6;
hc595_out(Data);
_delay_ms(6);
PORTB &=~0XF0;
PORTB |= 1<<7;
hc595_out(Data);
//}
}
}
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()
{
ge = shu1%10;
shi = shu1%100/10;
bai = shu1%1000/100;
qian = shu1/1000;
}
哪里不对啊 大仙们指点 小弟刚刚开始学习 做的什么,看不懂。。 驱动数码管显示0-9999 significance201 发表于 2013-4-25 21:43 static/image/common/back.gif
做的什么,看不懂。。
数码管显示0-9999 这不是百度知道参见“提问的艺术” 笑。h 发表于 2013-4-25 21:48 static/image/common/back.gif
数码管显示0-9999
格式好乱,定时器,然后自加显示,就可以了吧 现在没用avr的MCU
页:
[1]