tajiknomi
Member level 4
Okay, so i tried to interface PIC16f722A with LM016L LCD. i had wrote the C-code for initializing (LCD) and displaying characters on LCD. Somehow i got stuck when i simulated the program in Proteus. The problems are as follows:
1)When i transfer X number of characters, it just shows (X-1) number of characters, ignoring the last character.
2) The proteus shows that "Controller(LM016L) was busy while recieving the character".
I didn't used delay in the program,instead, i used one bit (D7) to monitor whether the LCD is busy or not. Here is the screenshot.
Note: I have transfered 4 characters and it displayed only "3"
Here is the C code
I tried and tried to solve what's wrong with the code, still couldn't find the bug that is causing the above 2 issues i have stated.
So i tried to use "built-in Library" provided by the MicroCpro for the LCD, And guess what, i got the same "Controller(LM016L) was busy while recieving the character".
Any help would be appreciated. Thank you.
1)When i transfer X number of characters, it just shows (X-1) number of characters, ignoring the last character.
2) The proteus shows that "Controller(LM016L) was busy while recieving the character".
I didn't used delay in the program,instead, i used one bit (D7) to monitor whether the LCD is busy or not. Here is the screenshot.
Note: I have transfered 4 characters and it displayed only "3"
Here is the C code
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 #include <stdio.h> #include <stdbool.h> #define LCD_DATA PORTB #define LCD_CTRL PORTA sbit LCD_EN at PORTA.B0; // LCD Latch pin (Enable) sbit LCD_RS at PORTA.B1; // Command/Data select PIN | Command(RS=0) | DATA(RS=1) sbit LCD_RW at PORTA.B2; // READ/WRTIE pin | Read (1) | Write (0) #define LCD_DATA_DIRECTION TRISB sbit LCD_EN_Direction at TRISA0_bit; sbit LCD_RS_Direction at TRISA1_bit; sbit LCD_RW_Direction at TRISA2_bit; #define CHECK_BIT(var,pos) (((var)>>(pos)) & 1) // ========================= LCD FUNCTIONS ========================= // LCD Busy-Check function void lcd_ready(){ LCD_DATA_DIRECTION=0xff; // Data ports input LCD_RS=0; // Command register LCD_RW=1; // Read from LCD LCD_EN=0;Delay_ms(1);LCD_EN=1; // Low-to-High signal for latching //while(LCD_DATA && 0x08 == 0x08); // Checking the MSB (B7) for busy indication while(CHECK_BIT(LCD_DATA,7)); // Stay here if the d7 bit is high (i.e. LCD is busy) } // LCD Command write function void lcd_Command_write(char value){ LCD_DATA_DIRECTION=0x00; LCD_RS=0;LCD_RW=0; LCD_DATA=value; LCD_EN=1; delay_ms(1); LCD_EN=0; // High to Low signal for latching } // LCD Display function void lcd_Data_write(char value){ LCD_DATA_DIRECTION=0x00; LCD_RS=1;LCD_RW=0; LCD_DATA=value; LCD_EN=1;delay_ms(1);LCD_EN=0; // High to Low signal for latching } // LCD_POWER(ON/OFF) | ON=1 void LCD_POWER(bool flag){ if(flag){ Delay_ms(250); // Power up delay lcd_ready(); // Is LCD BUSY ? wait here lcd_Command_write(0x38); // LCD 2 Lines, 5x7 characters lcd_ready(); lcd_Command_write(0x0E); // Display ON, Cursor ON lcd_ready(); lcd_Command_write(0x01); // Clear LCD lcd_ready(); lcd_Command_write(0x06); // Shift Cursor Right lcd_ready(); lcd_Command_write(0x80); // Cursor at line 1 position 1 } else{ lcd_ready(); // Is LCD BUSY ? wait here LCD_RS=0; // Select Command Register LCD_RW=0; // Write operation LCD_DATA=0x10; // Cursor and Display off Delay_us(1);LCD_EN=1;Delay_us(1);LCD_EN=0; // Latch } } void main() { LCD_EN_Direction=LCD_RS_Direction=LCD_RW_Direction=0x00; LCD_DATA_DIRECTION=0x00; LCD_POWER(1); LCD_ready(); LCD_DATA_write('1'); LCD_ready(); LCD_DATA_write('2'); LCD_ready(); LCD_DATA_write('3'); LCD_ready(); LCD_DATA_write('4'); // Last character doens't shows up! }
I tried and tried to solve what's wrong with the code, still couldn't find the bug that is causing the above 2 issues i have stated.
So i tried to use "built-in Library" provided by the MicroCpro for the LCD, And guess what, i got the same "Controller(LM016L) was busy while recieving the character".
Any help would be appreciated. Thank you.
Last edited by a moderator: