STM32F103 - EXT triggering SPI read
Posted: Mon Feb 13, 2017 11:47 pm
HI Guys,
I'm after a little guidance (or maybe a lot) I currently have an STM32F103VET interfacing to a AD7767 24bit ADC, so the current code that works by itself it uses the ext driver to trigger and interrupt on the falling edge of the DRDY pin (from the ADC). From the interrupt I can call a spiStartReceive (which I'm pretty sure Im not meant to do). Then have the SPI callback that casts the 24bit signed number into a 32bit signed and store is in a simple ring buffer (implemented my own as I didn't want any blocking). I then filter this in a normal thread.
This is works stand alone, but when I add the other parts of the project together which is are, GPT interrupt (2kHz at the moment), Timer capture event, a serial port (for GPS) and the USB serial output it all falls over.
Now I know this is because the callback is not finishing in time for the next interrupt Ive tired making as small as possible but not having much luck. All the other interput sources can wait a little the only other critical one is the time capture but as that is hardware I just need to get to it before the next event (every send it a GPS PPS).
Oh the AD7767 is outputting at 32kHz and I am using a digital isolator chip that has max through put of about 1Mhz so I cant just raise the SPI clock to get more time.
So back to the question, what is the best way to trigger the SPI from the ext interrupt. I need it to be quick without blocking cpu resources. Ive considered waking a thread from the interrupt and using a synchronous SPI, but not sure if that will respond quick enough, I really need this to take precedent over all other threads.
Thanks
Simon
I'm after a little guidance (or maybe a lot) I currently have an STM32F103VET interfacing to a AD7767 24bit ADC, so the current code that works by itself it uses the ext driver to trigger and interrupt on the falling edge of the DRDY pin (from the ADC). From the interrupt I can call a spiStartReceive (which I'm pretty sure Im not meant to do). Then have the SPI callback that casts the 24bit signed number into a 32bit signed and store is in a simple ring buffer (implemented my own as I didn't want any blocking). I then filter this in a normal thread.
This is works stand alone, but when I add the other parts of the project together which is are, GPT interrupt (2kHz at the moment), Timer capture event, a serial port (for GPS) and the USB serial output it all falls over.
Now I know this is because the callback is not finishing in time for the next interrupt Ive tired making as small as possible but not having much luck. All the other interput sources can wait a little the only other critical one is the time capture but as that is hardware I just need to get to it before the next event (every send it a GPS PPS).
Oh the AD7767 is outputting at 32kHz and I am using a digital isolator chip that has max through put of about 1Mhz so I cant just raise the SPI clock to get more time.
So back to the question, what is the best way to trigger the SPI from the ext interrupt. I need it to be quick without blocking cpu resources. Ive considered waking a thread from the interrupt and using a synchronous SPI, but not sure if that will respond quick enough, I really need this to take precedent over all other threads.
Thanks
Simon