3 Replies Latest reply on Oct 11, 2016 1:14 PM by Intel_Peter

    SPI - Nokia 5110 display (transfer only mode)


      I'm trying add to my application simple LCD display (from Nokia 5110). I have code as below but the display don't want to print any data. I checked lines MOSI and SCK (via oscilloscope) and the data is transmited into the display properly. I checked also qm_spi_transfer() function but the result is QM_RC_OK = 0 so all should be ok, but is not. Have maybe somebody any idea? Did I made some SPI or initialization mistake ?




      #include <qm_common.h>

      #include "qm_gpio.h"

      #include "qm_spi.h"

      #include "qm_pinmux.h"

      #include "qm_scss.h"


      #define LEL_YELLOW 10

      #define DC 5

      #define CE 2

      #define RST 8


      #define SPI_CLOCK_DIV (256)

      #define BUFFERSIZE (504)

      #define CMD_BUFFERSIZE (1)


      static uint8_t tx_buff [] = {

      0xFC, 0xFE, 0xFF, 0xFF,..........0xFF, 0xFF, 0xFF, 0x7F, 0x3F,



      static uint8_t cmd_buff;


      void lcd_data(qm_spi_transfer_t * polled_xfer_desc);

      void lcd_reset(void);

      void lcd_cmd(uint8_t cmd, qm_spi_transfer_t * cmd_polled_xfer_desc);


      int main(void)


        qm_spi_config_t cfg;

        qm_spi_transfer_t polled_xfer_desc;

        qm_spi_transfer_t cmd_polled_xfer_desc;


        qm_gpio_port_config_t gpio_cfg; /* GPIO */


        gpio_cfg.direction = BIT(LEL_YELLOW) | BIT(DC) | BIT(CE) | BIT(RST);  /*Led */

        qm_gpio_set_config(QM_GPIO_0, &gpio_cfg);


        qm_pmux_select(QM_PIN_ID_0, QM_PMUX_FN_2);  /* SS0 */

        qm_pmux_select(QM_PIN_ID_16, QM_PMUX_FN_2); /* SCK */

        qm_pmux_select(QM_PIN_ID_17, QM_PMUX_FN_2); /* TXD */


        qm_pmux_input_en(QM_PIN_ID_16, false);

        qm_pmux_input_en(QM_PIN_ID_17, false);


        clk_periph_enable(CLK_PERIPH_CLK | CLK_PERIPH_SPI_M0_REGISTER);


        cfg.frame_size = QM_SPI_FRAME_SIZE_8_BIT;

        cfg.transfer_mode = QM_SPI_TMOD_TX;

        cfg.bus_mode = QM_SPI_BMODE_0;

        cfg.clk_divider = SPI_CLOCK_DIV;


        qm_spi_set_config(QM_SPI_MST_0, &cfg);

        qm_spi_slave_select(QM_SPI_MST_0, QM_SPI_SS_0);


        polled_xfer_desc.tx = tx_buff;

        polled_xfer_desc.tx_len = BUFFERSIZE;

        polled_xfer_desc.rx = NULL;

        polled_xfer_desc.rx_len = 0;


        cmd_polled_xfer_desc.tx = &cmd_buff;

        cmd_polled_xfer_desc.tx_len = CMD_BUFFERSIZE;

        cmd_polled_xfer_desc.rx = NULL;

        cmd_polled_xfer_desc.rx_len = 0;



        qm_gpio_clear_pin(QM_GPIO_0, LEL_YELLOW);

        qm_gpio_set_pin(QM_GPIO_0, LEL_YELLOW);

        qm_gpio_clear_pin(QM_GPIO_0, LEL_YELLOW);



        qm_gpio_set_pin(QM_GPIO_0, CE);

        qm_gpio_set_pin(QM_GPIO_0, RST);



        /*make reset*/



        lcd_cmd(0x21, &cmd_polled_xfer_desc);

        lcd_cmd(0xB8, &cmd_polled_xfer_desc);

        lcd_cmd(0x04, &cmd_polled_xfer_desc);

        lcd_cmd(0x14, &cmd_polled_xfer_desc);


        lcd_cmd(0x20, &cmd_polled_xfer_desc);

        lcd_cmd(0x0C, &cmd_polled_xfer_desc);


        lcd_data( &polled_xfer_desc);



        QM_PRINTF("some text - spi\n");


        lcd_data( &polled_xfer_desc);




        return 0;



      void lcd_data(qm_spi_transfer_t * polled_xfer_desc)


        qm_gpio_set_pin(QM_GPIO_0, DC);

        qm_gpio_clear_pin(QM_GPIO_0, CE);

        QM_PRINTF("CMD %X\n", qm_spi_transfer(QM_SPI_MST_0, polled_xfer_desc));

        qm_gpio_set_pin(QM_GPIO_0, CE);



      void lcd_reset(void){

        qm_gpio_clear_pin(QM_GPIO_0, RST);


        qm_gpio_set_pin(QM_GPIO_0, RST);



      void lcd_cmd(uint8_t cmd, qm_spi_transfer_t * cmd_polled_xfer_desc){

        cmd_buff = cmd;

        qm_gpio_clear_pin(QM_GPIO_0, CE | DC);

        QM_PRINTF("CMD %X\n", qm_spi_transfer(QM_SPI_MST_0, cmd_polled_xfer_desc));

        qm_gpio_set_pin(QM_GPIO_0, CE);



      Best regards,


        • 1. Re: SPI - Nokia 5110 display (transfer only mode)

          Hello mark_kram,


          I will try to help you. According to your description it seems like everything on the D2000's side is working fine, so I'd suggest you to double check the physical connections between the D2000's and the display. Check that the LCD is being powered properly and in case you use a level translator before the display check that it is outputting the signals correctly.


          Also, it would also be useful to check whether or not the issue is the display itself. Have you tried it with another board? If so, does it work correctly?


          Let me know.


          • 2. Re: SPI - Nokia 5110 display (transfer only mode)

            Hi Peter,

               my physical connection looks as below I made test on second D2000 board and the effect is the same. Maybe there is some problem with speed of SPI or initialization procedure ?

            btw. VCC of LCD is connected to J22_4 (3.3V) and DGN to J22_6 (GND)



            Best regards,




            • 3. Re: SPI - Nokia 5110 display (transfer only mode)

              Is it possible for you to test it with a different board (I mean not a D2000)? I'd like to determine if the issue is caused by the LCD or the D2000 and if you manage to use the display with let's say an Arduino it would tell us that in fact the issue is something on the D2000 or QMSI side. This is because you mentioned that the SPI signals are sent correctly to the LCD, could you please let us know how you did those measurements?


              I will be waiting for your response.