#include "board.h"
#include "avr_compiler.h"
unsigned char number [16]={0x00,0x01,0x01,0x02,0x03,0x03,0x04,0x04,0x05,0x06,0x06,0x07,0x08,0x08,0x09,0x09};
void delay_ms(unsigned int count)
{
while(count--)delay_us(1000);
}
void port_init(void)
{
PORTD.DIR=0xFF;
PORTD.OUT=0xFF;
PORTA.DIRSET=PIN4_bm|PIN5_bm|PIN6_bm;
PORTA.OUTSET=PIN4_bm|PIN5_bm|PIN6_bm;
}
void sentCMD(unsigned char dat)
{
delay_ms(20);
PORTA.OUTCLR=PIN4_bm|PIN5_bm;
PORTD.OUT= dat;
PORTA.OUTSET=PIN6_bm;
delay_ms(20);
PORTA.OUTCLR=PIN6_bm;
delay_ms(20);
}
void sentDAT(unsigned char dat)
{
delay_ms(20);
PORTA.OUTSET=PIN4_bm;
PORTA.OUTCLR=PIN5_bm;
PORTD.OUT= dat;
PORTA.OUTSET=PIN6_bm;
delay_ms(20);
PORTA.OUTCLR=PIN6_bm;
delay_ms(20);
}
void initiallcd(void)
{
delay_ms(20);
sentCMD(0x38);
sentCMD(0x04);
sentCMD(0x0c);
sentCMD(0x01);
sentCMD(0x02);
}
void LCD_Display()
{
sentCMD( 0x80 ); sentDAT( 0x30 );
sentCMD( 0x81 ); sentDAT( 0x31 );
sentCMD( 0x82 ); sentDAT( 0x32 );
sentCMD( 0x83 ); sentDAT( 0x33 );
}
int main(void)
{
port_init();
initiallcd();
sentCMD(0xc1);
sentDAT(0x32);
while(1)
{
LCD_Display();
}
}
|