Skip to main content
3 of 3
Improved title. Added code formatting. Added line breaks into text where intended by OP.
SamGibson
  • 18.3k
  • 5
  • 41
  • 63

Driving LCD using PIC18LF27K42

I am struggling to drive an LCD with a PIC18LF27K42.

The functions are all OK. They are working fine with a PIC18F14K50 with the same clock of 4MHz.

I suspect the error is in my configuration bits. I did review it without success.

Thanks for your help

I am using the following pin definitions:

define ENL      LATCbits.LATC7 (OUT)

define RW       LATCbits.LATC6 (OUT)

define RS       LATCbits.LATC5 (OUT)

define DB7      LATAbits.LATA3 (OUT)

define DB6      LATAbits.LATA2 (OUT)

define DB5      LATAbits.LATA1 (out)

define DB4      LATAbits.LATA0 (out)

Before running the main() I am doing the following initialization:

PORTA   = 0x00;
LATA    = 0x00;
ANSELA  = 0x00;
TRISA   = 0xF0;
PORTB   = 0x00;
LATB    = 0x00;
ANSELB  = 0x00;
TRISB   = 0x1F;
PORTC   = 0x00;
LATC    = 0x00;
ANSELC  = 0x00;
TRISC   = 0x1F;

CONFIGURATION BITS

// CONFIG 1L

 #pragma  config  FEXTOSC = HS

 #pragma  config  RSTOSC  = EXTOSC
  
 // CONFIG 1H

 #pragma  config  CLKOUTEN= OFF

 #pragma  config  PR1WAY  = ON

 #pragma  config  CSWEN   = OFF

 #pragma  config  FCMEN   = ON

 
// CONFIG 2L

 #pragma  config  MCLRE   = EXTMCLR

 #pragma  config  PWRTS   = PWRT_OFF

 #pragma  config  MVECEN  = OFF

 #pragma  config  IVT1WAY = OFF

 #pragma  config  LPBOREN = OFF

 #pragma  config  BOREN   = OFF
  
 // CONFIG 2H

 #pragma  config  BORV    = VBOR_2P45

 #pragma  config  ZCD     = OFF      

 #pragma  config  PPS1WAY = OFF

 #pragma  config  STVREN  = ON

 #pragma  config  DEBUG   = OFF

 #pragma  config  XINST   = OFF
  
 // CONFIG 3L

 #pragma  config  WDTCPS  = WDTCPS_31

 #pragma  config  WDTE    = OFF
  
 // CONFIG 3H

 #pragma  config  WDTCWS  = WDTCWS_0

 #pragma  config  WDTCCS  = LFINTOSC
  
 // CONFIG 4L 

 #pragma  config  BBSIZE  = BBSIZE_512

 #pragma  config  BBEN    = OFF

 #pragma  config  SAFEN   = OFF

 #pragma  config  WRTAPP  = OFF
  
 // CONFIG 4H

 #pragma  config  WRTB    = OFF

 #pragma  config  WRTC    = OFF

 #pragma  config  WRTD    = OFF

 #pragma  config  WRTSAF  = OFF

 #pragma  config  LVP     = ON
  
 // CONFIG 5L

 #pragma  config    CP      = OFF
topic
  • 37
  • 7