Home > other >  10-110 temperature range
10-110 temperature range

Time:09-29

Using tlc1549 how to output data, according to the array to convert temperature and gave me 1602 thanks! Dear god,

CodePudding user response:

C language code, urgent need, thank you all for the great god,

CodePudding user response:

# include & lt; Reg52. H> # include & lt; Stdio. H> # define OSC 11059200 # define BAUDRATE 9600 # define LCD1602_DB P0 sbit clock=P1 ^ 5; Sbit dataout=P1 ^ 6; Sbit cs=P1 ^ 7; Sbit LCD1602_RS=P2 ^ 0; Sbit LCD1602_RW=P2 ^ 1; Sbit LCD1602_E=P2 ^ 4; Unsigned int ADConvert (); Void InitLcd1602 (); Void LcdShowStr (unsigned char x, unsigned char y, unsigned char * STR); Unsigned int ReadTLC1549 (void); Unsigned char STR [1]=x0000 {0}; Unsigned int rdat=0; Void main () {InitLcd1602 (); ReadTLC1549 (); STR [1]=rdat; LcdShowStr (2, 0, STR); }//read TLC1549 function: unsigned int ReadTLC1549 (void) {unsigned char (I); Cs=0;//plate can make the for (I=0; I<10; I++) {clock=0; Clock=1;//rise along the read data rdat<=1; If (dataout==1) rdat |=0 x0001;//read from the high of the else rdat |=0 x0000;//if it is zero, don't do processing} cs=1;//piece selected ban return rdat; }/* ready wait for LCD */void LcdWaitReady () {unsigned char sta. LCD1602_DB=0 XFF; LCD1602_RS=0; LCD1602_RW=1; Do {LCD1602_E=1; The sta=LCD1602_DB;//read status word LCD1602_E=0; } while (sta & amp; 0 x80); LCD is busy//bit7 equals 1 said, repeating test until it is equal to 0}/* to write a byte order, LCD1602 LCD CMD - writing command values to be */void LcdWriteCmd (unsigned char CMD) {LcdWaitReady (); LCD1602_RS=0; LCD1602_RW=0; LCD1602_DB=CMD; LCD1602_E=1; LCD1602_E=0; }/* to write a byte of data, LCD1602 LCD dat - to write data values */void LcdWriteDat unsigned char (dat) {LcdWaitReady (); LCD1602_RS=1; LCD1602_RW=0; LCD1602_DB=dat; LCD1602_E=1; LCD1602_E=0; }/* set the display RAM starting address, i.e. the cursor position (x, y) - */void LcdSetCursor corresponding characters on the screen coordinates (unsigned char x, unsigned char y) {unsigned char addr. If (y==0) {//by input screen coordinates calculation shows the RAM address addr=0 x00 + x;//the first line of characters from address 0 x00 starting} else {addr=0 x40 + x;//the second line character address x40 starting from 0} LcdWriteCmd (addr | 0 x80);//set the RAM address}/* on the liquid crystal display string, (x, y) - corresponding starting coordinates on the screen, the STR - string pointer */void LcdShowStr (unsigned char x, unsigned char y, unsigned char * STR) {LcdSetCursor (x, y);//set the starting address while (* STR!='\ 0') {//write string data in a row, until the end of detected LcdWriteDat str++ (*);//take STR pointing to the data first and then since STR + 1}}/* initialized 1602 LCD */void InitLcd1602 () {LcdWriteCmd x38 (0);//16 * 2, 5 * 7 lattice, 8 bits of data interface LcdWriteCmd x0c (0);//display, the cursor closed LcdWriteCmd x06 (0);//text, address automatically + 1 lcdwritecmd (0 x01); }//clear screen

CodePudding user response:

Here is my code, please god help me to rewrite it,
  • Related