david otitoju
/
elec350
h
Diff: main.cpp
- Revision:
- 0:67db5ce17397
diff -r 000000000000 -r 67db5ce17397 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 09 19:48:25 2018 +0000 @@ -0,0 +1,54 @@ +* Function Name : main +* Description : Main program. +*******************************************************************************/ +int main(void) //Main function +{ + +initgpio(); + +int k=0; +char a[]="WWW.EEHERALD.COM"; +char b[]="EMBEDDED SYSTEMS"; + +GPIOC->BRR=RS; //Initialize RS=0 for selecting instruction Send +GPIOC->BRR=RW; // Select RW=0 to write Instruction/data on LCD +GPIOC->BSRR=EN; // EN=1 for unlatch. (used at initial condition) + +delay_ms(10); + +s_init(); //Call Instruction Select routine +GPIOA->ODR=0x0001; // Clear Display, Cursor to Home +s_latch(); //Latch the above instruction +GPIOA->ODR=0x0038; // Display Function (2 rows for 8-bit data; small) +s_latch(); //Latch this above instruction 4 times +s_latch(); +s_latch(); +s_latch(); +GPIOA->ODR=0x000E; // Display and Cursor on, Cursor Blink off +s_latch(); //Latch the above instruction +GPIOA->ODR=0x0010; // Cursor shift left +s_latch(); //Latch the above instruction +GPIOA->ODR=0x0006; // Cursor Increment, Shift off +s_data(); //Change the input type to Data.(before it was instruction input) +s_latch(); //Latch the above instruction + +for(k=0;a[k];k++) +{ +GPIOA->ODR=a[k]; //It will send a[0]='P' as = '0x0050' on Port A. +s_latch(); //Latch the above instruction only once. Or it will clone each character twice if you latch twice. +} +GPIOC->BRR=RS; //Initialize RS=0 for selecting instruction Send +GPIOC->BRR=RW; // Select RW=0 to write Instruction/data on LCD +GPIOC->BSRR=EN; // EN=1 for unlatch. (used at initial condition) + +delay_ms(10); +GPIOA->ODR=0x00C0; // Move cursor to beginning of second row +s_latch(); //Latch the above instruction +s_data(); //Change the input type to Data.(before it was instruction input) +for(k=0;b[k];k++) +{ +GPIOA->ODR=b[k]; //It will send b[0]='E' as = '0x0044' on Port A. +s_latch();//Latch the above instruction only once. Or it will clone each character twice if you latch twice. +} +s_init(); +} \ No newline at end of file