Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 11 months ago.
[Solved] KLxxz flashing led trouble with gLCD library
Compiling for either KL46z or KL25z targets and running results in red LED blinking. Commenting out the gLCD declaration and lcd. code, results in proper LED operation, of course no lcd though. Is my use of gLCD correct? Is SDI and "lcd" part of declaration even necessary? Presence or absence of LSD display plugged in has no effect. ST7565 controller on Newhaven SPI compatible 128x64 display. I did updates on gLCD & mbed libraries post import. Any thoughts? Thanks!!!
#include "mbed.h" #include "gLCD.h" // graphics mode LCD library fork by Beck // gLCD(cs,res,rs,sdo,sdi,scl,backlight, "name" for graphicsdisplay); //gLCD lcd(PTC16,PTC13,PTE3,PTA13,PTE1,PTE2,PTB3); // PTA13 is place holder as sdi not actually used?? //gLCD lcd(PTC16,PTC13,PTE3,PTA13,PTE1,PTE2,PTB3, "lcd"); gLCD lcd(PTC16,PTC13,PTE3,PTA13,PTE1,PTE2,PTB3); //DigitalOut led1(LED_RED); // 0 turns LED on //DigitalOut led2(LED_GREEN); int main(void) { /* led2 = 0; led1 = 1; lcd.cls(); lcd.locate(0,3); lcd.printf("Well hello there!"); while (1) { led1 = !led1; wait(0.5); } */ }
2 Answers
10 years, 11 months ago.
Declaration seems to expect SPI port pins (sdo,sdi,scl) as parameters 4, 5 and 6
// gLCD(cs,res,rs,sdo,sdi,scl,backlight, "name" for graphicsdisplay);
Your declaration is
gLCD lcd(PTC16,PTC13,PTE3,PTA13,PTE1,PTE2,PTB3);
This does not seem to match with the KL25Z SPI ports PTD2, PTD3, PTD1.
Try:
gLCD lcd(PTC16,PTC13, PTC12, PTD2, PTD3, PTD1, PTC17, "LCD");
And modify your LCD wiring accordingly.
10 years, 11 months ago.
Thanks Wim, however:
gLCD lcd(PTC16,PTC13, PTC12, PTD2, PTD3, PTD1, PTC17, "LCD");
produces the same blinking red led including if I reverse PTD2 & PTD3.
My impression is that the SPI LCD is not actually read and so the SDI choice didn't matter, but including it doesn't seem to change anything. My original pin choices were for pins allowing SPI 1 port, which I thought might be compatible.
Also, the successful compilation produces six warnings like: "Locate inherits implicit virtual "void locate(int x, inty);"" and "Qualified name is not allowed in member declaration in "gLCD/gLCD.h"" I don't know if those are diagnostic for my problem or not.
An example that works using this library would be dandy.
So, still no solution...
Thanks.
In general if you got a red LED blinking (or on the LPC1768/LPC11u24 the leds blinking in a nice pattern), start your serial console, and see what message you get from the mbed. In 95% of the cases it will be: "Pinmap not found", which is for example what Wim described.
Edit: The last pin is a PWM pin, here is a list of acceptable pins:
{LED_RED , PWM_9 , 3}, // PTB18, TPM2 CH0 {LED_GREEN, PWM_10, 3}, // PTB19, TPM2 CH1 {LED_BLUE , PWM_2 , 4}, // PTD1 , TPM0 CH1 // Arduino digital pinout {D0, PWM_9 , 3}, // PTA1 , TPM2 CH0 {D1, PWM_10, 3}, // PTA2 , TPM2 CH1 {D2, PWM_5 , 4}, // PTD4 , TPM0 CH4 {D3, PWM_7 , 3}, // PTA12, TPM1 CH0 {D4, PWM_2 , 3}, // PTA4 , TPM0 CH1 {D5, PWM_3 , 3}, // PTA5 , TPM0 CH2 {D6, PWM_5 , 3}, // PTC8 , TPM0 CH4 {D7, PWM_6 , 3}, // PTC9 , TPM0 CH5 {D8, PWM_8 , 3}, // PTA13, TPM1 CH1 {D9, PWM_6 , 4}, // PTD5 , TPM0 CH5 {D10, PWM_1 , 4}, // PTD0 , TPM0 CH0 {D11, PWM_3 , 4}, // PTD2 , TPM0 CH2 {D12, PWM_4 , 4}, // PTD3 , TPM0 CH3 {D13, PWM_2 , 4}, // PTD1 , TPM0 CH1, {PTA0, PWM_6, 3}, {PTA3, PWM_1, 3}, {PTB0, PWM_7, 3}, {PTB1, PWM_8, 3}, {PTB2, PWM_9, 3}, {PTB3, PWM_10, 3}, {PTC1, PWM_1, 4}, {PTC2, PWM_2, 4}, {PTC3, PWM_3, 4}, {PTC4, PWM_4, 4}, {PTE20, PWM_7, 3}, {PTE21, PWM_8, 3}, {PTE22, PWM_9, 3}, {PTE23, PWM_10, 3}, {PTE24, PWM_1, 3}, {PTE25, PWM_2, 3}, {PTE29, PWM_3, 3}, {PTE30, PWM_4, 3}, {PTE31, PWM_5, 3},
(You can ignore everything except the first pinname).
posted by 14 Jan 2014