Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC16/PIC18 to PIC24 code migration

Status
Not open for further replies.

mdanh2002

Newbie level 4
Joined
Dec 27, 2010
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,361
Hi,

I have the attached source code, used to control a Nokia 3510i LCD, that has been working well with a PIC16F88 and PIC18F4550 for a long time. The code is using bit-banging to simulate SPI to interface with the LCD.

Now I am attempting to migrate it to a PIC24FJ64GA002, and strangely enough, it just doesn't work (the LCD does not respond). Similarly my code for a Nokia 5110 LCD, previously working with PIC16/18, also does not work on this PIC24. I have verified and ensured that the PIC24F is working fine by trying to output square wave onto the pins intended to be used for the LCD interface (CS, RESET, CLK, DATA) and everything works. I have also checked thousands times and nothing seems wrong with the connections or the PIC. This leads me into thinking that the architecture (8-bit) vs 16-bit of the PIC24 may have played a role.

I am testing the code by calling

LCD_Initialize();
LCD_ColorSet(0); //256-color
LCD_Clear(0xFF, 0); //all pixels white in 256-color mode

Any advice is appreciated. Thanks!
 

Attachments

  • lcd.c.txt
    4.4 KB · Views: 47
Last edited:

maybe too fast for the LCD???? a common PIC16 works up to 20MHz which means 200ns per instruction, an PIC18 can go up to 40MHz so 100ns per instruction (but at which freq did you worked previously????) i think a PIC24 can go faster than that, but your LCD can switch at which frequency????

that could be an issue...
 

Hi,

Thanks for the very fast reply. I will check the frequency again, one more time, but I have considered it before. The PIC18F4550 I am using for this LCD (which works) is running on internal oscillator @ 8MHz and same for the PIC24 (internal oscillator 8MHz). Another PIC16F88 I tested this LCD on runs on 20MHz and it still works. I have disabled the PLL (x4 so it could be 32MHz) on the PIC24 so it will also run at 8MHz. I even wrote a pin toggle program and check the output on an oscilloscope to see the frequency. Nothing wrong to me.

Could it be some of the bit-wise operations in the code used for SPI bit-banging that behaves differently on the PIC24F?
 

I am answering my own question - hope this will help other with similar problems.

The attached code is correct and there is nothing wrong. The only problem here is that the pin needs to be set via the latch register, LATBbits, and not the port register, PORTBbits. The reason for this is unclear (perhaps some timing issue). Most sites I found recommend using the LAT register for writing, and the PORT register for reading. I defined the SPI pins as:

#define sclk LATBbits.LATB9
#define sdata LATBbits.LATB8
#define rest LATBbits.LATB7
#define cs LATBbits.LATB6

and the LCD starts to initialize and works perfectly.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top