cancel
Showing results for 
Search instead for 
Did you mean: 

detect BSPI transmission completion

fabian239955_stm1
Associate II
Posted on June 26, 2006 at 14:04

detect BSPI transmission completion

3 REPLIES 3
fabian239955_stm1
Associate II
Posted on June 22, 2006 at 12:56

hi everybody

I'm controlling a display over BSPI with the STR7 evaluation board from hitex.

Mostly everything works perfect except the thing that I can't detect when the BPSI transmission is completed.

I'm only sending one byte at a time and afterwards I have to wait until the transmission is completed because i have to reset the enable (chip select) line at the end of the transmission.

First I used the BSPI_TFE (TransmitFIFOEmpty) flag but then I realized that it's set immediately after the data byte is transmittet to the shift register and not at the time when the shift register has shifted out the byte.

Afterwards I read that the BSPI_TUFL (TransmitFIFOUnderflow) flag could do the job. It's set after the transmission is completed but there's nothing new in the transmit register, that's right, isn't it? - i think it's not else it would work :-?

the TUFL flag will never be set...thus the CPU hangs in an endless loop

What am I doing wrong?

Thanks for your help in advance!

Regards,

Fab

PS: the code is attached below...

A command byte is sent as follows:

Code:

/**

* Send byte as a command to the display

**/

void PictivaOLED_Display_SendCommandByte(uint8_t cCommand) {

FlagStatus bTransmissionCompleted;

GPIO_BitWrite(GPIO0, PICTIVA_OLED_DISPLAY_ENABLE_PIN, 0); //Enable display

GPIO_BitWrite(GPIO0, PICTIVA_OLED_DISPLAY_DC_PIN, 0); //We're sending a command

BSPI_WordSend (BSPI0, cCommand);

do {

bTransmissionCompleted = BSPI_FlagStatus (BSPI0, BSPI_TUFL);

} while (!bTransmissionCompleted);

GPIO_BitWrite(GPIO0, PICTIVA_OLED_DISPLAY_ENABLE_PIN, 1); //Disable display

}

The BSPI is initialized as follows:

Code:

//Init SPI

GPIO_Config(GPIO0, 0x01<<PICTIVA_OLED_DISPLAY_SCLK_PIN, GPIO_AF_PP);

GPIO_Config(GPIO0, 0x01<<PICTIVA_OLED_DISPLAY_SOUT_PIN, GPIO_AF_PP);

GPIO_Config(GPIO0, 0x01<<0, GPIO_AF_PP);

GPIO_Config(GPIO0, 0x01<<3, GPIO_AF_PP);

BSPI_BSPI0Conf (ENABLE);

BSPI_Init (BSPI0);

BSPI_ClockDividerConfig(BSPI0, 40);

BSPI_Enable (BSPI0, ENABLE);

BSPI_MasterEnable (BSPI0, ENABLE);

BSPI_8bLEn(BSPI0, ENABLE);

BSPI_ClkActiveHigh (BSPI0, ENABLE);

BSPI_ClkFEdge (BSPI0, ENABLE);

BSPI_TrFifoDepth(BSPI0,1);

BSPI_FifoDisable(BSPI0);

ben2
Associate II
Posted on June 23, 2006 at 05:09

hi,

I also used the spi to talk to a serial LCD controller.

The way I ended up doing it is to use the RFNE bit to check for a completed transmit e.g

u16 cmd16;

/* empty rx fifo */

while( (BSPI0->CSR2 & 0x0008)!=0) {

cmd16 = BSPI0->RXR;

}

/* start write command cycle */

LCD_A1_LOW;

LCD_nLCD_CS_LOW;

/* load shift register with data */

cmd16 = cmd;

cmd16 <<= 8;

BSPI0->TXR = cmd16;

while ((BSPI0->CSR2 & 0x0008)==0) { /* Wait until the end of transmission */

asm(''nop'');

}

cmd16 = BSPI0->RXR; /* Read the received data */

/* end write command cycle */

LCD_nLCD_CS_HIGH;

fabian239955_stm1
Associate II
Posted on June 26, 2006 at 14:04

hi

thanks a lot, that solved my problem. now the controller proper detects BSPI transmission completion!

thanks again!

best regards,

fab