Problem with initializing Port A for LCD display

General discussion on mikroC.
Post Reply
Author
Message
ir_amir
Posts: 6
Joined: 05 Feb 2010 05:32

Problem with initializing Port A for LCD display

#1 Post by ir_amir » 18 Mar 2010 19:55

Hi guys.

I am using PIC18F4620 to interface with a 16x2 LCD display using PORT A as pasted in the code below:

Code: Select all

char *text = "mikroElektronika";

void main() {
  PORTA = 0;
  TRISA = 0;                         // PORTA is output
  ADCON1 = 0x0F;
  CMCON = 0x07;

  Lcd_Custom_Config(&PORTA,7,6,5,4,&PORTA,1,2,3);  // Initialize LCD on PORTA
  Lcd_Custom_Cmd(Lcd_CURSOR_OFF);           // Turn off cursor
  Lcd_Custom_Out(1, 1, text);               // Print text at LCD
}
I have read through the datasheet several times and tested the codes many times already but it still doesnt work. Can anyone fix this problem?

Thanks.

AR :idea:

ir_amir
Posts: 6
Joined: 05 Feb 2010 05:32

Re: Problem with initializing Port A for LCD display

#2 Post by ir_amir » 20 Mar 2010 12:12

Hello, anyone can help?Plz..it's just a quick one.. :?:

MARIO
Posts: 978
Joined: 18 Aug 2008 22:13
Location: Brasil

Re: Problem with initializing Port A for LCD display

#3 Post by MARIO » 20 Mar 2010 13:11

I don't know 18F4620 configuration but I think you are having problems with PORTA 6 and 7.
Look at what datasheet says:
OSC2/CLKO/RA6 | RA6 | 0 | O |DIG | LATA<6> data output. Enabled in RCIO, INTIO2 and ECIO modes only.
OSC1/CLKI/RA7 | RA7 | 0 | O | DIG | LATA<7> data output. Disabled in external oscillator modes.
Try another port and see if it works. PORTA is generally confused and in this case pins 6 and 7 are associated with oscillator, making it much more confuse. Maybe someone who has more experience with this MC could help you better than me.

BR.

ir_amir
Posts: 6
Joined: 05 Feb 2010 05:32

Re: Problem with initializing Port A for LCD display

#4 Post by ir_amir » 20 Mar 2010 17:59

Thanks Mario, for your respond. :D Yup, I was having problem with PortA 6 & 7 but I managed to turn off the external OSC configuration mode and set PortA 6 & 7 on. This is done by editing the properties of the project in mikroC that I'm using. But, still nothing comes out of the LCD screen. I've already tried using Port B, C and D. All of them are success.
But I'm using the ports for other I/Os. Therefore, I need to configure PortA to interface as output for my LCD.

Can anyone plz help??

I'll try to use two ports at once,for the moment.

Thanks. If anyone has the answer,plz do reply my post.

basicbasic111
Posts: 127
Joined: 26 Jan 2010 17:01

Re: Problem with initializing Port A for LCD display

#5 Post by basicbasic111 » 15 Apr 2010 08:41

hi,

your post is old

dunno if u r using c pro now

Code: Select all

  //16f4620
    sbit LCD_RS at LATa2_bit;
sbit LCD_EN at LATa3_bit;
sbit LCD_D4 at LATa1_bit;
sbit LCD_D5 at LATa0_bit;
sbit LCD_D6 at LATa6_bit;
sbit LCD_D7 at LATa5_bit;

sbit LCD_RS_Direction at TRISa2_bit;
sbit LCD_EN_Direction at TRISa3_bit;
sbit LCD_D4_Direction at TRISa1_bit;
sbit LCD_D5_Direction at TRISa0_bit;
sbit LCD_D6_Direction at TRISa6_bit;
sbit LCD_D7_Direction at TRISa5_bit;




              char *text = "mikroElektronika";

void main() {

        // turn off comparators
 ADCON1=0x0f;
 cmcon=7;


Lcd_Init();                        // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off

  Lcd_Out(1,1,text);                 // Write text in first row
}

edit project:

choose ( int rc port on ra 6 ra7)

Post Reply

Return to “mikroC General”