徐州工程学院毕业设计(论文)
asm(”nop”); asm(”nop”); lcd_clear_e();
LCD_OP_PORT=(Data<<4)|temp; lcd_clear_rw(); lcd_set_rs(); lcd_set_e(); asm(”nop”); asm(”nop”); lcd_clear_e(); }
//*********************************// //***初始化液晶***//
//*********************************// void Init_LCD(void) {
LCD_INIT();
LCD_WriteControl(LCD_FUNCTION_SET); LCD_WriteControl(LCD_OFF); LCD_WriteControl(LCD_CLEAR); LCD_WriteControl(LCD_MODE_SET); LCD_WriteControl(LCD_ON); LCD_WrlteControl(LCD_HOME); //LCD_WriteControl(0x90); }
//************************************************// / /***清屏 ***//
//************************************************// void LCD_Clear(void) {
LCD_WriteControl(0x01); }
//***********************************************// //***移动光标到0行0列***//
//***********************************************// void LCD_Home(void) {
LCD_WriteControl(0x02); \}
//**********************************************// //***显示字符,在当前光标处***//
//***********************************************// void LCD_DisplayCharacter(char Char) {
LCD_WriteData(Char); }
33
徐州工程学院毕业设计(论文)
//***********************************************// //***在Flash中、在指定的行和列显示一个字符串***// //***********************************************//
void LCD_DisplayString_F(char rOW,char column,unsigned char__flash*string) {
LCD_Cursor(row,column); while(*string) }
LCD_DisplayCharacter(*string++); } }
//***********************************************// //***在RAM中、在指定的行和列显示一个字符串***// //***********************************************//
void LCD_DisplayString(char row,char column,unsigned char*string) {
LCD_Cursor(row,column); while(*string)
LCD_DisplayCharacter(*string++); }
//***********************************************// //***定位行和列的光标***//
//***********************************************// void LCD_Cursor(char row,char column) {
switch (row) {
case 1:LCD_WriteControl(0x80+column一1);break; case 2:LCD_WriteControl(0xc0+column一1);break; case 3:LCD_WriteControl(0x94+column—1);break; case 4:LCD_WriteControl(0xd4+column—1);break; default:break; } }
//**************************// //***打开光标***//
//**************************// void LCD_Cursor_On(void) {
LCD_WriteControl(LCD_CURS_ON); }
//***************************// //***关闭光标***//
//***************************// void LCD_Cursor_Off(void) {
LCD_WriteControl(LCD_ON);
34
徐州工程学院毕业设计(论文)
//********************// //***关闭LCD***//
//*************杀******// void LCD_Display_Off(void) {
LCD_WriteControl(LCD_OFF); }
//*******************// //***打开LCD***// //******************// void LCD_Display_On(void) {
LCD_WriteControl(LCD_ON); }
MAIN.C
#include”includes.h”
#define WDR() asm(”wdr”)
unsigned char alarm _1_set,alarm_2_set,alarm_3_set; __flash unsigned char test[ ]=”DSl302 time is:”; void main(void) {
unsigned char hour,min,sec; unsigned char date,month; unsigned char flag; flag=1;
PORTB=0x00; DDRB=0x00; DDRD=0x7f; PORTD=0xFF; Init_LCD();
LCD_DisplayString(0,1,”Initialize OK!”); delay_nms(500);
LCD_WriteControl(LCD_CLEAR); WDR();
writebyte(w_protect,0x00); //设置时间
//writebyte(sec_w,0x09); //writebyte(min_w,0x09); //writebyte(hour_w,0x09); while(1) {
sec =readbyte(sec_r); //读秒 min =readbyte(min_r); //读分 hour =readbyte(hour_r); //读小时 month =readbyte(month_r); date =readbyte(date_r);
35
徐州工程学院毕业设计(论文)
WDR();
LCD_DisplayString_F(1,1,test); if(flag) {
LCD_Cursor(2,1);
LCD_DisplayCharacter(~+hour/10); LCD_DisplayCharacter(~+hour%lO); LCD_DisplayCharacter(’:,); WDR();
LCD_DisplayCharacter(~+m~/10)} LCD_DisplayCharacter(~+min%10); LCD_DisplayCharacter(':’); WDR();
LCD_DisplayCharacter(d~+s~/10); LCD_DisplayCharacter(~+sec%10): LCD_Cursor(2,ii); WDR();
LCD_DisplayCharacter(~Y+month/10); LCD DisplayCharacter(dY+month%10); LCD_DisplayCharacter<-/0; WDR();
LCD_DisplayCharacter(~+date/10); LCD_DisplayCharacter(~+date%10): WDR(); } } }
usart.c
#define USART_C #include”includes.h” void usart_putchar(char c) {
if(c==飞rr)
usart_putchar@f);
while(UCSRA&(1<<5)); UDR=c: )
void init—usart(void) {
//USART initialization
//Communication Parameters:8 Data,1 Stop。No Parity //USART Receiver:Off //USART Transmitter:On
//USART Mode:Asynchronous //USART Baud rate:19200 UCSRA=Ox00;
36
徐州工程学院毕业设计(论文)
UCSRB=Ox08; UCSRC=0x86; UBRRH=0x00; UBRRL=0x0C;
37
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库段峰的毕业设计(8)在线全文阅读。
相关推荐: