2014-04-04 07:43 AM
Hi all,
I
would like to know
if anyone has a problem when
enabling the Tx buffer empty interrupt. In fact, when i put SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, ENABLE); , the code coming after can't be executed switch (USBButton) { /* BUTTON_USER button pressed */ case 0x01: SendMode=0x01; ReceveMode=0x00; CmdTransmitted = 0x01; break; . . . } if (CmdTransmitted != 0x00) { /* Enable the Tx buffer empty interrupt */ SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, ENABLE); /* Transmission mode */ if(SendMode==0x01) { STM_EVAL_LEDOn(LED7); while(CmdStatus==0x00); while(Tx_Idx < DATA_SIZE); /* Waiting until TX FIFO is empty */ while (SPI_GetTransmissionFIFOStatus(SPI1) != SPI_TransmissionFIFOStatus_Empty) {} /* Wait busy flag */ while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET) {} } /*------SPI handler --------*/ void SPI1_IRQHandler(void) { /* SPI in Master Tramitter mode--------------------------------------- */ if (SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_TXE) == SET) { if (CmdStatus == 0x00) { SPI_SendData8(SPI1, CmdTransmitted); CmdStatus = 0x01; Tx_Idx=0x00; STM_EVAL_LEDOn(LED5); } else { if(SendMode) { SPI_SendData8(SPI1, CommandRegister_Tx[Tx_Idx++]); STM_EVAL_LEDOn(LED3); if (Tx_Idx == 4) { STM_EVAL_LEDOn(LED10); /* Disable the Tx buffer empty interrupt */ SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, DISABLE); } } } } This code is for the master. In the slave side, i can receive what the master sends but it doesn't enter to if(SendMode==0x01). Any suggestion. I hope that it's clear enough to understand the issue.2014-04-04 08:35 AM
It seems that when i enable TX SPI interrupt, the program doesn't exit from the SPI handler
2014-04-09 08:04 AM
Could you tell please what would be the issue if you have an idea ?
I can't fix this problem.2014-04-09 08:13 AM
There is no initialization of CmdStatus, little wonder that your ISR is running endlessly.
2014-04-09 09:22 AM
Thanks Laurent for you replay.
No, i have initialized it in the beginning before the switch (USBButton) CmdTransmitted = 0x00; CmdStatus = 0x00; Tx_Idx = 0x00; Rx_Idx = 0x00;2014-04-09 10:55 AM
Tell us a bit more about LED, how they behave ...
Did you enable another SPI interrupt, somewhere else ?2014-04-16 08:57 AM
2014-06-18 01:23 AM
Hi,Franck
Can you please tell us how have you solved the problem ? Thank You