2024-11-14 10:30 AM - last edited on 2024-11-14 11:06 AM by SofLit
Previous post: https://community.st.com/t5/stm32-mcus-embedded-software/dma-on-stm32l011f4/td-p/742092
I am working with code on the STM32L011 that uses DMA to read data from USART2. I received excellent help on this forum before and I'm hoping for the same now.
I'm using a custom PCB and several colored LEDs for debugging.
I expect the code to echo data it receives from the USART2 but it does not. And neither LED is turned on. It seems that the DMA IRQ handler is not being called. I believe I'm missing something simple again.
-A
2024-11-19 12:53 AM - edited 2024-11-19 12:54 AM
FE status bit is suspicious, and also the RDR content - have you transmitted 0x00 to Rx pin?
Without writing any more code, try to
- stop program execution
- disable DMA by writing to its control register
- transmit one byte to the UART_Rx pin
- observe the UART registers - RXNE should be set (don't use "live registers view" or similar in IDE, which would repeatedly read the registers, as reading UART_RDR clears RXNE)
- stop observing the UART registers
- enable DMA
- transmit one byte to the UART_Rx pin
- look at the DMA registers, there should be a decrement in NDTR and the received byte should appear in the memory buffer
JW
2024-11-27 01:07 PM
A simple solution and an embarrassing oversight.
I finally noticed that I was setting pin A0 (USART2 RX) to AF4 rather than AF0. My code now works correctly.
Thank you for your suggests.
-A