View previous topic :: View next topic |
Author |
Message |
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
Explorer 16/32 LCD not working properly |
Posted: Mon Apr 30, 2018 9:33 pm |
|
|
I'm make a little program to learn how PIC24 works but doesn't work as expected.
In the LCD I get
"OK! "
"SECONDS "
This is the program.
Code: | /*
* File: Test_PIC24_01.c
* Author: E_Blue
*
* Created on 22 de abril de 2018, 00:28
*/
#include <24fj1024gb610.h>
#device ICD=2
#use delay(clock=4M)
#fuses NOPROTECT,XT,NOWDT,ICSP2
//#USE FAST_IO (ALL)
#define LCD_ENABLE_PIN PIN_D4
#define LCD_RS_PIN PIN_B15
#define LCD_RW_PIN PIN_D5
// #define LCD_DATA0 PIN_E0
// #define LCD_DATA1 PIN_E1
// #define LCD_DATA2 PIN_E2
// #define LCD_DATA3 PIN_E3
#define LCD_DATA4 PIN_E4
#define LCD_DATA5 PIN_E5
#define LCD_DATA6 PIN_E6
#define LCD_DATA7 PIN_E7
//*******************************
//#define LCD_LINE_TWO 0xC0
#define LCD_LINE_LENGTH 16
//#define E_LCD 1
//#include <lcd_mod.c>
#include <lcd.c>
#define Led_3 PIN_A0
/*
*
*/
void main() {
long time=0;
// set_tris_a(0xFE);
//set_tris_e(0x00);
lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"LCD OK!");
while(1)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"Seconds: %Lu",time);
//output_high(Led_3);
delay_ms(500);
// output_low(Led_3);
delay_ms(500);
time++;
}
}
|
I tried with the J19(R/W) jumper plugged and unplugged.
The Explorer 16 demo works ok (XC16), I don't understand why CCS code doesn't work.
Since as far I read this microcontroller have remappable pins function I think is something related to port configuration.
I'm new with 16bit microcontrollers, I used a lot a 18F PIC microcontrollers
Does LCD.C is compatible with PIC24FJ? _________________ Electric Blue |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19831
|
|
Posted: Mon Apr 30, 2018 11:12 pm |
|
|
The first thing is where are you getting 4MHz from?. The explorer board has an 8MHz crystal as standard. You may well be overclocking the display.
Do a basic 'flash an LED' test and get your clock options right first. |
|
 |
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
|
Posted: Tue May 01, 2018 9:45 am |
|
|
Flash a LED was the first program, then I added the LCD management code.
At first I make the program thinking that its going to run at 8MHZ as default, but the LED flash at half the speed expected.
I debug this program and seem like the program always read the busy bit as busy.
I also put a breakpoint when the LCD.C routine put LCD_ENABLE_PIN high but I read near to zero volts, so that's why I'm thinking that can be a port configuration problem.
With the flashing LED program it works all ok, and the LED flash OK.
After I added the LCD code the LED never light on.
Anyway I will try what you suggest me just to be 100% sure about clock speed. _________________ Electric Blue |
|
 |
|