

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Program: Test LCD Created by: WTB Description: Writes test strings to the LCD and displays rotary count. 0-1 transition on SW3 clears count Last Modified: 2/16/ / //Prototypes void LCD_char(int index, char letter); extern "C" void LCD_write (int cmd_data, char data); extern "C" int Rotary(void); extern "C" int Button_Push(int mask); extern "C" void AsmInit(void); extern "C" void sleep(int usec); //Defines #define CMD 0 #define DATA 4 #define LCD_clear() LCD_write(CMD,1) int main(void) { int ind,count,temp; AsmInit(); //initialize any required ASM variables LCD_clear(); //clear LCD sleep(1640); //wait for command to execute for(ind=0;ind<16;ind++) LCD_char(ind,"Embedded systems"[ind]);//write first string for(ind=0;ind<9;ind++) LCD_char(ind+0x41,"are cool!"[ind]); //write second string count=0; while (1) { count += Rotary(); //increment count based on rotary knob movement if (count>=100) count=0; if (count<0) count=0; if (Button_Push(0x8)) count=0; //clear count based on switch movement temp=count/10; LCD_char(0x4d,'0'+temp); //write 10's digit of count LCD_char(0x4e,'0'+count-10temp); } } void LCD_char(int index, char letter) { LCD_write(CMD,(char)(0x80|index)); LCD_write(DATA,letter); }