This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28377S: INTERFACING ST7567 LCD with tms320f28377s microcontroller

Part Number: TMS320F28377S
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: Code Composer Studio

Dear All,

I am trying to interface ST7567 based graphical lcd-tms320f28377s TG12864H3-03A EN_V1.1.pdf. I inteface this lcd with tms320 with prallel connection and it is working fine. But when I try SPI interface (using software spi)  then display not showing any thing. I connect LCD in four wire mode usng MOSI, SCLK,CS, RS (A0). As given in data sheet(please see the attachment). And my code is as follow. I connect mosi on d7 and sclk on d6 as given in st7567 controller data sheet. Other connection are also correct. I think there is problem in initilization of lcd

const unsigned char A12[95][6] =
  {
  {0x0,0x0,0x0,0x0,0x0,0x0},        //
  {0x0,0x0,0x4F,0x0,0x0,0x0},        // !
  {0x0,0x7,0x0,0x7,0x0,0x0},        // "
  {0x14,0x7F,0x14,0x7F,0x14,0x0},    //#
  {0x24,0x2A,0x7F,0x2A,0x12,0x0},    //$
  {0x23,0x13,0x8,0x64,0x62,0x0},    //%
  {0x36,0x49,0x55,0x22,0x50,0x0},    //&
  {0x0,0x5,0x3,0x0,0x0,0x0},        //'
  {0x0,0x1C,0x22,0x41,0x0,0x0},    //(
  {0x0,0x41,0x22,0x1C,0x0,0x0},    //)
  {0x14,0x8,0x3E,0x8,0x14,0x0},    //*
  {0x8,0x8,0x3E,0x8,0x8,0x0},        //+
  {0x0,0x50,0x30,0x0,0x0,0x0},    //,
  {0x8,0x8,0x8,0x8,0x8,0x0},        //-
  {0x0,0x60,0x60,0x0,0x0,0x0},    //.
  {0x20,0x10,0x8,0x4,0x2,0x0},    // /
  {0x3E,0x51,0x49,0x45,0x3E,0x0},    //0
  {0x0,0x42,0x7F,0x40,0x0,0x0},    //1
  {0x42,0x61,0x51,0x49,0x46,0x0},    //2
  {0x21,0x41,0x45,0x4B,0x31,0x0},    //3
  {0x18,0x14,0x12,0x7F,0x10,0x0},    //4
  {0x27,0x45,0x45,0x45,0x39,0x0},    //5
  {0x3C,0x4A,0x49,0x49,0x30,0x0},    //6
  {0x1,0x71,0x9,0x5,0x3,0x0},        //7
  {0x36,0x49,0x49,0x49,0x36,0x0},    //8
  {0x6,0x49,0x49,0x29,0x1E,0x0},    //9
  {0x0,0x36,0x36,0x0,0x0,0x0},    //:
  {0x0,0x56,0x36,0x0,0x0,0x0},    //;
  {0x8,0x14,0x22,0x41,0x0,0x0},    //<
  {0x14,0x14,0x14,0x14,0x14,0x0},    //=
  {0x0,0x41,0x22,0x14,0x8,0x0},    //>
  {0x2,0x1,0x51,0x9,0x6,0x0},        //?
  {0x32,0x49,0x79,0x41,0x3E,0x0},    //@
  {0x7E,0x11,0x11,0x11,0x7E,0x0},    //A
  {0x7F,0x49,0x49,0x49,0x36,0x0},    //B
  {0x3E,0x41,0x41,0x41,0x22,0x0},    //C
  {0x7F,0x41,0x41,0x22,0x1C,0x0},    //D
  {0x7F,0x49,0x49,0x49,0x41,0x0},    //E
  {0x7F,0x9,0x9,0x9,0x1,0x0},        //F
  {0x3E,0x41,0x49,0x49,0x7A,0x0},    //G
  {0x7F,0x8,0x8,0x8,0x7F,0x0},    //H
  {0x0,0x41,0x7F,0x41,0x0,0x0},    //I
  {0x20,0x40,0x41,0x3F,0x1,0x0},    //J
  {0x7F,0x8,0x14,0x22,0x41,0x0},    //K
  {0x7F,0x40,0x40,0x40,0x40,0x0},    //L
  {0x7F,0x2,0xC,0x2,0x7F,0x0},    //M
  {0x7F,0x4,0x8,0x10,0x7F,0x0},    //N
  {0x3E,0x41,0x41,0x41,0x3E,0x0},    //O
  {0x7F,0x9,0x9,0x9,0x6,0x0},        //P
  {0x3E,0x41,0x51,0x21,0x5E,0x0},    //Q
  {0x7F,0x9,0x19,0x29,0x46,0x0},    //R
  {0x46,0x49,0x49,0x49,0x31,0x0},    //S
  {0x1,0x1,0x7F,0x1,0x1,0x0},        //T
  {0x3F,0x40,0x40,0x40,0x3F,0x0},    //U
  {0x1F,0x20,0x40,0x20,0x1F,0x0},    //V
  {0x3F,0x40,0x38,0x40,0x3F,0x0},    //W
  {0x63,0x14,0x8,0x14,0x63,0x0},    //X
  {0x7,0x8,0x70,0x8,0x7,0x0},        //Y
  {0x61,0x51,0x49,0x45,0x43,0x0},    //Z
  {0x0,0x7F,0x41,0x41,0x0,0x0},    //[
  {0x15,0x16,0x7C,0x16,0x15,0x0},    //
  {0x0,0x41,0x41,0x7F,0x0,0x0},    //]
  {0x4,0x2,0x1,0x2,0x4,0x0},        //^
  {0x40,0x40,0x40,0x40,0x40,0x0},    //_
  {0x0,0x1,0x2,0x4,0x0,0x0},        //
  {0x20,0x54,0x54,0x54,0x78,0x0},    //a
  {0x7F,0x48,0x44,0x44,0x38,0x0},    //b
  {0x38,0x44,0x44,0x44,0x20,0x0},    //c
  {0x38,0x44,0x44,0x48,0x7F,0x0},    //d
  {0x38,0x54,0x54,0x54,0x18,0x0},    //e
  {0x8,0x7E,0x9,0x1,0x2,0x0},        //f
  {0xC,0x52,0x52,0x52,0x3E,0x0},    //g
  {0x7F,0x8,0x4,0x4,0x78,0x0},    //h
  {0x0,0x44,0x7D,0x40,0x0,0x0},    //i
  {0x20,0x40,0x44,0x3D,0x0,0x0},    //j
  {0x7F,0x10,0x28,0x44,0x0,0x0},    //k
  {0x0,0x41,0x7F,0x40,0x0,0x0},    //l
  {0x7C,0x4,0x18,0x4,0x78,0x0},    //m
  {0x7C,0x8,0x4,0x4,0x78,0x0},    //n
  {0x30,0x48,0x48,0x48,0x30,0x0},    //o
  {0x7C,0x14,0x14,0x14,0x8,0x0},    //p
  {0x8,0x14,0x14,0x18,0x7C,0x0},    //q
  {0x7C,0x8,0x4,0x4,0x8,0x0},        //r
  {0x48,0x54,0x54,0x54,0x20,0x0},    //s
  {0x4,0x3F,0x44,0x40,0x20,0x0},    //t
  {0x3C,0x40,0x40,0x20,0x7C,0x0},    //u
  {0x1C,0x20,0x40,0x20,0x1C,0x0},    //v
  {0x3C,0x40,0x30,0x40,0x3C,0x0},    //w
  {0x44,0x28,0x10,0x28,0x44,0x0},    //x
  {0xC,0x50,0x50,0x50,0x3C,0x0},    //y
  {0x44,0x64,0x54,0x4C,0x44,0x0},    //z
  {0x0,0x8,0x36,0x41,0x0,0x0},    //{
  {0x0,0x0,0x7F,0x0,0x0,0x0},        //|
  {0x0,0x41,0x36,0x8,0x0,0x0}        //}
  };

 //------------------------------------------------------------------------------
 // File generated by LCD Assistant
 // en.radzio.dxp.pl/.../
 //------------------------------------------------------------------------------


 const unsigned char butterfly[128][8]=
 {
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
     0x00,0x00,0x00,0x02,0x10,0x00,0x00,0x00,
     0x00,0x00,0x00,0x06,0x10,0x00,0x00,0x00,
     0x00,0x00,0x00,0x04,0x10,0x00,0x00,0x00,
     0x00,0x00,0x00,0x04,0x10,0x00,0x00,0x00,
     0x00,0x00,0x00,0x08,0x10,0x00,0x00,0x00,
     0x00,0x00,0x00,0x08,0x10,0x00,0x00,0x00,
     0x00,0x00,0x00,0x09,0xF8,0x00,0x00,0x00,
     0x00,0x00,0x00,0x0B,0xF8,0x00,0x00,0x00,
     0x00,0x00,0x00,0x0A,0x24,0x00,0x00,0x00,
     0x00,0x00,0x00,0x08,0x24,0x00,0x00,0x00,
     0x00,0x00,0x00,0x04,0x24,0x00,0x00,0x00,
     0x00,0x00,0x00,0x04,0x64,0x00,0x00,0x00,
     0x00,0x00,0x00,0x08,0x44,0x00,0x00,0x00,
     0x00,0x00,0x00,0x08,0x44,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x88,0x00,0x00,0x00,
     0x00,0x00,0x00,0x10,0x88,0x00,0x00,0x00,
     0x00,0x00,0x00,0x11,0x18,0x00,0x00,0x00,
     0x00,0x00,0x00,0x12,0x10,0x00,0x00,0x00,
     0x00,0x00,0x00,0x02,0x20,0x00,0x00,0x00,
     0x00,0x00,0x00,0x04,0x40,0x00,0x00,0x00,
     0x00,0x00,0x00,0x0C,0x80,0x00,0x00,0x00,
     0x00,0x00,0x01,0xFB,0x80,0x00,0x00,0x00,
     0x00,0x00,0x03,0x36,0x00,0x00,0x00,0x00,
     0x00,0x00,0x02,0x9C,0x00,0x1F,0xF8,0x00,
     0x00,0x00,0x04,0x30,0x00,0xFF,0xFE,0x00,
     0x00,0x00,0x04,0xD0,0x03,0xFF,0xC7,0x80,
     0x00,0x00,0x05,0xE0,0x0F,0xF0,0xFD,0xC0,
     0x00,0x00,0x07,0x30,0x3E,0x38,0x7F,0xE0,
     0x00,0x00,0x07,0x10,0x7E,0x1C,0x3F,0xF0,
     0x00,0x00,0x07,0x10,0xFF,0x8F,0xFD,0xF8,
     0x00,0x00,0x07,0x21,0xFF,0x87,0x30,0x00,
     0x00,0x00,0x0D,0xE7,0xC3,0xEF,0x60,0x00,
     0x00,0x00,0x08,0x4F,0x03,0xDC,0xC0,0x00,
     0x00,0x00,0x08,0x1C,0x03,0x38,0xC0,0x00,
     0x00,0x00,0x08,0x78,0x06,0x21,0x80,0x00,
     0x00,0x00,0x18,0x7F,0xFE,0x41,0x00,0x00,
     0x00,0x00,0x18,0x7F,0xFE,0x83,0x00,0x00,
     0x00,0x00,0x18,0x7F,0xFF,0xFE,0x00,0x00,
     0x00,0x00,0x1F,0xFF,0xFF,0xFE,0x00,0x00,
     0x00,0x00,0x27,0xB8,0xF1,0xFE,0x00,0x00,
     0x00,0x00,0x20,0xF0,0x39,0xFC,0x00,0x00,
     0x00,0x00,0x60,0xF8,0x9C,0xFE,0x00,0x00,
     0x00,0x00,0x61,0xFF,0x3C,0x6F,0x00,0x00,
     0x00,0x00,0x61,0x3E,0x7C,0x77,0x80,0x00,
     0x00,0x00,0x61,0x00,0xFC,0x33,0xC0,0x00,
     0x00,0x00,0xE3,0x41,0xFE,0x30,0xE0,0x00,
     0x00,0x01,0x9E,0x3F,0xE7,0x18,0xF0,0x00,
     0x00,0x01,0x9E,0x0F,0x81,0xD9,0xF8,0x00,
     0x00,0x07,0x04,0x00,0x00,0x0D,0x18,0x00,
     0x00,0x7F,0x0C,0x70,0x1F,0x8C,0x4C,0x00,
     0x00,0x7E,0x0C,0x38,0x3F,0xF4,0x26,0x00,
     0x00,0x7C,0x1D,0x0C,0x44,0xFE,0x96,0x00,
     0x00,0x40,0x35,0xCE,0x04,0xBE,0x6B,0x00,
     0x00,0x70,0x37,0xE7,0x06,0x4E,0x25,0x80,
     0x00,0x3F,0xF3,0xF3,0x82,0x47,0x2C,0x80,
     0x00,0x1F,0xF3,0x9B,0x82,0x21,0x3F,0xC0,
     0x00,0x00,0xFB,0x8D,0xC1,0x20,0x7F,0xC0,
     0x00,0x00,0xF9,0x85,0xFC,0x10,0xFF,0xE0,
     0x00,0x01,0xF9,0xC0,0xFE,0x01,0xFF,0xE0,
     0x00,0x01,0xF5,0xC2,0xF1,0x73,0xE0,0xF0,
     0x00,0x01,0x75,0xC0,0x70,0x3F,0x80,0x70,
     0x00,0x01,0x75,0xE0,0x70,0x1F,0x00,0x30,
     0x00,0x03,0x7D,0xF0,0x70,0x1F,0x00,0x08,
     0x00,0x03,0x7C,0xFD,0xE0,0x3E,0x00,0x00,
     0x00,0x02,0x7C,0xFF,0xC0,0xFC,0x00,0x00,
     0x00,0x06,0xFC,0xEF,0x83,0xF8,0x00,0x00,
     0x00,0x07,0x78,0x4F,0xFF,0xF0,0x00,0x00,
     0x00,0x07,0x78,0x47,0xFF,0xE0,0x00,0x00,
     0x00,0x0E,0xFC,0x15,0xFF,0x80,0x00,0x00,
     0x00,0x0E,0x3E,0x54,0x3E,0x00,0x00,0x00,
     0x00,0x0A,0x3F,0x94,0x00,0x00,0x00,0x00,
     0x00,0x1E,0x33,0x16,0x00,0x00,0x00,0x00,
     0x00,0x1F,0xA0,0x16,0x00,0x00,0x00,0x00,
     0x00,0x38,0x64,0x1E,0x00,0x00,0x00,0x00,
     0x00,0x37,0xE0,0x1E,0x00,0x00,0x00,0x00,
     0x00,0x7F,0xEC,0x1E,0x00,0x00,0x00,0x00,
     0x00,0x7F,0xFC,0x1E,0x00,0x00,0x00,0x00,
     0x00,0xE0,0x7C,0x1E,0x00,0x00,0x00,0x00,
     0x00,0xC0,0x7D,0x3C,0x00,0x00,0x00,0x00,
     0x01,0x80,0x67,0xF4,0x00,0x00,0x00,0x00,
     0x03,0x80,0xC6,0x44,0x00,0x00,0x00,0x00,
     0x07,0x00,0xC3,0x0C,0x00,0x00,0x00,0x00,
     0x0E,0x00,0xC1,0xAC,0x00,0x00,0x00,0x00,
     0x1A,0x00,0x80,0x08,0x00,0x00,0x00,0x00,
     0x1C,0x01,0x9C,0xD8,0x00,0x00,0x00,0x00,
     0x34,0x01,0xF3,0x98,0x00,0x00,0x00,0x00,
     0x3C,0x03,0xE7,0x30,0x00,0x00,0x00,0x00,
     0x68,0x03,0xCE,0x70,0x00,0x00,0x00,0x00,
     0x58,0x07,0x8F,0xE0,0x00,0x00,0x00,0x00,
     0x70,0x07,0x0F,0xE0,0x00,0x00,0x00,0x00,
     0x30,0x0F,0xFF,0xC0,0x00,0x00,0x00,0x00,
     0x00,0x0F,0xFF,0x80,0x00,0x00,0x00,0x00,
     0x00,0x1F,0xFF,0x00,0x00,0x00,0x00,0x00,
     0x00,0x1F,0x9C,0x00,0x00,0x00,0x00,0x00,
     0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
     0x01,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
     0x03,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,
     0x03,0x60,0x00,0x00,0x00,0x00,0x00,0x00,
     0x03,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
     0x07,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
     0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
     0x05,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
     0x04,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
     0x07,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
     0x07,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
     0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 };


void lcd_data_out(unsigned char data)
 {
   SpiaRegs.SPITXBUF=(data<<8);// Send data

   us(500);

   return;
 }

 void LCD_WRITE_CMD(unsigned char cmd)
 {
    LCD_RS_L                us(50);

    LCD_CS_L                 us(50);

    //LCD_RW_L                us(50);
    soft_spi_data(cmd);     us(50);
    //lcd_data_out(cmd);    us(500);

    //LCD_RW_H;               us(50);

    LCD_CS_H;                  us(50);

    //LCD_RS_H                 us(500);

    return;
 }

 void LCD_WRITE_DATA(unsigned char data)
 {
    LCD_RS_H                us(50);

    LCD_CS_L                 us(50);

    //LCD_RW_L              us(50);

    soft_spi_data(data);    us(50);

    //lcd_data_out(data);    us(500);

    //LCD_RW_H;               us(50);

    LCD_CS_H;                  us(50);

    //LCD_RS_L;                us(500);

    return;
 }

 void LCD_INIT(void)
 {
  // C86_H;        us(50);        //Enable SPI Mode

  // LCD_RW_H           us(200);

   //LCD_EN;       us(200);

   LCD_RST_H;     ms(20);         // Set RST

   LCD_RST_L;    ms(50); ms(50); ms(50)

   LCD_RST_H;     ms(20);         // Set RST

   LCD_RS_L      us(50);

   //LCD_CS_L;     us(50);


   /*
    LCD_WRITE_CMD(0xA0); // ADC select
      LCD_WRITE_CMD(0xA2); // SET BIAS=1/9
      LCD_WRITE_CMD(0xCF); // COM SCAN DIRECTION(C63-C0)
      LCD_WRITE_CMD(0x2C); // POWER CONTROL1      boost on
      LCD_WRITE_CMD(0x2E); // POWER CONTROL2      regulator on 110
      LCD_WRITE_CMD(0x2F); // POWER CONTROL3      follow on
      LCD_WRITE_CMD(0x26); // REGULATOR RESISOR SELECT R2 R1 R0
      LCD_WRITE_CMD(0x81); // SET REFERENCE VOLTAGE MODE //???
      LCD_WRITE_CMD(0x17); // SET REFERENCE VOLTAGE REGISTER  C5 C4 C3 C2 C1 C0:010111 a=17H
      LCD_WRITE_CMD(0xA4); // DISPLAY  OFF
      //LCD_WRITE_CMD(0xA7); // NORMAL DISPLAY
      LCD_WRITE_CMD(0xA6); // NORMAL DISPLAY
      LCD_WRITE_CMD(0xB0); // 1st PAGE
      LCD_WRITE_CMD(0x40); // INITIAL START LINE
      LCD_WRITE_CMD(0x10); // SET COLUMN ADDR (H)
      LCD_WRITE_CMD(0x00); // SET COLUMN ADDR (L)
    LCD_WRITE_CMD(0xAF); // DISPLAY  ON
*/

/*   LCD_WRITE_CMD(0xA0);      // ADC select
   LCD_WRITE_CMD(0xA2);      // SET BIAS=1/9,dont use 1/7
   LCD_WRITE_CMD(0xCF);      // COM SCAN DIRECTION(C63-C0)
   LCD_WRITE_CMD(0x2C);      // POWER CONTROL1      boost on
   LCD_WRITE_CMD(0x2E);      // POWER CONTROL2      regulator on 110
   LCD_WRITE_CMD(0x2F);      // POWER CONTROL3      follow on
   LCD_WRITE_CMD(0x25);      // REGULATOR RESISOR SELECT R2 R1 R025    //25
   LCD_WRITE_CMD(0xbf);         // SET REFERENCE VOLTAGE MODE //???for contract adjustment of lcd,ev voltage
   LCD_WRITE_CMD(0x07);      // SET REFERENCE VOLTAGE MODE //???for contract adjustment of lcd,ev voltage
   LCD_WRITE_CMD(0x17);      // SET REFERENCE VOLTAGE REGISTER  C5 C4 C3 C2 C1 C0:010111 a=17H
   LCD_WRITE_CMD(0xA4);      // DISPLAY  OFF
   LCD_WRITE_CMD(0xA6);         // NORMAL DISPLAY
   LCD_WRITE_CMD(0xB0);         // 1st PAGE
   LCD_WRITE_CMD(0x40);         // INITIAL START LINE
   LCD_WRITE_CMD(0x10);         // SET COLUMN ADDR (H)
   LCD_WRITE_CMD(0x00);      // SET COLUMN ADDR (L)
   LCD_WRITE_CMD(0xAF);      // DISPLAY  ON
*/

  LCD_WRITE_CMD(0xE2);      // ADC select
  LCD_WRITE_CMD(0xA3);      // SET BIAS=1/9,dont use 1/7
  LCD_WRITE_CMD(0xAF);      // COM SCAN DIRECTION(C63-C0)
  LCD_WRITE_CMD(0xC8);
  LCD_WRITE_CMD(0x22);
  LCD_WRITE_CMD(0x2C);      // POWER CONTROL1      boost on
  LCD_WRITE_CMD(0x2E);      // POWER CONTROL2      regulator on 110
  LCD_WRITE_CMD(0x2F);      // POWER CONTROL3      follow on
  LCD_WRITE_CMD(0x25);      // REGULATOR RESISOR SELECT R2 R1 R025    //25
  LCD_WRITE_CMD(0xbf);     // SET REFERENCE VOLTAGE MODE //???for contract adjustment of lcd,ev voltage
  LCD_WRITE_CMD(0x07);      // SET REFERENCE VOLTAGE MODE //???for contract adjustment of lcd,ev voltage
  LCD_WRITE_CMD(0x17);      // SET REFERENCE VOLTAGE REGISTER  C5 C4 C3 C2 C1 C0:010111 a=17H
  LCD_WRITE_CMD(0xA4);      // DISPLAY  OFF
  LCD_WRITE_CMD(0xA6);     // NORMAL DISPLAY
  LCD_WRITE_CMD(0xB0);     // 1st PAGE
  LCD_WRITE_CMD(0x40);     // INITIAL START LINE
  LCD_WRITE_CMD(0x10);     // SET COLUMN ADDR (H)
  LCD_WRITE_CMD(0x00);      // SET COLUMN ADDR (L)
  LCD_WRITE_CMD(0xAF);      // DISPLAY  ON*/


/*
   LCD_WRITE_CMD(0xA2); // SET BIAS=1/9
   LCD_WRITE_CMD(0xCF); // COM SCAN DIRECTION(C63-C0)
   LCD_WRITE_CMD(0x2C); // POWER CONTROL1      boost on
   LCD_WRITE_CMD(0x2E); // POWER CONTROL2      regulator on 110
   LCD_WRITE_CMD(0x2F); // POWER CONTROL3      follow on
   LCD_WRITE_CMD(0x25); // REGULATOR RESISOR SELECT R2 R1 R0
   LCD_WRITE_CMD(0x81); // SET REFERENCE VOLTAGE MODE //???
   LCD_WRITE_CMD(0x17); // SET REFERENCE VOLTAGE REGISTER  C5 C4 C3 C2 C1 C0:010111 a=17H
   LCD_WRITE_CMD(0xA4); // DISPLAY  OFF
         //LCD_WRITE_CMD(0xA7); // NORMAL DISPLAY
   LCD_WRITE_CMD(0xA6); // NORMAL DISPLAY
   LCD_WRITE_CMD(0xB0); // 1st PAGE
   LCD_WRITE_CMD(0x40); // INITIAL START LINE
   LCD_WRITE_CMD(0x10); // SET COLUMN ADDR (H)
   LCD_WRITE_CMD(0x00); // SET COLUMN ADDR (L)
   LCD_WRITE_CMD(0xAF); // DISPLAY  ON
*/


  return;
 }

 void lcd_on(void)
 {
   LCD_WRITE_CMD(0xAE);
   return;
 }

 void lcd_off(void)
 {
   LCD_WRITE_CMD(0xAF);
   return;
 }

 void all_pixel_on1(void)
 {
   LCD_WRITE_CMD(0xA5);
   return;
 }

 void all_pixel_off1(void)
 {
  LCD_WRITE_CMD(0xA4);
  return;
 }

 void goto_row1(unsigned int y)
 {
     unsigned char pattern;
    pattern=0xB0 | (y & 0xBF); //put row address on data port set command
    LCD_WRITE_CMD(pattern);
    return;;
 }

 void goto_col1(unsigned int x)
 {
   unsigned int pattern;
   pattern=((0xF0&x)>>4)|0x10;
   LCD_WRITE_CMD(pattern);    //set high byte column command
   pattern=((0x0F&x))|0x00;
   LCD_WRITE_CMD(pattern);    //set low byte column command;
   return;
 }

 void goto_xy1(unsigned int x,unsigned int y)
 {
   goto_col1(x);
   us(10);
   goto_row1(y);
   us(10);
   return;
 }

 void glcd_write1(unsigned char b)
 {
    LCD_WRITE_DATA(b);    //put data on data port
     us(10);
 }

 void LCD_CLEAR(void)
 {
     unsigned char i = 0,j = 0;

     LCD_SET_PAGE(PAGE1,0);        // initial page, col

     for(i = 0; i < 8; i ++)
     {
     for(j = 0; j < 128; j ++)
         LCD_WRITE_DATA(0x00);

     LCD_SET_PAGE(PAGE1 + i + 1 , 0);    // increment page
     }
     LCD_SET_PAGE(PAGE1,0);        // initial page,col
 }

 void LCD_SET_PAGE(unsigned char page,unsigned char col)
 {
    unsigned char msb,lsb;
     msb        =    (((col & 0xF0) >> 4)| 0x10);
     lsb        =    (col & 0x0F) ;
     LCD_WRITE_CMD(page);
     LCD_WRITE_CMD(msb);
     LCD_WRITE_CMD(lsb);
 }

 void Display_Page1(void)
 {
  //co/const unsigned char  *msg1 = {"       Hello!!!      "};
  const unsigned char  *msg1 = {"123456789101112131411819"};

   PAGE = PAGE1;
   COL  =    COL1;
   LCD_SET_PAGE(PAGE,COL);        // initial page,col

    while(*msg1 != '\0')
     {
       LCD_PRINT_FONT1(*msg1);
       msg1++;
     }
 }

 void Display_Page2(void)
 {
  const unsigned char  *msg2 = {"     SHAKTI PUMP     "};


         PAGE = PAGE2;
         COL  =    COL1;
         LCD_SET_PAGE(PAGE,COL);        // initial page,col
         while(*msg2 != '\0')
         {
             LCD_PRINT_FONT1(*msg2);
             msg2++;
         }
 }

 void Display_Page3(void)
 {
  const unsigned char  *msg3 =    {"    PUMING LIFE    "};


         PAGE = PAGE3;
         COL  =    COL1;
         LCD_SET_PAGE(PAGE,COL);        // initial page,col
         while(*msg3 != '\0')
         {
             LCD_PRINT_FONT1(*msg3);
             msg3++;
         }
 }

 void Display_Page4(void)
 {
  const unsigned char  *msg4 =    {"       INDORE       "};


         PAGE = PAGE4;
         COL  =    COL1;
         LCD_SET_PAGE(PAGE,COL);        // initial page,col
         while(*msg4 != '\0')
         {
             LCD_PRINT_FONT1(*msg4);
             msg4++;
         }
 }
 void Display_Page5(void)
 {
  const unsigned char  *msg5 =    {" "};


         PAGE = PAGE5;
         COL  =    COL1;
         LCD_SET_PAGE(PAGE,COL);        // initial page,col
         while(*msg5 != '\0')
         {
             LCD_PRINT_FONT1(*msg5);
             msg5++;
         }
 return;
 }
 void Display_Page6(void)
 {
  const unsigned char  *msg6 =    {"     ALL THE BEST   "};


         PAGE = PAGE6;
         COL  =    COL1;
         LCD_SET_PAGE(PAGE,COL);        // initial page,col
         while(*msg6 != '\0')
         {
             LCD_PRINT_FONT1(*msg6);
             msg6++;
         }
  return;
 }

 void Display_Page7(void)
 {
  const unsigned char  *msg7 =    {"      THANK YOU        "};


         PAGE = PAGE7;
         COL  =    COL1;
         LCD_SET_PAGE(PAGE,COL);        // initial page,col
         while(*msg7 != '\0')
         {
             LCD_PRINT_FONT1(*msg7);
             msg7++;
         }
  return;
 }

 void Display_Page8(void)
 {
  const unsigned char  *msg8 =    {"      GOOD BYE     "};

         PAGE = PAGE8;
         COL  =    COL1;
         LCD_SET_PAGE(PAGE,COL);        // initial page,col

         while(*msg8 != '\0')
         {
             LCD_PRINT_FONT1(*msg8);
             msg8++;
         }

  return;
 }

 void LCD_PRINT_FONT1(unsigned char data)
 {
     unsigned char i,j,index;

     static unsigned char PAGE_var =    PAGE1;

     static unsigned char COL_var  =    COL1;

     index    = data - 32;

     LCD_PAGE_COL_CHECK_FONT1();

     for(i = 0; i < 6; i++)
     LCD_WRITE_DATA(A12[index][i]);

     COL += 1;
  return;
 }

 void LCD_PAGE_COL_CHECK_FONT1(void)
 {
     if (COL >= 22)
     {
         PAGE += 1;
         if(PAGE        >=    PAGE8 + 1)
             LCD_CLEAR();

         COL     =    COL1;

         LCD_SET_PAGE(PAGE,COL);        // initial page,col
     }

    return;
 }

 void SetSPage(void)
 {
     PAGE= PAGE1;
     LCD_WRITE_CMD(PAGE);        // Set page address
     LCD_WRITE_CMD(0x10);        // Set coloumn addr  MSB
     LCD_WRITE_CMD(0x00);        // Set coloumn addr LSB
 }

 void display_image(void)
 {
  DispImage(&newlogo2);
  return;
 }

 void DispImage(unsigned char *Adata)
 {
     int row,col,col1,row1=1024;
         for(row=7;row>=0;row--)
         {
             row1=row1-1;
             col1=row1;
             for(col=127;col>=0;col--)
             {
                 LCD_WRITE_DATA(Adata[col1]);
                 col1=col1-8;
             }
             PAGE++;
             LCD_WRITE_CMD(PAGE);
             LCD_WRITE_CMD(0x10);
             LCD_WRITE_CMD(0x00);
         }
 }

 void display_output_pin(void)
 {

   /*************************************LCD data out***************************************************/
   GPIO_SetupPinMux(12, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(12, GPIO_OUTPUT, GPIO_PUSHPULL);                    //D0

   GPIO_SetupPinMux(13, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(13, GPIO_OUTPUT, GPIO_PUSHPULL);                    //D1

   GPIO_SetupPinMux(14, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(14, GPIO_OUTPUT, GPIO_PUSHPULL);                    //D2

   GPIO_SetupPinMux(15, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(15, GPIO_OUTPUT, GPIO_PUSHPULL);                    //D3

   GPIO_SetupPinMux(16, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(16, GPIO_OUTPUT, GPIO_PUSHPULL);                    //D4

   GPIO_SetupPinMux(17, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(17, GPIO_OUTPUT, GPIO_PUSHPULL);                    //D5

   GPIO_SetupPinMux(20, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(20, GPIO_OUTPUT, GPIO_PUSHPULL);                    //D6

   GPIO_SetupPinMux(21,GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(21,GPIO_OUTPUT, GPIO_PUSHPULL);                    //D7

  /***************************************LCD Control lines**************************************************/

   GPIO_SetupPinMux(2, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(2, GPIO_OUTPUT, GPIO_PUSHPULL);        //cs1

   GPIO_SetupPinMux(3, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(3, GPIO_OUTPUT, GPIO_PUSHPULL);        //cs2

   GPIO_SetupPinMux(10, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(10, GPIO_OUTPUT, GPIO_PUSHPULL);        //E

   GPIO_SetupPinMux(11, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(11, GPIO_OUTPUT, GPIO_PUSHPULL);        //DI

   GPIO_SetupPinMux(18, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(18, GPIO_OUTPUT, GPIO_PUSHPULL);        //RW

   GPIO_SetupPinMux(19, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(19, GPIO_OUTPUT, GPIO_PUSHPULL);        //RESET

   /*********************************************************************************************************/

   return;
 }

 void soft_spi_data(unsigned char data)
 {
    unsigned char i, maskdata = 0x80;

    us(5);
    for(i= 0;i<8;i++)
    {
        scl_l;
        us(20);
        if(data & maskdata)
        {
            sda_h;
        }
        else
        {
            sda_l;
        }
        maskdata >>= 1;
        us(20);
        scl_h;
        us(20);
    }
    us(5);

  return;
 }


 void soft_spi_init(void)
 {
   GPIO_SetupPinMux(58, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(58, GPIO_OUTPUT, GPIO_PUSHPULL);        //cs1

   GPIO_SetupPinMux(60, GPIO_MUX_CPU1, 0);
   GPIO_SetupPinOptions(60, GPIO_OUTPUT, GPIO_PUSHPULL);        //cs2

   return;
 }

  • Sam,

    We are happy to clarify the behavior of any bit/register/features of the SPI module. All peripherals have examples in Controlsuite. You may want to compare your code with the examples to see where the problem might lie. Please continue to debug your code and use the forum to ask specific questions.

    Thanks,

    Vince Rodriguez
  • Hi Sam,

    Some debug strategies that might be helpful here:

    -Are the SPI registers getting initialized as intended?  After running whatever SPI initialization code you have, set a breakpoint and examine the SPI registers in the expressions window.  Are the registers configured as intended?  (You will also obviously want to refer to the technical documentation + TI examples to see if you are writing the right thing to begin with)

    -Are the SPI signals making it to the pins?  Here you might want to use an oscilloscope or logic analyzer to see if there is SPI bus traffic when you send a command over SPI.  If not, you may want to check the GPIO mux settings.  You can also switch the GPIO mux to GPIO and then manually toggle the GPIO data in the expressions window to sanity check that you have the correct pins.

    -Are the commands correct? Once you are getting SPI bus traffic, you can use the scope/logic analyzer to capture a single SPI message.  You can try and look at the first couple messages to check things like phase, polarity, timing, and bit order.  If everything looks good electrically, then you may want to verify that the correct messages are being sent (e.g. power up should be the first message, and should be data = XXX)