STM32 USART register

Post here first, or if you can't find a relevant section!
Post Reply
Supervisor
Posts: 1
Joined: Wed Nov 01, 2023 11:10 am

STM32 USART register

Post by Supervisor »

I'm trying to use a library written for Atmel chip.

Code: Select all

commandStartNewFrame(UART_PIXEL_FORMAT_RGB565);
  for (uint16_t j=0; j<lineCount; j++) {
    for (uint16_t i=0; i<lineLength; i++) {
      waitForPreviousUartByteToBeSent();
      UDR0 = formatRgbPixelByteH(colorH);
      waitForPreviousUartByteToBeSent();
      UDR0 = formatRgbPixelByteL(colorL);
    }
  }
}
When I try to build it on platformio, it says UDR0 was not declared. I'm using STM32L432KC board. I want to port that code for STM32.
dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: STM32 USART register

Post by dannyf »

the easiest way to port a piece of code is to understand its functionality first and then replicate that functionality on your target chip. the code here seems to be about transmitting over uart: it waits for the uart to be available, and then send something over.

so you need two functions:
1. detect if uart is available - either tx buffer not full, or uart not in transmission.
2. load up data into the transmission buffer - the uart has a data register (at a minimum), or a transmission data register (sometimes).

both are fairly easy to do.
Post Reply

Return to “General discussion”