AnsweredAssumed Answered

NOKIA LCD_6610 wrong STM32F107

Question asked by Zoubi on Aug 21, 2015
hi ,
i use STM32F107 to comunicate with LCD NOKIA 6610 though UEXT but i have problem.  

i set up the configuration SPI using the scope, i see waves form MOSI data sent by microcontroller to NOKIA 6610.

this is my SPI configuration

/***************************************************************************//**
 *@brief
 ******************************************************************************/
void LCD_SPI3_RCC_Configuration(void)
{
    /*SPI3 clocks enable */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);

    /* GPIOB, GPIOC clocks enable */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOB, ENABLE);
}

/***************************************************************************//**
 @brief Configure GPIO settings
 ******************************************************************************/
void LCD_SPI3_GPIO_Configuration(void)
{
     /* Enable SPI3 Pins Software Remapping */
    GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);

    //* Configure SPI3 pins: SCK and MOSI-------------------------------*/
    SPI3_GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_10 |GPIO_Pin_12 ;
    SPI3_GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF_PP;
    SPI3_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOC, &SPI3_GPIO_InitStructure);

    /* Configure SPI3 pins:  Chip Select -------------------------------*/
    SPI3_GPIO_InitStructure.GPIO_Pin   =  GPIO_Pin_15;                                    /* PB15 - SPI chip select pin.*/
    SPI3_GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
    SPI3_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOB, &SPI3_GPIO_InitStructure);
}

void LCD_SPI3_NVIC_Configuration(void)
{
    NVIC_InitTypeDef NVIC_InitStructure;
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

    /* SPI3 IRQ Channel configuration */
    NVIC_InitStructure.NVIC_IRQChannel = SPI3_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
    NVIC_Init(&NVIC_InitStructure);
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    NVIC_SetPriorityGrouping(0);
}

void LCD_SPI3_Initialization(void)
{
    SPI_I2S_DeInit(SPI3);
    /* SPI3 Master configuration */
    SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx; // set to full duplex mode, seperate MOSI and MISO lines
    SPI_InitStructure.SPI_Mode = SPI_Mode_Master;             // configuration for Master mode
    SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;                // one packet of data is 8 bits wide
    SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;                    /*
    SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
    SPI_InitStructure.SPI_NSS  = SPI_NSS_Soft;
    SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8;             // SPI frequency is APB2 frequency / 4  ==>72Mhz/8= 9Mhz
    SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
    SPI_InitStructure.SPI_CRCPolynomial = 7;

    SPI_Init(SPI3, &SPI_InitStructure);

    /* Enable SPI3 */
    SPI_Cmd(SPI3, ENABLE);

}

void LCD_SPI3_IRQHandler(void){

      /* Check the interrupt source */
    if (SPI_I2S_GetITStatus(SPI3, SPI_I2S_IT_TXE) == SET)
    {
        /* Disable the I2S3 TXE interrupt to end the communication */
               SPI_I2S_ITConfig(SPI3, SPI_I2S_IT_TXE, DISABLE);

    }

    /* Check the interrupt source */
        if (SPI_I2S_GetITStatus(SPI3, SPI_I2S_IT_RXNE) == SET)
        {
            /* Disable the I2S3 TXE interrupt to end the communication */
                   SPI_I2S_ITConfig(SPI3, SPI_I2S_IT_RXNE, DISABLE);
        }
}


this is the LCD configuration


void LCD_PinInitBacklightReset(void)
{
    /* GPIOD and GPIOB clocks enable */
   
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOB, ENABLE);

    GPIO_InitStruct_GPIO.GPIO_Pin   = GPIO_Pin_8 | GPIO_Pin_9 ; // Pins 8 (Blacklight) and 9 (reset) are used
  
 GPIO_InitStruct_GPIO.GPIO_Mode  = GPIO_Mode_Out_PP            ;// the pins are configured as output
   
GPIO_InitStruct_GPIO.GPIO_Speed = GPIO_Speed_50MHz        ;// this defines the IO speed and has nothing to do with the baudrate!
  
 GPIO_Init(GPIOD, &GPIO_InitStruct_GPIO)                   ;// now all the values are passed to the GPIO_Init() function which sets the GPIO registers

    /* Configure GPIO pins:  Chip Select -------------------------------*/
    GPIO_InitStruct_GPIO.GPIO_Pin   =  GPIO_Pin_15; /* PB15 - select pin.*/
    GPIO_InitStruct_GPIO.GPIO_Mode  = GPIO_Mode_Out_PP;
    GPIO_InitStruct_GPIO.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOB, &GPIO_InitStruct_GPIO);
}
my problem is what i follow the tutorial,  nothing come out from LCD. 

this is the LCD TEST to allow me to write the Clear Screen on diplay

void LCD_Test (){
// Initialize SPI interface to LCD
        LCD_SPI3_Configuration();

        // Pin for backlight and reset
        LCD_PinInitBacklightReset();

        /*Pin PD9 used for LCD_BL (backlight) set to high*/
        LCD_Backlight(BKLGHT_LCD_ON);

        /*Pin PD8 used for LCD_RESET set to high */
        LCD_RESET(RST_LCD_ON);

        /*Pin PB15 used for CS_LCD (chip select) set to high*/
        LCD_ChipSelect(CS_LCD_ON);

        //LCD_Initialisation();
      LCD_Initialisation();

        // clear the screen
        LCD_ClearScreen();               //  nothing come out to Clear Screen

        }

void LCD_ClearScreen(void)
{
    long i; // loop counter


    /*Pin PB15 used for CS_LCD (chip select)*/
    //LCD_ChipSelect(CS_LCD_OFF);

    // Row address set (command 0x2B)
    LCD_WriteSpiCommand(PASET);
    LCD_WriteSpiData(0);
    LCD_WriteSpiData(131);

    // Column address set (command 0x2A)
    LCD_WriteSpiCommand(CASET);
    LCD_WriteSpiData(0);
    LCD_WriteSpiData(131);

    // set the display memory to BLACK
    LCD_WriteSpiCommand(RAMWR);

    for (i = 0; i < ((131 * 131) / 2); i++)
    {
        LCD_WriteSpiData((BLACK >> 4) & 0xFF);
        LCD_WriteSpiData(((BLACK & 0xF) << 4) | ((BLACK >> 8) & 0xF));
        LCD_WriteSpiData(BLACK & 0xFF);
    }


void LCD_WriteSpiCommand(volatile unsigned int command)
{
    // clear bit 8 - indicates a "command"
    command = (command & ~0x0100);

    /*chip select low to enable transmission*/
    LCD_ChipSelect(CS_LCD_OFF);

    /* Loop while DR register is not empty */
    while (SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE) == RESET);

    // send the command
    SPI_I2S_SendData(SPI3, command);

     /*chip select high to disable transmission*/
     LCD_ChipSelect(CS_LCD_ON);
}


void LCD_WriteSpiData(volatile unsigned int data)
{

    /*chip select low to disable transmission*/
    LCD_ChipSelect(CS_LCD_OFF);

    // wait for the transfer to complete
    while (SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE) == RESET);

    // set bit 8, indicates "data"
   data = (data | 0x0100);

    // send the data
    SPI_I2S_SendData(SPI3, data);

    /* Wait for SPI3 data reception */
    while (SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_RXNE) == RESET);
    Send_Rcv= SPI_I2S_ReceiveData(SPI3);

      /*chip select high to disable transmission*/
    LCD_ChipSelect(CS_LCD_ON);
}

Outcomes