View previous topic :: View next topic |
Author |
Message |
kwadwo
Joined: 09 Nov 2017 Posts: 2
|
PIC18F97J94 4-bit LCD not working |
Posted: Thu Nov 09, 2017 11:29 am |
|
|
Hi, has anyone successfully got an LCD to work on PIC18F97J94 in 4-bit mode ?
I cannot get my LCD to work (4-bit ).
The LCD shows black squares.
I program a PIC16F1825 with similar code (only difference is the fuse INTRO_RC that is not accepted on the 18F97J94 and the device header file) and it works.
I have checked the hardware connections and changed the development board (Microchip MA180034).
Please see code below.
Any assistance would be greatly appreciated.
Thank you.
Code: |
#include <18F97J94.h>
#device ADC=10
#define LCD_ENABLE_PIN PIN_E0
#define LCD_RS_PIN PIN_E1
#define LCD_RW_PIN PIN_E2
#define LCD_DATA4 PIN_B4
#define LCD_DATA5 PIN_B5
#define LCD_DATA6 PIN_B6
#define LCD_DATA7 PIN_B7
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#fuses NOWDT, NOPROTECT
#use delay(internal=4MHz)
#pin_select U1TX=PIN_C6
#pin_select U1RX=PIN_C7
#use rs232(baud=9600, UART1, parity=N,stream=RS232,bits=8)
#include <LCD.c>
void main()
{
setup_adc_ports(sAN0|sAN1);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_0);
int i=0;
lcd_init();
delay_ms(100);
lcd_putc("\fReady...\n");
while(TRUE)
{
lcd_putc('\f'); //Clear Display
lcd_putc("Hello World");
delay_ms(2000);
lcd_putc('\f'); //Clear Display
lcd_putc("Welcome To");
lcd_gotoxy(1,2);
lcd_putc("LCD Library");
delay_ms(2000);
lcd_putc('\f');
printf(lcd_putc,"Count = %d", i);
delay_ms(2000);
i++;
output_low(PIN_B0);
}
} |
_________________ KNS |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Thu Nov 09, 2017 12:48 pm |
|
|
You've not got 'something' setup correctly, probably port access. In the LCD.C driver, CCS says what has to be done as far as setup or configuring for using the driver.
I haven't used it in years, since the 'flex_lcd' driver came out.
I suspect you got 'lucky' with the other PIC.
Also there are several code errors like 'adc_clock_internal' and no 'ERRORS' added in the RS232 (...options...)
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Thu Nov 09, 2017 2:02 pm |
|
|
First, a general comment:
The fuses, clock and serial setup should be before you include any library files like stdio.h
If you have these afterwards, it can (in a few specific cases like software serial), cause problems because the timings are not setup.
Much better to get into the habit of configuring the chip _before_ anything else.
The fuse on the 1825, would have been INTRC_IO, and if you look at the data sheet, you will see that this disables the clockout, that otherwise appears on the OSC2 pin. The J94 does not do this, hence no such fuse.
The big problem is you need to disable the internal LCD controller. This has priority over the I/O pins.
setup_lcd(LCD_DISABLED, 0, 0,0); |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 09, 2017 2:07 pm |
|
|
Quote: |
I have checked the hardware connections and changed the development
board (Microchip MA180034). |
I can't find a schematic of this board. It has jumpers on it. I can't find
a manual that explains the jumpers.
What board do you have it plugged into ? Microchip Explorer ? What's the part number ? |
|
|
kwadwo
Joined: 09 Nov 2017 Posts: 2
|
|
Posted: Mon Nov 13, 2017 5:44 am |
|
|
Thank you all for your help. I requested the datasheet for the MA180034 board from Microchip. It turns out the pin-outs are not one-to-one as the supplier suggested. _________________ KNS |
|
|
|