LCD not working on 18F45K20, but works on 18F43K20

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
grootjohannes
Posts: 2
Joined: 18 Jul 2018 23:05

LCD not working on 18F45K20, but works on 18F43K20

#1 Post by grootjohannes » 18 Jul 2018 23:34

Hi
I have written software that uses LCD in 4 bit mode, but LCD does not work.
Compiler : V7.2.0
Board : EasyLV-18F V6
On Pic18F43K20, LCD and software runs without problem. Same code fails to drive LCD on 18F45K20

If I compile the same software and load it on pic18F45K20, the LED status changes when I activate my inputs, and my "whatchdog LEd" on Timer0 flashes at exactly the same rate, but the LCD remains blank.

So I know the chip programmed properly as the A/D works, my flashing LEDs flash correctly, and everything reacts as on the 43K20. I know my clock frequency and timer settings are the same as on PIC18F43K20. Only LCD does not work

I checked the "low voltage programming" and other flags, all are the same. I have tried 3 different chips, no change.

UPDATE : 19 Jul 2018 : when changing "OSCCON := %11110011;" to "OSCCON := %10110011;" the LCD works. Whenever " IRCF1" bit is set, the LCD fails to work. Switching to XT / HS oscillator with 12MHz crystal also works.

For some reason when setting the internal clock above 1MHz (IRCF1 to 1) causes the LCD to fail. However, the same code works fine on PIC18F43K20.


have anyone else had this issue? PIC issue or compiler issue?
Attachments
BatteryTester.zip
(124.51 KiB) Downloaded 115 times

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: LCD not working on 18F45K20, but works on 18F43K20

#2 Post by janni » 20 Jul 2018 12:02

When controlling single output pins one should use LAT registers in PIC18 processors. Otherwise, the so-called Read-Modify-Write (RMW) effects may lead to unintended output states. Changing

Code: Select all

// LCD module connections
    var LCD_RS : sbit at RB4_bit;
    var LCD_EN : sbit at RB5_bit;
    var LCD_D4 : sbit at RB0_bit;
    var LCD_D5 : sbit at RB1_bit;
    var LCD_D6 : sbit at RB2_bit;
    var LCD_D7 : sbit at RB3_bit;
to

Code: Select all

// LCD module connections
    var LCD_RS : sbit at LATB.4;
    var LCD_EN : sbit at LATB.5;
    var LCD_D4 : sbit at LATB.0;
    var LCD_D5 : sbit at LATB.1;
    var LCD_D6 : sbit at LATB.2;
    var LCD_D7 : sbit at LATB.3;
should solve your problem.

grootjohannes
Posts: 2
Joined: 18 Jul 2018 23:05

Re: LCD not working on 18F45K20, but works on 18F43K20

#3 Post by grootjohannes » 20 Jul 2018 16:24

Hi Janni

It works!

Thank you!!! :lol:

Post Reply

Return to “mikroPascal PRO for PIC General”