AnsweredAssumed Answered

SPI timing

Question asked by ebommer on Aug 14, 2014
Latest reply on Aug 15, 2014 by Jack Peacock

I am writing an SPI interface where after 4 messages are sent I toggle a pin.  My issue is my pin is toggling before the transmission is complete(I can see my pin go high after the 3rd message).  I am monitoring the bsy and the tx flags but not getting the results I was expecting.  Any help is appreciated.  I am using an STM32F103.

LCD_Write_Command(0x60 | tmp);
LCD_Write_Command(0x70 | tmp);
LCD_Write_Command(0x00 | tmp);
LCD_Write_Command(0x10 | tmp);

GPIO_WriteBit(GPIOB,LCD_CD,Bit_SET);
   
    
void LCD_Write_Command(unsigned char dat){
    while ((SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == 1));
    
    SPI_I2S_SendData(SPI1, dat);
    
    while ((SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == 0));
}

Outcomes