6 years, 6 months ago.

LPUART on L031K6

How can I use the LPUART1 on the L031K6 board?

Thank you very much.

Regards,

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32L031K6T6 microcontroller.

1 Answer

6 years, 6 months ago.

Hi,

For the moment you have to edit the "targets/TARGET_STM/TARGET_STM32L0/TARGET_NUCLEO_L031K6/PeripheralPins.c" file (import mbed-dev or use mbed CLI) and change the pins in the different UART structures:

const PinMap PinMap_UART_TX[] = {
// {PA_2,  UART_2,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART2)}, // PREVIOUS using UART_2
    {PA_9,  UART_2,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART2)},
    {PA_14, UART_2,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART2)}, // Warning: this pin is used by SWCLK
    {PB_6,  UART_2,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)},
    {PA_2,  LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, // NEW using LPUART_1
//  {PA_14, LPUART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)},
    {NC,    NC,       0}
};

Accepted Answer

It works and thank you very much.

However, I got another problem:

How can I use multiple tickers with different priorities. For example, I would like the Ticker1 has higher priority than Ticker2.

For the L031K6 board, the mbed library uses the TIMER21 for the ticker event (for class Ticker and Timer). As a result, Ticker1...TickerN have the same priority.

I am wondering that is it possible to have a Ticker using other general purpose timer, say the TIMER1 on the MCU?

Thank you very much in advance.

posted by Tony YI 09 Oct 2017

After some diggings.

It looks like the TIM22 and TIM2 on the MCU are already used by the PWM outputs.

posted by Tony YI 09 Oct 2017