Problem using LCD on PortA and PortE with MiKroC

Status
Not open for further replies.

Nizar

New Member
Every thing works OK when I'm using Proteus with but in the reality when I make my circuit nothing appears on the LCD I'm using PIC18F4550 und LMB162A LCD my Cristal is 8MHZ
I think the problem is by using PortA or PortE when I use PortB or PortD every thing is OK.
Thank You all
This is my Code:

Code:
char *text = "Hello World";

void main()
{
  CMCON |= 0x07;             // turn off comparators
  ADCON1 |= 0x0F;           // turn off analog inputs

  TRISA = 0x00;
  TRISE = 0x00;                        // PORTB is output
  TRISB = 0x00;
  
  Lcd_Custom_Config(&PORTA,3,2,1,0,&PORTE,2,1,0);  // Initialize LCD on PORTB
  Lcd_Custom_Cmd(Lcd_CURSOR_OFF);           // Turn off cursor
  Lcd_Custom_Cmd(LCD_CLEAR);
  Lcd_Custom_Out(1, 1, text);
  
  PORTB.F2 = 1;
  
  while(1)
  {
    Delay_ms(250);  // One second pause
    Lcd_Custom_Cmd(LCD_SHIFT_RIGHT);
    PORTB.F2 = ~PORTB.F2;
  }

}

This is my circuit:
 

Attachments

  • LCD_PIC18F4550.JPG
    97 KB · Views: 799
change this
Code:
  CMCON |= 0x07;             // turn off comparators
  ADCON1 |= 0x0F;           // turn off analog inputs

to this
Code:
  CMCON = 7;             // turn off comparators
  ADCON1 = 0x0F;           // turn off analog inputs

and see what happen
 
Sorry It doesn't work

I put putt-up res. but I get nothing.
So, when do LED test on PortA and PortE (without putt-up res.)I get sometning unblieveable: LEDs RA0 and RA1 blink but RA2 and RA3 light without blinking.
On PortE, I get RE0 and RE1 blinked but RE2 does nothing.
But the programm works good on Proteus
This is the Code:
Code:
//CPU Clock 48MHZ
//PIC18F4550
void main()
{
  CMCON = 0x07;             // turn off comparators
  ADCON1 = 0xFF;           // turn off analog inputs

  TRISA = 0x00;               // PORTA is output
  TRISE = 0x00;                // PORTE is output
  
  PORTA = 0xFF;
  PORTE = 0xFF;
  
  while(1)
  {
    Delay_ms(500);          /* 0.5 second pause */
    PORTA = ~PORTA;
    PORTE = ~PORTE;
  }
}
Circuit on Proteus:
 

Attachments

  • LED_TEST.JPG
    72.4 KB · Views: 656
Try changing all your port reads to latch reads,
so
PORTA = ~PORTA;
becomes
LATA = ~LATA;

Mike.
 
Thank You all


I got it due to Your help:
The Problem is that I used PORT instead of LAT
So, thanks for your help special Pommie.
The New code:
Code:
char *text = "Hello World";

void main()
{
  CMCON = 0x07;             // turn off comparators
  ADCON1 = 0xFF;           // turn off analog inputs

  TRISA = 0x00;                         // PORTA is output
  TRISB = 0x00;                         // PORTB is output
  TRISE = 0x00;                         // PORTE is output
  
  Lcd_Custom_Config(&LATA,3,2,1,0,&LATE,2,1,0);  // Initialize LCD on PORTB
  Lcd_Custom_Cmd(Lcd_CURSOR_OFF);                 // Turn off cursor
  Lcd_Custom_Cmd(LCD_CLEAR);
  Lcd_Custom_Out(1, 16, text);
  
  PORTB.F2 = 1;
  
  while(1)
  {
    Delay_ms(300);               // 0.3 second pause
    Lcd_Custom_Cmd(LCD_SHIFT_LEFT);
    PORTB.F2 = ~LATB.F2;
  }
}
 
Last edited:
Hi,

I just wanted to say thankyou for the LAT/PORT hint.

I have been troubleshooting this issue for two long evening/nights now looking for soft and hard errors.... !

thankyou / Ahd71
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…