I am having difficulty with printing text onto the 2x16 LCD (one taken from my old easyPICV7 dev-board) on a PCB I have made.
All the traces from the MCU to the LCD pins are correct, as per the mikroC PRO for PIC32 Help files for the LCD Library.
I would like to ask if anyone can help me get text to appear on the LCD please?
MCU:
- PIC32MX695F512L
- Primary OSC: 20MHz crystal resonator
- Secondary OSC: 32.768kHz crystal resonator
- Sys-Clk frequency: 100MHz
- MCU Power = +3V3
- LCD VCC = +5V
- mikroC PRO for PIC32 v.4.0.0
Pin naming code;
Code: Select all
// ============================================================================= Pin Declarations Section
// ----------------------------------------------------------------------------- LCD Connections
sbit LCD_RS at LATA0_bit;
sbit LCD_EN at LATA1_bit;
sbit LCD_D4 at LATA4_bit;
sbit LCD_D5 at LATA5_bit;
sbit LCD_D6 at LATA6_bit;
sbit LCD_D7 at LATA7_bit;
sbit LCD_BKLT at LATD0_bit;
sbit LCD_RS_Direction at TRISG14_bit;
sbit LCD_EN_Direction at TRISG15_bit;
sbit LCD_D4_Direction at TRISA4_bit;
sbit LCD_D5_Direction at TRISA5_bit;
sbit LCD_D6_Direction at TRISA6_bit;
sbit LCD_D7_Direction at TRISA7_bit;
sbit LCD_BKLT_Direction at TRISD0_bit;
Code: Select all
// ============================================================================= Variables Section
// ----------------------------------------------------------------------------- LCD
//0123456789012345
char txt1[] = "0123456789012345";
char txt2[] = "ABCDEFGHIJKLMNOP";
Code: Select all
// ----------------------------------------------------------------------------- PIC Set-Up
void Init_PIC() { // Configure Registers, Ports/Pins here
// --------------------------------------------------------------------------- Registers
CHECON = 0x32; // Cache Control Register (Copied from LCD Library Help files)
AD1PCFG = 0xFFFF; // Configure AN pins as digital I/O
JTAGEN_bit = 0; // Disable JTAG
PMAEN = 0; // This and PMCON 'ON' bit must be cleared so as to make LATE usable.
PMCON = 0; // Disable Parallel Port Contol
// --------------------------------------------------------------------------- Port pin directions
// -- LCD --
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
//0123456789012345
txt1[16] = "--- Welcome! ---";
txt2[16] = "- Please Wait! -";
Lcd_Out(1, 1, txt1);
Lcd_Out(2, 1, txt2);
}
Code: Select all
// ============================================================================= Main Program Section
void main() {
// --------------------------------------------------------------------------- Config area
Init_PIC(); // Configure PIC
Init_Vari(); // Configure variables
LED_Test(); // Flash LEDs
// --------------------------------------------------------------------------- Display program running message on LCD
Lcd_Cmd(_LCD_CLEAR);
//0123456789012345
txt1[16] = "--All Complete--";
txt2[16] = "-Ready to test!-";
Lcd_Out(1, 1, txt1);
Lcd_Out(2, 1, txt2);
// --------------------------------------------------------------------------- Main Program Loop
while (1) { // Loop
// ------------------------------------------------------------------------- Buttons for LCD
// -- LCD INC --
if (Button (&PORTA, 9, 1, 1)) { // LCD INC pressed
OS_LCD_INC = 1;
}
if (OS_LCD_INC && Button(&PORTA, 9, 1, 0)) { // LCD INC released
BKLT_Current_Duty++;
if (BKLT_Current_Duty >= 11) {
BKLT_Current_Duty = 0;
}
Alter_LCD_Backlight(BKLT_Current_Duty);
OS_LCD_INC = 0;
}
// -- LCD DEC --
if (Button (&PORTA, 10, 1, 1)) { // LCD DEC pressed
OS_LCD_DEC = 1;
}
if (OS_LCD_DEC && Button(&PORTA, 10, 1, 0)) { // LCD DEC released
if (BKLT_Current_Duty == 0) {
BKLT_Current_Duty = 10;
} else {
BKLT_Current_Duty--;
}
Alter_LCD_Backlight(BKLT_Current_Duty);
OS_LCD_DEC = 0;
}
// ------------------------------------------------------------------------- Buttons under Red LEDs
// -- BTN A --
if (Button (&PORTB, 12, 1, 1)) { // BTN A pressed
OS_BTN_A = 1;
}
if (OS_BTN_A && Button(&PORTB, 12, 1, 0)) { // BTN A released
RED_LED_A = ~RED_LED_A;
RED_5A = RED_LED_A;
OS_BTN_A = 0;
}
// -- BTN B --
if (Button (&PORTB, 13, 1, 1)) { // BTN B pressed
OS_BTN_B = 1;
}
if (OS_BTN_B && Button(&PORTB, 13, 1, 0)) { // BTN B released
RED_LED_B = ~RED_LED_B;
RED_5B = RED_LED_B;
OS_BTN_B = 0;
}
// -- BTN C --
if (Button (&PORTB, 14, 1, 1)) { // BTN C pressed
OS_BTN_C = 1;
}
if (OS_BTN_C && Button(&PORTB, 14, 1, 0)) { // BTN C released
RED_LED_C = ~RED_LED_C;
RED_5C = RED_LED_C;
OS_BTN_C = 0;
}
// -- BTN D --
if (Button (&PORTB, 15, 1, 1)) { // BTN D pressed
OS_BTN_D = 1;
}
if (OS_BTN_D && Button(&PORTB, 15, 1, 0)) { // BTN D released
RED_LED_D = ~RED_LED_D;
RED_5D = RED_LED_D;
OS_BTN_D = 0;
}
}
}
- MCU controls several LEDs (successfully tested).
- LCD 2x16 display for general messaging (currently testing).
- Four ADC inputs. 10K trimpots (not yet tested).
- PS2 port for Keyboard (not yet tested).
- I2C will control five PCA9956B IC's. 1MHz clock speed required, which is why the MCU is run at 100MHz sysclock frequency (not yet tested).
- Provision for I2C to communicate between another of these PCB's (not yet tested).
- Code compiles well to MCU.
- Code initialises registers and pins first. Within this, the "Welcome... please wait" message should display on the LCD after LCD initialisation. It does not display this.
- After MCU initialisation code and variable initialisation code, LEDs are tested (flash each colour) and this works.
- Then the LCD should clear, and a new message saying "All complete... ready to test" should appear. It does not appear.
- Within the main loop, especially the 'While-loop', the buttons that raise or lower the backlight of the LCD via PWM work, as does the four other buttons that turn on or off LEDs.
- The LCD will display all character spaces on both rows as 'block'-characters, or, each character is completely lit up. No text.
- LCD_RS equivalent pin is RA0, which is also 'TMS', which is JTAG Test Mode
- LCD_EN equivalent pin is RA1, which is also 'TCK', which is JTAG Test Clock Input Pin
- LCD_D4 equivalent pin is RA4, which is also 'TDI', which is JTAG Test Data Input Pin
- LCD_D5 equivalent pin is RA5, which is also 'TDO', which is JTAG Test Data Output Pin
- LCD_D6 equivalent pin is RA6, which is also 'TRCLK', which is Trace Clock
- LCD_D7 equivalent pin is RA7, which is also 'TRD3', which is Trace Data Bits
Code: Select all
JTAGEN_bit = 0;
Bonus question, I can't find "JTAGEN" bit in any register. Where exactly is it? Especially, which datasheet? As I have looked in a few now.
If there isn't any other code needed, to do with a register or at least stopping the JTAG and Trace functioning of LATA pins, then can anyone see why the LCD isn't displaying text, but block characters instead?
P.S:
- I do not have a development board for the PIC32MX695F512L, as the one I want is out of stock.
- Plus, the few PIC32MX695F512L chips I do have were a chance find that a friend-of-a-friend had.
- After getting them, I really put this PCB together to cover some bases as a testing rig, so to speak.
- It will eventually be used to do things, but it's all I have at the moment.
- Therefore, I can't really test the LCD help file test code from LATB as it's connected to in the help file.
- And again, if people need the entire code of the project thus far, ask, and I'll put it up.