STM32L152RE UART driver problem
Posted: Fri May 13, 2016 12:29 pm
Hello, I'm trying out ChibiOS (the latest revision from GitHub), I need to use all the available USART and UART ports of my Nucleo borad with STM32L152RE and it seems I need a little help. The microcontroller has 3 USARTS and 2 UARTS, I want USART2 as serial (for debugging) and the other 4 as U(S)ARTS:
[nfo]/*
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 FALSE
#define STM32_SERIAL_USE_USART2 TRUE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USART1_PRIORITY 12
#define STM32_SERIAL_USART2_PRIORITY 12
#define STM32_SERIAL_USART3_PRIORITY 12
// ...
/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 TRUE
#define STM32_UART_USE_USART2 FALSE
#define STM32_UART_USE_USART3 TRUE
#define STM32_UART_USE_UART4 TRUE
#define STM32_UART_USE_UART5 TRUE
#define STM32_UART_USART1_IRQ_PRIORITY 10
#define STM32_UART_USART2_IRQ_PRIORITY 12
#define STM32_UART_USART3_IRQ_PRIORITY 11
#define STM32_UART_UART4_IRQ_PRIORITY 12
#define STM32_UART_UART5_IRQ_PRIORITY 12
#define STM32_UART_USART1_DMA_PRIORITY 0
#define STM32_UART_USART2_DMA_PRIORITY 0
#define STM32_UART_USART3_DMA_PRIORITY 0
#define STM32_UART_UART4_DMA_PRIORITY 0
#define STM32_UART_UART5_DMA_PRIORITY 0
#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")[/nfo]
First of all, for some reason the STM32L1 port still uses the older USAR1 library instead of USART2 (is there a good reason for this), and second of all, I am getting compilation errors:
[nfo]../chibios/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.h:230:2: error: #error "UART4 DMA access not supported in this platform"
#error "UART4 DMA access not supported in this platform"
^
../chibios/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.h:240:2: error: #error "UART5 DMA access not supported in this platform"
#error "UART5 DMA access not supported in this platform"[/nfo]
I'm positive that the microcontroller supports DMA access for both UART4 and UART5, the correct values are even defined in stm32_registry.h of the STM32L1xx port:
[nfo]#if (STM32L1XX_PROD_CAT == 1) || (STM32L1XX_PROD_CAT == 2) || \
(STM32L1XX_PROD_CAT == 3) || defined(__DOXYGEN__)
#define STM32_HAS_UART4 FALSE
#define STM32_HAS_UART5 FALSE
#else
#define STM32_HAS_UART4 TRUE
#define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
#define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
#define STM32_HAS_UART5 TRUE
#define STM32_UART_UART5_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
#define STM32_UART_UART5_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
#endif[/nfo]
In my case the STM32L1XX_PROD_CAT is 5, so I have both UART4 and UART5.
Can anybody help me with this, please? Thank you.
[nfo]/*
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 FALSE
#define STM32_SERIAL_USE_USART2 TRUE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USART1_PRIORITY 12
#define STM32_SERIAL_USART2_PRIORITY 12
#define STM32_SERIAL_USART3_PRIORITY 12
// ...
/*
* UART driver system settings.
*/
#define STM32_UART_USE_USART1 TRUE
#define STM32_UART_USE_USART2 FALSE
#define STM32_UART_USE_USART3 TRUE
#define STM32_UART_USE_UART4 TRUE
#define STM32_UART_USE_UART5 TRUE
#define STM32_UART_USART1_IRQ_PRIORITY 10
#define STM32_UART_USART2_IRQ_PRIORITY 12
#define STM32_UART_USART3_IRQ_PRIORITY 11
#define STM32_UART_UART4_IRQ_PRIORITY 12
#define STM32_UART_UART5_IRQ_PRIORITY 12
#define STM32_UART_USART1_DMA_PRIORITY 0
#define STM32_UART_USART2_DMA_PRIORITY 0
#define STM32_UART_USART3_DMA_PRIORITY 0
#define STM32_UART_UART4_DMA_PRIORITY 0
#define STM32_UART_UART5_DMA_PRIORITY 0
#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")[/nfo]
First of all, for some reason the STM32L1 port still uses the older USAR1 library instead of USART2 (is there a good reason for this), and second of all, I am getting compilation errors:
[nfo]../chibios/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.h:230:2: error: #error "UART4 DMA access not supported in this platform"
#error "UART4 DMA access not supported in this platform"
^
../chibios/os/hal/ports/STM32/LLD/USARTv1/hal_uart_lld.h:240:2: error: #error "UART5 DMA access not supported in this platform"
#error "UART5 DMA access not supported in this platform"[/nfo]
I'm positive that the microcontroller supports DMA access for both UART4 and UART5, the correct values are even defined in stm32_registry.h of the STM32L1xx port:
[nfo]#if (STM32L1XX_PROD_CAT == 1) || (STM32L1XX_PROD_CAT == 2) || \
(STM32L1XX_PROD_CAT == 3) || defined(__DOXYGEN__)
#define STM32_HAS_UART4 FALSE
#define STM32_HAS_UART5 FALSE
#else
#define STM32_HAS_UART4 TRUE
#define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
#define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
#define STM32_HAS_UART5 TRUE
#define STM32_UART_UART5_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
#define STM32_UART_UART5_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
#endif[/nfo]
In my case the STM32L1XX_PROD_CAT is 5, so I have both UART4 and UART5.
Can anybody help me with this, please? Thank you.