Hi,
My Nokia 3510i LCD has been working well with a PIC16f88 for a while. Now I am trying to migrate the same code to a PIC24FJ64GA002. I am using MPLab C30 compiler. The PIC is configured to run on internal oscillator @ 8MHz. I am not using the PIC SPI module, just bit-banging. However, it doesn't work on the 24F. The LCD doesn't seem to initialize.
My connection from the PIC to the LCD is as follows (the PIC is running from 3.3V):
#define sclk PORTBbits.RB15
#define sdata PORTBbits.RB14
#define rest PORTBbits.RB9
#define cs PORTBbits.RB8
I have tried to test outputting square wave to these individual pins, just to confirm they can be used for output, and it works. Is there anything special about these pins, e.g. analog, comparators, oscillators that need to be disabled?
My code for the LCD (lcd.c) is attached. My main program code to initialize the LCD is:
_CONFIG2(FNOSC_FRCPLL & OSCIOFNC_ON & POSCMOD_NONE & I2C1SEL_PRI) // Internal FRC OSC = 8 MHz
_CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx1) //turn off junk we don't need
int main()
{
TRISB = 0x00;
CLKDIVbits.RCDIV0=0;
AD1PCFG = 0xFFFF;
AD1CON1 = 0; // Disable Analog
OSCCONbits.SOSCEN=0; //Disables the secondary oscilator
LCD_Initialize();
LCD_ColorSet(0); //256-color mode
LCD_Clear(255,0); //set all pixels to white
....
}
What could be the problems or where can I find proper SPI tutorials for the PIC24f? Many Thanks
My Nokia 3510i LCD has been working well with a PIC16f88 for a while. Now I am trying to migrate the same code to a PIC24FJ64GA002. I am using MPLab C30 compiler. The PIC is configured to run on internal oscillator @ 8MHz. I am not using the PIC SPI module, just bit-banging. However, it doesn't work on the 24F. The LCD doesn't seem to initialize.
My connection from the PIC to the LCD is as follows (the PIC is running from 3.3V):
#define sclk PORTBbits.RB15
#define sdata PORTBbits.RB14
#define rest PORTBbits.RB9
#define cs PORTBbits.RB8
I have tried to test outputting square wave to these individual pins, just to confirm they can be used for output, and it works. Is there anything special about these pins, e.g. analog, comparators, oscillators that need to be disabled?
My code for the LCD (lcd.c) is attached. My main program code to initialize the LCD is:
_CONFIG2(FNOSC_FRCPLL & OSCIOFNC_ON & POSCMOD_NONE & I2C1SEL_PRI) // Internal FRC OSC = 8 MHz
_CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx1) //turn off junk we don't need
int main()
{
TRISB = 0x00;
CLKDIVbits.RCDIV0=0;
AD1PCFG = 0xFFFF;
AD1CON1 = 0; // Disable Analog
OSCCONbits.SOSCEN=0; //Disables the secondary oscilator
LCD_Initialize();
LCD_ColorSet(0); //256-color mode
LCD_Clear(255,0); //set all pixels to white
....
}
What could be the problems or where can I find proper SPI tutorials for the PIC24f? Many Thanks
Last edited: