Configuration of GPIO, USART, DMA and SPI peripherals to transmit bytes between a USART and an SPI (in slave mode) in Interrupt mode. This example is based on the STM32C0xx USART LL API (the SPI uses the DMA to receive/transmit characters sent from/received by the USART). The peripheral initialization uses LL unitary service functions for optimization purposes (performance and size).
This example works with only one NUCLEO-C031C6.
USART1 Peripheral is acts as Master using IT. SPI1 Peripheral is configured in Slave mode using DMA. GPIO associated to User push-button is linked with EXTI.
Example execution:
LED4 is blinking Fast (200ms) and wait User push-button action. Press User push-button on BOARD start a Full-Duplex communication from USART using IT. On USART1 side, Clock will be generated on SCK line, Transmission done on TX, reception on RX. On SPI1 side, reception is done through the MOSI Line, transmission on MISO line.
At end of transmission, both received buffers are compared to expected ones.
In case of both transfers successfully completed, LED4 is turned on.
In case of errors, LED4 is blinking Slowly (1s).
Connectivity, UART/USART, Synchronous, Interrupt, SPI interface, Receiver, Transmitter, full-duplex
This example runs on STM32C031C6Tx devices.
This example has been tested with NUCLEO-C031C6 board and can be easily tailored to any other supported device and development board.
NUCLEO-C031C6 Set-up :
Board connector:
In order to make the program work, you must do the following :