10 years, 1 month ago.

blinky stuked

I have the following test code and it compiles programs but does not bilks when i uncomment the serial declaration line or the textlcd line.

main.c

#include "mbed.h"
#include "TextLCD.h"

DigitalOut myled(LED3);

// Host PC Communication channels
Serial pc(USBTX, USBRX); // tx, rx

//Text LCD
//SPI spi_lcd(D11, NC, D13); // MOSI, MISO, SCLK
//TextLCD lcd(&spi_lcd, D12, TextLCD::LCD16x2);   // SPI bus, CS pin, LCD Type
//TextLCD lcd(D5, D4, D3, D2, D1, D0);     // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780

int main()
{

    //lcd.setBacklight(TextLCD::LightOn);
    //lcd.printf("Hello World!\n");

    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

Must be something ridiculous simple can anyone help??

Question relating to:

2 Answers

10 years, 1 month ago.

D1 and D0 can not be used for the LCD. They are required for the serial port connection to the host. Use any other free pins for the LCD instead of D1 and D0.

There may also be an issue with using D12 for SPI CS in the SPI version of the TextLCD. D12 is supposed to be MISO and SPI may not work when that pin is used as CS.

Make sure you update the mbed lib to to most recent version since the lib for the LPC1549 is still being worked on and is not yet complete.

10 years, 1 month ago.

I have reviewed the code but it all compiles and loads but nothing append , no blinking and no driver appears for virtual com port on the device manager.

include the mbed library with this snippet

#include "mbed.h"
#include "TextLCD.h"

DigitalOut myled(LED3);

Serial pc(USBTX, USBRX); // tx, rx

//Text LCD
//SPI spi_lcd(D11, NC, D13); // MOSI, MISO, SCLK
//TextLCD lcd(&spi_lcd, D12, TextLCD::LCD16x2);   // SPI bus, CS pin, LCD Type
TextLCD lcd(D7, D6, D5, D4, D3, D2, TextLCD::LCD16x2, NC, NC, TextLCD::HD44780);  // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780

int main()
{
    lcd.setMode(TextLCD::DispOn);
    lcd.setBacklight(TextLCD::LightOn);
    lcd.printf("Hello World!\n");
    pc.printf("test");
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

You first need to install the driver for the virtual com port on your PC as explained here. Then first remove the TextLCD instructions and try to get the serial port going and the LED blinking.

Then get started on the LCD after making sure that the supply and contrast voltages are OK and all connections are correct.

posted by Wim Huiskamp 13 Mar 2014

There is another issue with your code: you call "lcd.setBacklight(TextLCD::LightOn)" to turn on the backlight. However that is only allowed when you actually define a pin to control the backlight. You have currently defined that pin as 'NC' in the declaration of TextLCD, so the code is stuck. Either provide a valid parameter for that pin (BL) or remove the call to setBacklight().

posted by Wim Huiskamp 13 Mar 2014

Hello again if you review my fist code the leds does not blink just because I have only declared the serial pc. ... statement. I believe something might be wrong on the library pins. (P0_18 and P0_13)

posted by Antonio Gomes 14 Mar 2014

I have also noticed problems with downloading code using the mbed interface method. Only minimal blinky programs will work when using the mbed interface. More elaborate code using printf fails. However, the SAME binary will run fine when you use the USB bootloader mode. Serial port etc will also work fine for that code when you connect the USB cable back to the mbed interface port.

posted by Wim Huiskamp 14 Mar 2014