ELE2303 WORKSHOP 5 – Strings, conversions and LCD Demo section How to use LCD and string functions Problem section 1. Create your own project for a PIC18F4620 processor (assume Fosc = 10Mhz) Include the “atraso.h” and “lcd.h”, atraso.c and lcd.c in your project as well as your main program. Look for these in folder on study desk in workshops area. Your main program is to use the functions provided initialise the LCD, create a prompt “Click button RB0” and display it on the LCD, wait for RB0 button to be pressed and then output “pressed” to the second line of the display. [ Make sure you use #pragma config WDT = OFF in your main program ] Use lcd_cmd(0b11000000); to start on line 2. 2. Also include in the main program. Modify the program to test for a button press on RB1 or RB0 and concatenate text “RB1” or “RB0” to the “pressed” string before sending it to the display 3. Declare a character, an integer and float and initialise them to a known value. Use the built in functions btoa, itoa and ftoa to convert those values to strings. Send those stings to the display, one at a time with a 2 second delay between. Homework section Complete all the parts of the workshop above. Table 7.6 HD44780 instruction set Instruction Code RS R/W B7 B6 B5 B4 B3 B2 B1 B0 Description Exe ticm ut eion Clear display Cursor home Entry mode set Display on/off control Cursor /display shift Function set Set CGRAM address Set DDRAM address Read busy flag and address counter Write to CGRAM or DDRAM Read from CGRAM or DDRAM Clears display and returns cursor to the home position (address 0). Returns cursor to home position (address 0). Also returns display being shifted to the original position. DDRAM contents remain unchanged. Set cursor move direction (I/D), specifies to shift the display (S). These operations are performed during data read/write. Sets on/off of all display (D), cursor on/off (C) and blink of cursor position character (B). Sets cursor-move or display-(S/C), shift direction (R/L). DDRAM contents remains unchanged. Sets interface data length (DL), number of display line (N) and character font (F). Sets the CGRAM address. CGRAM data is sent and received after this setting. Sets the DDRAM address. DDRAM data is sent and received after this setting. Reads busy flag (BF) indicating internal operation is being performed and reads CGRAM or DDRAM address counter contents (depending on previous instruction). Writes data to CGRAM or DDRAM. Reads data from CGRAM or DDRAM. 1.64 ms 1.64 ms 40 s 40 s 40 s 40 s 40 s 40 s 0 s 40 s 40 s 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 BF 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 DL 0 0 0 1 S/C N 0 0 1 D R/L F 0 1 I/D C * * 1 * S B * * CGRAM address DDRAM address CGRAM/DDRAM address write data read data