Hi all,
I used mikroC lcd library and success fully interfaced my lcd module with pic 18f452 using PORTC, abut now I want to interface it using two different ports,
:control pins in port E and data pins in port E
so I changed my code as follows
sbit LCD_RS at RE0_bit;
sbit LCD_EN at RE2_bit;
sbit LCD_D7 at RC3_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D4 at RC0_bit;
sbit LCD_RS_Direction at TRISE0_bit;
sbit LCD_EN_Direction at TRISE2_bit;
sbit LCD_D7_Direction at TRISC3_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D4_Direction at TRISC0_bit;
void main(){
TRISC=0;
TRISE=0; //this line added to make port E also an output
//rest of the code
}
but it doesnt work , if anybody could let me know how to get thins done it would be a great help, Thanks you.
Interface LCD data and control pins in two different ports
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: Interface LCD data and control pins in two different por
Hi,
If you use PIC18F, please, try to use LAT register, instead of:
Use:
Also, you can add this lines of code to configure pins as digital:
For additional information please take a look at PIC18F452 datasheet.
Also, please, check your Project Settings (Project -> Edit Project) and double check your hardware connection.
Best regards,
Marina
If you use PIC18F, please, try to use LAT register, instead of:
Code: Select all
sbit LCD_RS at RE0_bit;
sbit LCD_EN at RE2_bit;
sbit LCD_D7 at RC3_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D4 at RC0_bit;
Code: Select all
sbit LCD_RS at LATE0_bit;
sbit LCD_EN at LATE2_bit;
sbit LCD_D7 at LATC3_bit;
sbit LCD_D6 at LATC2_bit;
sbit LCD_D5 at LATC1_bit;
sbit LCD_D4 at LATC0_bit;
Code: Select all
ADCON0 = 0;
ADCON1 = 0;
Also, please, check your Project Settings (Project -> Edit Project) and double check your hardware connection.
Best regards,
Marina
Re: Interface LCD data and control pins in two different por
Thank you Mariana,
changing code
sbit LCD_RS at LATE0_bit;
sbit LCD_EN at LATE2_bit;
sbit LCD_D7 at LATC3_bit;
sbit LCD_D6 at LATC2_bit;
sbit LCD_D5 at LATC1_bit;
sbit LCD_D4 at LATC0_bit;
itself resolved my issue,
but I wonder why it didnt work it with "RC0_bit" format because it worked when use just PORTC to interface the LCD.
I was really frustrated with this.. thanks again for the great help
changing code
sbit LCD_RS at LATE0_bit;
sbit LCD_EN at LATE2_bit;
sbit LCD_D7 at LATC3_bit;
sbit LCD_D6 at LATC2_bit;
sbit LCD_D5 at LATC1_bit;
sbit LCD_D4 at LATC0_bit;
itself resolved my issue,
but I wonder why it didnt work it with "RC0_bit" format because it worked when use just PORTC to interface the LCD.
I was really frustrated with this.. thanks again for the great help