2024-11-06 03:08 PM
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
2024-11-11 05:26 PM
Hi,
I assume you have created a project using CubeMX using the desired MCU?
Fundamentally, you setup the static portion of your design with CubeMX. It will create and install the necessary initialisation code (per your configuration in CubeMX) into main.c.
Have you been able to setup the COMP with the desired input/ output connections?
Kind regards
Pedro
2024-11-11 08:07 PM
Interesting question.
I have a demo board with the STM32F466 on it and it does not have a COMP on it. So, not yet. I have a protype board that was misconfigured with a STM32F3030 that doesn't have two SPI on it. Trying cobble together the USARTs on it instead for concept.