Skip to main content
Explorer
April 17, 2024
Question

Trying to adapt stm32f4 for stm32l452RE

  • April 17, 2024
  • 1 reply
  • 802 views

Hi all,

I'm truying to adapt one file coming fromm stm32f4 discovery board for using UART. But when I try to add it to my STM NUCLEO L452RE board I got an error :

 

 

 

 

../Drivers/BSP/uart.c:328:63: error: 'USART_TypeDef' has no member named 'DR'; did you mean 'RDR'?
 328 | data = (uint8_t) ((uint16_t) (s_uart1Handle.Instance->DR & (uint16_t) 0x01FF) & (uint16_t) 0x00FF);
 | ^~
 | RDR

 

 

 

  

Here is the function :

 

 

 

 

void USART1_IRQHandler(void)
{
 uint8_t data;
 uint16_t usedCapacityOfBuffer = 0;
 uint16_t realCountPutBuffer = 0;

 if (__HAL_UART_GET_IT_SOURCE(&s_uart1Handle, UART_IT_RXNE) != RESET &&
 __HAL_UART_GET_FLAG(&s_uart1Handle, UART_FLAG_RXNE) != RESET) {
 data = (uint8_t) ((uint16_t) (s_uart1Handle.Instance->DR & (uint16_t) 0x01FF) & (uint16_t) 0x00FF);
 realCountPutBuffer = RingBuf_Put(&s_uart1ReadRingBuffer, &data, 1);
 usedCapacityOfBuffer = UART1_READ_BUF_SIZE - RingBuf_GetUnusedSize(&s_uart1ReadRingBuffer);
 s_uart1ReadBufferState.maxUsedCapacityOfBuffer =
 usedCapacityOfBuffer > s_uart1ReadBufferState.maxUsedCapacityOfBuffer ? usedCapacityOfBuffer
 : s_uart1ReadBufferState.maxUsedCapacityOfBuffer;
 s_uart1ReadBufferState.countOfLostData += 1 - realCountPutBuffer;
 }

 if (__HAL_UART_GET_IT_SOURCE(&s_uart1Handle, UART_IT_TXE) != RESET &&
 __HAL_UART_GET_FLAG(&s_uart1Handle, UART_FLAG_TXE) != RESET) {
 if (RingBuf_Get(&s_uart1WriteRingBuffer, &data, 1)) {
 /* Transmit Data */
 s_uart1Handle.Instance->DR = ((uint16_t) data & (uint16_t) 0x01FF);
 } else {
 __HAL_UART_DISABLE_IT(&s_uart1Handle, UART_IT_TXE);
 }
 }
}

 

 

 

 

Do you think I can change DR by RDR? What is the difference, I've lookin for but I don't find good explaination...

Should I used TDR for transmit and RDR for receive maybe ?

Thanks

    This topic has been closed for replies.

    1 reply

    Super User
    April 17, 2024

    @SBaro.11 wrote:

    Do you think I can change DR by RDR? What is the difference,


    Look at the two different definitions of the USART_TypeDef structure for the two different processors (L4 and F4).

    Also look at the register definitions (in the Reference Manuals) for the two processors (L4 and F4).

    That should tell you if they're compatible ...