I am working on a project and I am new at working with GLCD's. I have PIC18F4550 which will be loading an image onto the CFAF176220M. The example for the CFAF176220M shows pin layouts for the AVR setup and a crystalfontz admin said he hasnt worked with PIC's before. So is any one familiar with using the CFAF176220M and maybe can answer questions regarding my setup?
I will be using PORTD on the PIC for the D0-D7 on the CFAF176220M.
The other connections are as follows:
PIC <-> CFAF176220M
RA0 <-> Reset
RA1 <-> RD
RA2 <-> WR
RA3 <-> RS
RA4 <-> CS
The CFAF176220M example in the datasheet shows:
#define LCD_RESETPC2
#define LCD_RD PC5
#define LCD_WR PC6
#define LCD_RS PC7
#define LCD_CS PC4
#define LED_1 PD1
#define LED_2 PD2
// macros for control lines
#define CLR_RS PORTC &= ~(1<<LCD_RS);
#define SET_RS PORTC |= (1<<LCD_RS);
#define CLR_CS PORTC &= ~(1<<LCD_CS);
#define SET_CS PORTC |= (1<<LCD_CS);
#define CLR_RESET PORTC &= ~(1<<LCD_RESET);
#define SET_RESET PORTC |= (1<<LCD_RESET);
#define CLR_WR PORTC &= ~(1 << LCD_WR);
#define SET_WR PORTC |= (1 << LCD_WR);
#define CLR_RD PORTC &= ~(1 << LCD_RD);
#define SET_RD PORTC |= (1 << LCD_RD);
#define LED1_OFF PORTD &= ~(1 << LED_1);
#define LED1_ON PORTD |= (1 << LED_1);
#define LED2_OFF PORTD &= ~(1 << LED_2);
#define LED2_ON PORTD |= (1 << LED_2);
And my "modified" one looks like:
//control lines
#define LCD_RESET LATAbits.LATA0
#define LCD_RD LATAbits.LATA1
#define LCD_WR LATAbits.LATA2
#define LCD_RS LATAbits.LATA3
#define LCD_CS LATAbits.LATA4
#define LED_1 LATEbits.LATE0
#define LED_2 LATEbits.LATE1
#define LED_3 LATEbits.LATE2
#define LCD_DATA LATD
// macros for control lines
#define CLR_RS PORTA &= ~(1<<LCD_RS);
#define SET_RS PORTA |= (1<<LCD_RS);
#define CLR_CS PORTA &= ~(1<<LCD_CS);
#define SET_CS PORTA |= (1<<LCD_CS);
#define CLR_RESET PORTA &= ~(1<<LCD_RESET);
#define SET_RESET PORTA |= (1<<LCD_RESET);
#define CLR_WR PORTC &= ~(1 << LCD_WR);
#define SET_WR PORTC |= (1 << LCD_WR);
#define CLR_RD PORTC &= ~(1 << LCD_RD);
#define SET_RD PORTC |= (1 << LCD_RD);
#define LED1_OFF PORTE &= ~(1 << LED_1);
#define LED1_ON PORTE |= (1 << LED_1);
#define LED2_OFF PORTE &= ~(1 << LED_2);
#define LED2_ON PORTE |= (1 << LED_2);
#define LED3_OFF PORTE &= ~(1 << LED_3);
#define LED3_ON PORTE |= (1 << LED_3);
Thanks for looking thru that, also:
What is the meaning of the LED1_ON/OFF
Arnt the backlight LEDS on as soon as i turn the LCD on?
Thanks for your responses, Frank.
I will be using PORTD on the PIC for the D0-D7 on the CFAF176220M.
The other connections are as follows:
PIC <-> CFAF176220M
RA0 <-> Reset
RA1 <-> RD
RA2 <-> WR
RA3 <-> RS
RA4 <-> CS
The CFAF176220M example in the datasheet shows:
#define LCD_RESETPC2
#define LCD_RD PC5
#define LCD_WR PC6
#define LCD_RS PC7
#define LCD_CS PC4
#define LED_1 PD1
#define LED_2 PD2
// macros for control lines
#define CLR_RS PORTC &= ~(1<<LCD_RS);
#define SET_RS PORTC |= (1<<LCD_RS);
#define CLR_CS PORTC &= ~(1<<LCD_CS);
#define SET_CS PORTC |= (1<<LCD_CS);
#define CLR_RESET PORTC &= ~(1<<LCD_RESET);
#define SET_RESET PORTC |= (1<<LCD_RESET);
#define CLR_WR PORTC &= ~(1 << LCD_WR);
#define SET_WR PORTC |= (1 << LCD_WR);
#define CLR_RD PORTC &= ~(1 << LCD_RD);
#define SET_RD PORTC |= (1 << LCD_RD);
#define LED1_OFF PORTD &= ~(1 << LED_1);
#define LED1_ON PORTD |= (1 << LED_1);
#define LED2_OFF PORTD &= ~(1 << LED_2);
#define LED2_ON PORTD |= (1 << LED_2);
And my "modified" one looks like:
//control lines
#define LCD_RESET LATAbits.LATA0
#define LCD_RD LATAbits.LATA1
#define LCD_WR LATAbits.LATA2
#define LCD_RS LATAbits.LATA3
#define LCD_CS LATAbits.LATA4
#define LED_1 LATEbits.LATE0
#define LED_2 LATEbits.LATE1
#define LED_3 LATEbits.LATE2
#define LCD_DATA LATD
// macros for control lines
#define CLR_RS PORTA &= ~(1<<LCD_RS);
#define SET_RS PORTA |= (1<<LCD_RS);
#define CLR_CS PORTA &= ~(1<<LCD_CS);
#define SET_CS PORTA |= (1<<LCD_CS);
#define CLR_RESET PORTA &= ~(1<<LCD_RESET);
#define SET_RESET PORTA |= (1<<LCD_RESET);
#define CLR_WR PORTC &= ~(1 << LCD_WR);
#define SET_WR PORTC |= (1 << LCD_WR);
#define CLR_RD PORTC &= ~(1 << LCD_RD);
#define SET_RD PORTC |= (1 << LCD_RD);
#define LED1_OFF PORTE &= ~(1 << LED_1);
#define LED1_ON PORTE |= (1 << LED_1);
#define LED2_OFF PORTE &= ~(1 << LED_2);
#define LED2_ON PORTE |= (1 << LED_2);
#define LED3_OFF PORTE &= ~(1 << LED_3);
#define LED3_ON PORTE |= (1 << LED_3);
Thanks for looking thru that, also:
What is the meaning of the LED1_ON/OFF
Arnt the backlight LEDS on as soon as i turn the LCD on?
Thanks for your responses, Frank.
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.