cancel
Showing results for 
Search instead for 
Did you mean: 

LL and Registers to program STM32

LimoGr
Associate II

Hi! I am trying to configure a UART communication using the LL but I am not really understanding, registers seem easier to digest to me but I am not finding any tutorials or examples online. Can someone provide me with please? Thank you!

6 REPLIES 6

The registers are described in the Reference Manual (RM).

There are multiple instances of most peripherals.

The peripherals are mapped into the processors address space, you can read/write them using regular memory access methods.

You can use pointers and structures, or you can peek/poke the memory directly.

The HAL source code does register access internally, suggest you review that in the context of reading the RM

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
KnarfB
Principal III

LL is IMHO rarely used and close to register level. You can config STM32CubeMX/IDE to generate LL setup for the UART and study the code with the RM at hand.

Sending in a loop at register level with CMSIS defines may look like (depending on chip):

for(;;) {
    while( (USART1->ISR & USART_ISR_TXE) == 0 );
    USART1->TDR = '*';
  }

And receiving is similar with RXNE flag.

hth

KnarfB

>>LL is IMHO rarely used

Yes, a lot of resources seem to have been wasted. What I wanted was something relatively light-weight like the original SPL, not something massive with a forced and broken paradigm that HAL offers, and not something to abstract register access with little net benefit.

I can do register access directly and with less encumberment than LL, and probably spend less time coding and porting.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
KDJEM.1
ST Employee

Hello @LimoGr​ ,

To configure a UART communication using the LL, I advise you to get inspired from LL_USART examples.

I hope this help you!

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

> I am not finding any tutorials or examples online.

That's because ST refuses to work on register-based examples. Writing and maintaining examples is incredibly hard and expensive, so while you may find some e.g. in Snippets (which is roughly the same as the example at the end of 'F0 and 'L0 RMs), or for example I can come up with some random examples, I'm not sure how helpful such may be for your particular STM32 and your particular expectations.

Please upvote this request.

JW

ASELM
Associate II

Hi,

The LL drivers offer hardware services based on the available features of the STM32 peripherals. These services reflect exactly the hardware capabilities, and provide atomic operations that must be called by following the programming model described in the product line reference manual.

The Low-layer APIs (LL) are offering a fast light-weight expert-oriented layer which is closer to the hardware than the HAL. You can find a description of the low-layer drivers within the user manuals (STM32F4 user manual as example).

Regarding examples, there is unfortunately no UART LL examples. However, you may refer to the LL USART examples delivered in the STM32Cube packages (STM32G474 Nucleo board USART examples for instance).

It is also possible to generate the UART initialization using the STM32CubeMx tool. You can refer to this tutorial.

Best regards,