CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Explorer 16/32 LCD not working properly

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
E_Blue



Joined: 13 Apr 2011
Posts: 403

View user's profile Send private message

Explorer 16/32 LCD not working properly
PostPosted: Mon Apr 30, 2018 9:33 pm     Reply with quote

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: 19195

View user's profile Send private message

PostPosted: Mon Apr 30, 2018 11:12 pm     Reply with quote

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: 403

View user's profile Send private message

PostPosted: Tue May 01, 2018 9:45 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group