cancel
Showing results for 
Search instead for 
Did you mean: 

Dac -> COMP -> Timer -> DMA -> dual SPI_TX

pixeltamer
Visitor

I've been programming microprocessors for over 40 years and the STM32F301K8 has me stumped.
I'm required to use it in a low budget project with some unusual characteristics.

I need a working example of:
Using STM32CubeIDE and the target STM32F301K8 or STM32F302K8. I have the NUCLEO-F446RE development board to work with and it has the appropriate capabilities for testing. (Pin references below are for the stm32F301)
1) A preset DAC output level is linked to a comparator (minus input PA4), with an external analog input signal to same comparator (positive input PA7).
2) When the comparator output transitions to negative output, a pair of SPIs are to be triggered. The two SPIs (Tx only), each using a DMA output in synchronous parallel. The contents of the buffers act as a 2-bit wide nonblocking & uninterrupted data stream. An interrupt is needed when sending is complete.
3) The SPIs will run at 4MBs, 8-Bit, msb first, no delay between bytes, outputs (PB5 & PA11).
4) A small programmable delay will most likely be needed between when the comparator trips and the SPIs start. Something like a very fast one-shot or PWM (less than 4us).
5) Basically, this routine is independent of the code processor as the output is synced to an external input and must remain synchronous until the buffers are empty.
The code part of the microprocessor will be used to set the DAC level, the delay, and determine what data to put into the contents of the two SPI buffers.

Configuring the individual modules seems to be relatively obvious to me using HAL directives, however tying them together is baffling.
Virtually every USART and SPI example I have found and tried transmits data only once in the DMA modes.

A code snippet showing how it is all tied together would be greatly appreciated.
Can anyone help?

Pixeltamer

0 REPLIES 0