Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 5th February 2009, 04:00 AM   #1
Default Problem using LCD on PortA and PortE with MiKroC

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:
Attached Thumbnails
Problem using LCD on PortA and PortE with MiKroC-lcd_pic18f4550.jpg  
Nizar is offline  
Old 5th February 2009, 10:28 AM   #2
Lightbulb

pull up all data lines d4-d7 with 4.7k resistor to 5v.
yatoof is offline  
Old 5th February 2009, 02:56 PM   #3
Default

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
__________________
Steve
mister_e is offline  
Old 5th February 2009, 04:07 PM   #4
Default Thanks, I will try it

I think this is the problem
Thank You very much
Nizar is offline  
Old 6th February 2009, 02:58 AM   #5
Default

Thank You very much
ROKE2009 is offline  
Old 7th February 2009, 07:01 AM   #6
Default 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:
Attached Thumbnails
Problem using LCD on PortA and PortE with MiKroC-led_test.jpg  
Nizar is offline  
Old 7th February 2009, 07:11 AM   #7
Default

Try changing all your port reads to latch reads,
so
PORTA = ~PORTA;
becomes
LATA = ~LATA;

Mike.
Pommie is online now  
Old 8th February 2009, 04:49 AM   #8
Default 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 by Nizar; 8th February 2009 at 04:51 AM.
Nizar is offline  
Old 4th June 2009, 08:38 PM   #9
Default

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
ahd71 is offline  
Old 15th November 2009, 02:09 AM   #10
Default

Thanks it is working.
kalindusri is offline  
Reply

Tags
lcd, mikroc, porta, porte, problem

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Interrupt on change problem, PORTA mjdeez Micro Controllers 7 11th June 2009 01:58 AM
MikroC Delay_ms() problem!!! cGr Micro Controllers 2 7th November 2008 12:49 PM
mikroC problem colin mac Micro Controllers 12 22nd July 2008 01:02 PM
PORTA output problem skyrock Micro Controllers 2 13th May 2008 11:47 AM
Problem in PORTE register of PIC Hesam Kamalan Micro Controllers 2 11th July 2006 12:51 PM



All times are GMT. The time now is 12:28 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker