We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
#include<lpc21xx.h> void SendMessage(char *Message); void SendByteSerially(unsigned char a); void initLCD(void); void enable(void); void LCD_WriteChar(unsigned char c); void LCD_WriteString(unsigned char *z); void LCD_Cmd(unsigned int cmd); void delay(void);
#define CR 0x0D
void initLCD(void) { IODIR0 = 0xFF; //P0.0 to P0.7 configured as Output - Using 8 Bit mode IODIR0 |= (1<<16) | (1<<17); //P1.16 and P1.17 configured as Output - Control Pins // IOPIN0 = 0x0; //Reset Port0 to 0. // IOPIN1 = 0x0; //Reset Port1 to 0 - Which also makes RS and Enable LOW.
//LCD Initialization Sequence Now starts delay(); //Initial Delay LCD_Cmd(0x38); LCD_Cmd(0x04); LCD_Cmd(0x01); LCD_Cmd(0x0c); LCD_Cmd(0x80);
// LCD_Cmd(0x3C); //Function Set Command : 8 Bit Mode , 2 Rows , 5x10 Font Style // LCD_Cmd(0x0F); //Display Switch Command : Display on , Cursor on , Blink on // LCD_Cmd(0x06); //Input Set : Increment Mode // LCD_Cmd(0x01); //Screen Clear Command , Cursor at Home // LCD_Cmd(0x80); //Not required the 1st time but needed to reposition the cursor at home after Clearing Screen //Done! }
void enable(void) { delay();
// IOSET1=0x000e0000; IOPIN0 |= (1<<17);//Enable=High delay(); delay(); //IOCLR1=0x000e0000; IOPIN0 &= ~(1<<17);//Enable=Low delay(); }
void LCD_WriteChar(unsigned char c) { IOPIN0 = c& 0x000000FF; IOPIN0 |= (1<<16); //(char)Switch to Data Mode // c+=3; // (char)Supply Character Code enable(); //Pulse Enable to process it !='\0' }
void LCD_WriteString(unsigned char *z) { // unsigned int i=0; while(*z!='\0') { // LCD_WriteChar(*z++);
} /*do {
z++; }while(1); */ }
void LCD_Cmd(unsigned char cmd) { IOPIN0 = cmd& 0x000000FF; IOPIN0 &= ~(1<<17); IOPIN0 &= ~(1<<16); // IOPIN1 = 0x00000000; //Enter Instruction Mode //Supply Instruction/Command Code enable(); //Pulse Enable to process it }
void delay(void) { int i=0,x=0; for(i=0; i<19999; i++){ x++; } } ////////////// int putchar (int ch) { /* Write character to Serial Port */
if (ch == '\n') { while (!(U1LSR & 0x20)); U1THR = CR; /* output CR */ } while (!(U1LSR & 0x20)); return (U1THR = ch); }
int getchar (void) { /* Read character from Serial Port */
while (!(U1LSR & 0x01));
return (U1RBR); }
void srl() { PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */ U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */ U1LCR = 0x03; } /////////////
void main() { initLCD(); srl(); // 20 INPUT 24 OUT // init_uart1(); IODIR1 &= ~((1<<20)) ; // explicitly making P0.7 as Input - even though by default its already Input IODIR1 |= (1<<21); IODIR1 |= (1<<22);
/* DLAB = 0 */
while(1) { //LCD Now intialized and ready to Print! LCD_Cmd(0x80);LCD_WriteString("RFID BASED VEHICLE"); LCD_Cmd(0xC0); LCD_WriteString("ADHOC N/W");
if( !(IOPIN1 & (1<<20)) ) // Evaluates to True for a 'LOW' on P0.7 { IOSET1 |= (1<<21); // drive P0.30 High
IOCLR1 |= (1<<22); LCD_Cmd(0x01); LCD_Cmd(0x80);LCD_WriteString(" !ALERT!"); LCD_Cmd(0xC0); LCD_WriteString(" ALCOHOL DETECTED");
printf (" ALCOHOL DETECTED\n");
} else if( (IOPIN1 & (1<<20)) ) // Evaluates to True for a 'HIGH' on P0.7 { IOCLR1 |= (1<<21); // drive P0.30 High IOSET1 |= (1<<22); } while ((U1LSR & 0x01)) { if(U1RBR=='a') { LCD_Cmd(0xC0); LCD_WriteString(" 123456"); }}
} }
Is there a question in there somewhere? Also please read the posting tips before pasting in source code in an unreadable form. Thanks
IOCLR1 |= (1<<22); LCD_Cmd(0x01); LCD_Cmd(0x80);LCD_WriteString(" !ALERT!"); LCD_Cmd(0xC0); LCD_WriteString(" ALCOHOL DETECTED IN BLOOD STREAM. LOTS MORE BEER REQUIRED");
printf (" ALCOHOL DETECTED IN BLOOD STREAM - LOTS MORE BEER REQUIRED\n");
} else if( (IOPIN1 & (1<<20)) ) // Evaluates to True for a 'HIGH' on P0.7 { IOCLR1 |= (1<<21); // drive P0.30 High IOSET1 |= (1<<22); } while ((U1LSR & 0x01)) { if(U1RBR=='a') { LCD_Cmd(0xC0); LCD_WriteString(" GLUG GLUG"); }}
That was an even bigger fail than the first post. I guess reading the posting instructions and looking at the preview taxed your concentration too much.
I answered the post! Look. I added some relevance to the mess.
I added some relevance to the mess. a relevant mess is still a mess
the issue here is the OPs imnability to read/follow directions
Erik
Whooooooshhhh. The sound made when something said passes straight over your head.
well, that is obvious, you did not not the instructions either
@kevin matusch ....u r a no match dude (being sarcastic) #sic.
define:"erik malund"
Verb, example "to erik malund a post". Entering text into a forum and hitting the post button without first checking for typographical errors, grammar, spelling etc.
that may be, but I follow the posting instructions