lcd_m8._c

来自「AVR ICC基于AVR MEGA8单片机的LCD程序!」· _C 代码 · 共 73 行

_C
73
字号
#include <iom16v.h>
#include <macros.h>
#include <stdlib.h>
#include <eeprom.h>
#include <math.h>
#include "head.h"
#include "lcd.h"





void port_init(void)
{
 PORTA = 0x00;
 DDRA  = 0xFF;
 PORTB = 0x00;
 DDRB  = 0x00;
 PORTC = 0x00; //m103 output only
 DDRC  = 0xFF;
 PORTD = 0x00;
 DDRD  = 0x00;
}

//Watchdog initialize
// prescale: 256K
void watchdog_init(void)
{
 WDR(); //this prevents a timout on enabling
 WDTCR = 0x0C; //WATCHDOG ENABLED - dont forget to issue WDRs
}

//call this routine to initialize all peripherals
void init_devices(void)
{
 //stop errant interrupts until set up
 CLI(); //disable all interrupts
 port_init();
 watchdog_init();
 
 MCUCR = 0x00;
 GICR  = 0x00;
 TIMSK = 0x00; //timer interrupt sources
 SEI(); //re-enable interrupts
 //all peripherals are now initialized
}

void main(void)
{
char i;
unit k;
 uchar flash *p1[]={hz_wo,hz_ai,hz_yan,hz_shan,hz_da,hz_xue,NULL};	
delay(100);
init_devices(); 

initlcd();

delay(1000);

while(1)
{
dis_5(1,0,k++);
i=dis_hz_row(16,1,p1);
disen_row(1,3,"I Love You @>-+");
dis_en_row(1,5," all peripherals are now initialized..");


}
}



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?