AnsweredAssumed Answered

LCD UC1608 SPI S8

Question asked by l.bartosz on Nov 2, 2012
Latest reply on Oct 26, 2014 by ramsamy.angelique
I have a problem with the initialization of the display AGG240128A05-FHW-R
I do not know what could be wrong. Maybe someone has an idea?
code:
                                   
 #include "GLCD_240x128.h"
            #include "STM32F10x.h"
             
             
            /*
              GPIO_SetBits(DrivePort_B, BM1);     //DelayLCD(0xFF);
              GPIO_SetBits(DrivePort_B, BM0);     //DelayLCD(0xFF);
            */
            //----------------------------------------------------------------------------------------------------------
            void GLCD_Init(void){
             
                //Display initialisaton
              volatile unsigned long int i;
             
              GPIO_ResetBits(DrivePort_B, RES);    //RES=0
              GLCD_delay(100);
              GPIO_SetBits(DrivePort_B, RES);        //RES=1
                GLCD_delay(100);
              //CD=0 wysylanie komend
                GPIO_ResetBits(DrivePort_B, CS);
                GPIO_ResetBits(DrivePort_B, CD);
             
                // SET MR TC
                GLCD_SPI_Transmit(0x26);
             
                // set LCD mapping
                GLCD_SPI_Transmit(0x3d);
             
                // set bias ratio
                GLCD_SPI_Transmit(0xec);
             
                // set gain & potentiometer I bajt
                GLCD_SPI_Transmit(0x81);
             
                // set gain & potentiometer II bajt
                GLCD_SPI_Transmit(0x72);    
             
              // start line number
              GLCD_SPI_Transmit(0x40);         
             
                // display enable
              GLCD_SPI_Transmit(0xaf);         
             
                // all pixels ON - aby zobaczyc reakcje
              GLCD_SPI_Transmit(0xa5);
              /*
              GLCD_SPI_Transmit(0XE2);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0XEb);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0X24);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0X2E);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0XC4);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0X89);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0X81);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0X20);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0X40);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0X30);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0X22);
                 //GLCD_delay(30);
              GLCD_SPI_Transmit(0XAF);
                 //GLCD_delay(30);
                GLCD_SPI_Transmit(0xa5);
               //GLCD_delay(30);    
                  */         
            }
            //----------------------------------------------------------------------------------------------------------
            void GLCD_SPI_Transmit(char cData) {  
             
                GPIO_SetBits(DrivePort_B, CS);  //CS=1 (ENABLE)
             
                /* Loop while DR register in not empty */
                while( SPI_I2S_GetFlagStatus( GLCD_SPI, SPI_I2S_FLAG_TXE ) == RESET );
                /* Send byte through the SPIx peripheral */
                SPI_I2S_SendData( GLCD_SPI, cData );
              /* Zgodnie z karta katalogowa najpierw trzeba sprawdzic czy bufor nadawczy */
              /* jest pusty a dopiero potem sprawdzac czy SPI skonczylo nadawanie */
              /* Loop while DR register in not empty */
                while( SPI_I2S_GetFlagStatus( GLCD_SPI, SPI_I2S_FLAG_TXE ) == RESET );
              /* Loop while SPI is not busy */
                while( SPI_I2S_GetFlagStatus( GLCD_SPI, SPI_I2S_FLAG_BSY ) == SET );
             
              GPIO_ResetBits(DrivePort_B, CS);        //CS=0 (DISABLE)
             
            }
            //----------------------------------------------------------------------------------------------------------
            void GLCD_HwConfiguration(void)
            {
                GPIO_InitTypeDef  GPIO_InitStructure; //Konfiguracja GPIO
              SPI_InitTypeDef   SPI_InitStructure;//Konfiguracja interfejsu SPI
             
              //Enable clocks
              //RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);           //GPIO A Clock
              //RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);            //SPI Clock
             
              //GPIO config
              GPIO_InitStructure.GPIO_Pin = CLK | DIN ;    //SPI: SCK, MISO
              GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
              GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
              GPIO_Init(DrivePort_A, &GPIO_InitStructure);
             
              GPIO_InitStructure.GPIO_Pin = CS | CD | RES; //SPI: CS, CD, RES
              GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
                GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
              GPIO_Init(DrivePort_B, &GPIO_InitStructure);
             
              //SPI1 Configuration
              SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;//transmisja jednokierunkowa do MCU
              SPI_InitStructure.SPI_Mode = SPI_Mode_Master;//Tryb pracy SPI, mikrokontroler jako slave
              SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;//8-bit ramka danych
              SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;//Stan Sygnalu taktujacego przy braku transmisji
              SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;//Aktywne zbocze sygnalu taktujacego
              SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;//Sprzetowa obsluga lini NSS(CS)
              SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;//Prescaler, Szybkosc transmisji
              SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;//Pierwszy bit w danych najbardziej znaczacy albo LSB
            //  SPI_InitStructure.SPI_CRCPolynomial = 7;//Konfiguracja wielomianu do obliczenia CRC
                SPI_Init(GLCD_SPI, &SPI_InitStructure);//Inicjalizacja SPI
             
              SPI_Cmd(GLCD_SPI, ENABLE);                                         //SPI1 Enable                                             
            }
            //----------------------------------------------------------------------------------------------------------
            void GLCD_delay(unsigned int t)
            {
            unsigned int i,j;
            for(i=0;i<t;i++)
              for(j=0;j<104;j++);
            }
            //----------------------------------------------------------------------------------------------------------
logic analyzer:


Outcomes