2018-08-23 01:20 PM
Can someone please write me a few lines to enable my code to receive an interrupt as a byte is coming?
For the life of me I cannot find any code examples. All I can find is application notes that go on and on about the capabilities of the STMicro SPI. Some code examples show implementations that are too advanced for my below average brain.
All I need is for the SPI to fire an interrupt as a byte is coming. That's all. My code polls Okay, but I need interrupts. I wrote the interrupt code before but that wasn't using HAL, which seems to have changed everything.
I did go through the HAL source code without understanding much.
Thanks.
I am using:
STM32L4RVITx
IAR Embedded Workbench for ARM 8.30.1.17148
2018-08-23 03:23 PM
From polling RXNE to interrupt should be:
and a bonus hint, don't forget to check OVF flag and clear it if as that causes an interrupt too when RXNEIE is set, not only the RXNE flag.
2018-08-23 03:59 PM
You're not compelled to use HAL/Cube
The mechanics of the old SPL and register level interaction are still reasonably viable
STM32Cube_FW_L4_V1.12.0\Projects\NUCLEO-L4R5ZI\Examples\SPI\SPI_FullDuplex_ComIT
Will note that doing SPI via interrupts seems a bit of a circus, if you can blast blocks of data look at using DMA
2018-08-29 12:56 PM
Thank you very much for your help.
I will be sure to post code once I get back to this and use your valuable input.
Regards.
2018-09-11 06:25 AM
The problem is, and has been all along, with pausing the code.
After I pause the code SPI port closes and nothing is read afterwards either in polling or in interrupt modes.
Let's say SPI works fine, and I can send discrete commands from a C# master and receive responses from my SPI driver with no problem.
Then I place a breakpoint:
After I resume execution no more data will be read by SPI.
This happens even after I create a fresh project from CubeMX with SPI as the only peripheral.
The custom board I am using was functioning fine with an STM32F072 installed. Then we replaced that processor with an STM32L4R7, leaving everything else intact.
I am lost!!!
2018-09-11 07:11 AM
> After I pause the code SPI port closes
What? You mean SPIx_CR1.SPE=0?
AFAIK there's no inherent timeout in the SPI module, so such behaviour is most probably imposed by the "libraries" used.
JW
2018-09-11 09:20 AM
I should have said, "it appears as if it were closed".
In fact SPIx_CR1.SPE is still a one.
Sorry for the misinformation!
It's the behavior that resembles like a closed port. It won't detect or receive any more bytes.
Thanks