Interface LCD data and control pins in two different ports

Beta Testing discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
chris89
Posts: 4
Joined: 27 Dec 2013 07:38

Interface LCD data and control pins in two different ports

#1 Post by chris89 » 27 Dec 2013 07:55

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.

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: Interface LCD data and control pins in two different por

#2 Post by marina.petrovic » 27 Dec 2013 11:01

Hi,

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;
Use:

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;
Also, you can add this lines of code to configure pins as digital:

Code: Select all

ADCON0 = 0;
ADCON1 = 0;
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

chris89
Posts: 4
Joined: 27 Dec 2013 07:38

Re: Interface LCD data and control pins in two different por

#3 Post by chris89 » 27 Dec 2013 13:24

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 :)

Post Reply

Return to “mikroC PRO for PIC32 Beta Testing”