#include <iom16v.h>
#include <macros.h>
unsigned char led_7[10]={0x3F, 0x06, 0x5B, 0x4F, 0x66,
0x6D, 0x7D, 0x07, 0x7F, 0x6F};
unsigned char num[4] = {0x01, 0x02, 0x03, 0x04};
unsigned char pos[4] = {0x07, 0x06, 0x05, 0x04};
void HC_595_send(unsigned char sndData)
{
unsigned char i;
for(i = 0; i < 8; i++)
{
if(sndData&(1 <<(7 - i)))
{
PORTA |= (1 << 0);
}
else
{
PORTA &= ~(1 << 0);
}
PORTB &= ~(1 << 1);
PORTB |= (1 << 1);
}
PORTB &= ~(1 << 0);
PORTB |= (1 << 0);
}
void Delay_Ms(unsigned char time)
{
unsigned char n;
while(time--)
{
for(n = 0; n <= 200; n++)
{
NOP();
}
}
}
void main()
{
unsigned char i, counter = 0;
DDRD = 0xFF;
PORTD = 0xFF;
DDRA = 0xFF;
DDRB = 0xFF;
PORTA |= (1 << 0);
PORTA |= (1 << 3);
PORTB |= (1 << 1);
PORTB |= (1 << 0);
while(1)
{
for(i = 0; i < 4; i++)
{
HC_595_send(~led_7[num[i]]);
PORTD &= ~(1 << pos[i]);
Delay_Ms(2);
PORTD = 0xFF;
}
}
}