// Example 7b: LCD Display // Detect object with IR sensor #include /* common defines and macros */ #include /* derivative information */ #pragma LINK_INFO DERIVATIVE "mc9s12dg256b" #include "main_asm.h" /* interface to the assembly module */ void main(void) { char* q1; char* q2; char* blanks; q1 = "No Object"; q2 = "Object Nearby"; blanks = " "; PLL_init(); // set system clock frequency to 24 MHz lcd_init(); // enable lcd DDRS = 0x08; // PS3 output, PS2 input PTS = 0; // turn on IR transmitter while(1){ if(PTS & 0x04){ // PT2 is 0 for IR return set_lcd_addr(0x00); type_lcd(q1); // write q1 to row 1 set_lcd_addr(0x40); type_lcd(blanks); // write blanks to row 2 } else { set_lcd_addr(0x40); type_lcd(q2); // write q2 to row 2 set_lcd_addr(0x00); type_lcd(blanks); // write blanks to row 1 } } }