马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
#include <p18f4520.h> #include <delays.h> #include *ov.h* #include *ds18b20.h*
#pragma config OSC=HSPLL,BOREN=OFF,BORV=2,PWRT=ON,WDT=OFF,LVP=OFF
#define OSC_CLOCK 40 #define LCD_RS PORTEbits.RE0 #define LCD_RW PORTEbits.RE1 #define LCD_EN PORTEbits.RE2
void LCDdata_4bit(unsigned char data); void LCDcommand_4bit(unsigned char data); void LCDdata(unsigned char data); void LCDcommand(unsigned char data); void delay_ms(long A);
void main () {
int i; unsigned char ADCValue; unsigned char D(3); ADCON1 =0x0c; ?? TRISD = 0; ? TRISE = 0; ? LCD_EN = 0; LCDcommand(0b00000001); LCDcommand(0b00000010); LCDcommand(0b00000110); LCDcommand(0b00001111); ? LCDcommand(0b00101000); ?? while(1); { ADCValue=ds_get_temp(); PORTD=ADCValue; Delay_ms(1000);
Nop(); LCDcommand(0b100000000); D[0]=ADCValue/100%10; D[1]=ADCValue/10%10; D[2]=ADCValue%10;
For(i=0;i<3;i++){ if(D<10;D+= '0';) LCDdata('D');LCDdata('1') LCDdata('Q'); LCDdata('1') LCDdata('C');LCDdata('='); LCDdata(D[0]);LCDdata(D[1]); LCDdata(D[2];) void LCDdata_4bit(unsigned char data) { inti; LCD_RW=0; LCD_RS=1; LATD=data; LCD_EN=1; ? for(i=0;i<180;i++); LCD_EN=0; }
void LCDcommand_4bit(unsigned char data) { inti; LCD_RW=0; ??? LCD_RS=0; LATD=data; LCD_EN=1; ? for(i=0;i<300;i++); LCD_EN=0; }
void LCDdata(unsigned char data) { unsignedchar temp; temp=data&0xF0; LCDdata_4bit(temp); Nop(); temp=(data<<4)&0xF0; LCDdata_4bit(temp); }
void LCDcommand(unsigned char data) { unsignedchar temp; temp=data&0xF0; LCDcommand_4bit(temp); Nop(); temp=(data<<4)&0xF0; LCDcommand_4bit(temp); }
void delay_ms(long A) { longi; intus2TCY; us2TCY=(10*OSC_CLOCK)>>2; for(i=0;i<A;i++)Delay100TCYx(us2TCY); } |