My question is in the context of datasheet. I have only one question I do not understand table given in page 42Hi,Why don't you just use available code, use code examples....
You also could try to write your own code...test your code ... and if it does not work as expected:
* show your code
* show your schematic
* tell us what you expect
* tell us what not is like expected
Klaus
I said table given in page 42 is confusing me. I do not understand the sequence given for 4 bit mode which sequence I will need if I want to operate it without a any microcontroller.Hi,
The datasheet tells all you need to know.
You say it's confusing, but don't tell what is confusing to you.Klaus
I do not understand table given in page 42
I do not understand the sequence given for 4 bit mode
if I want to operate it without a any microcontroller.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 delayms(15); lcd cmd(0x03); //000011 delayms(5); lcd cmd(0x03); //000011 delay ms(1); lcd_cmd(0x03); //000011 delay ms(1); lcd cmd(0x02); //000010 Sets to 4-bit operation delay ms(1); lcd cmd(0x08); // Turn off display lcd cmd(0x01); //Clear display delay; lcd_cmd(0x06); //Set cursor move direction
Not quite right. The internal reset defaults to 8-bit mode. If you can rely on it, part of the init sequence can be bypassed. It's however usually assumed that the power on timing may not result in a successful reset and registers have arbitrary content, thus it's a good idea to perform the complete software initialization.Keep in mind that as default, the LCD is set to 4-bit mode.
How can you use a function lcd_cmd() both for 8-bit and 4-bit writes? Please show your implementation of lcd_cmd().
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 void lcd_cmd( int cmd, int ms) { RS = Low; R/W = Low; lcdcommand = cmd; EN = High; delayms(ms); EN = Low; } Void main () { void lcd_cmd( 0x03 , 2); void lcd_cmd( 0x03 , 2); void lcd_cmd( 0x02 , 2); }
Hi,
Page 22, section Interfacing to the MPU
And also in the 4-bit initialisation section.
Klaus
How is this done in your code.This will 0100 send first and then this will send 0100
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 void lcd_cmd2(int cmd, int ms) { RS = Low; R/W = Low; lcdport = cmd >> 4; EN = High; delay_us(1); EN = Low; delay_us(1); lcdport = cmd & 0xf; EN = High; delay_us(1); EN = Low; delay_ms(ms); }
Referring to the previous code, I would suggest something like
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 //PIC16F877A and Xc8 // CONFIG #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) #pragma config WDTE = ON // Watchdog Timer Enable bit (WDT enabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled) #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off) #pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) // #pragma config statements should precede project file includes. // Use project enums instead of #define for ON and OFF. #define _XTAL_FREQ 20000000 //Specify the XTAL crystal FREQ #include <xc.h> #define RS RB1 #define RW RB2 #define EN RB2 #define lcdport PORTA void initialize (void) { PORTA = 0; PORTB = 0; TRISA = 0b00000000; TRISB = 0b00000000; } void Delay_us (int us) { int i; for (i=0; i<us; i++) { } } void lcd_cmd(unsigned char cmd) { RS = 0; RW = 0; lcdport = cmd >> 4; EN = 1; Delay_us(1); EN = 0; Delay_us(1); lcdport = cmd & 0xf; EN = 1; Delay_us(1); EN = 1; Delay_us(1); } void main(void) { //initialize port pins initialize (); lcd_cmd (0x03); while(1) { } return; }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?