Thunderpack STM32L072xx

razvitm
Posts: 33
Joined: Sat Apr 11, 2020 12:35 pm

Re: Thunderpack STM32L072xx

Post by razvitm »

I'm happy to report that all 5 serial ports are working in Arduino on a STM32L072 on a breakout PCB without external oscillator or quarts using the Discovery LRWAN1 board with a small modification of one of the core's file. The question is if it can be done from the sketch rather than modifying one of the core files?
Later Edit: It works without modifying the core.
Just copy paste the modified code from the modified "PeripheralPins.c" above Setup() in arduino and it takes effect, it works without modifying the core.
//above setup
#ifdef HAL_UART_MODULE_ENABLED
WEAK const PinMap PinMap_UART_TX[] = {
{PA_0, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USART4)},
// {PA_2, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)},
// {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART2)},
{PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)},
//this one used originally and works {PA_14, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)},
{PA_14, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART2)},
// {PB_3, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USART5)}, // Not available on board
{PC_12, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USART5)},
{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)},
{PB_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_LPUART1)}, // Not available on board WORKS OK
// {PB_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_LPUART1)}, // Not available on board
// {PC_1, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, // LoRa dedicated pin
{NC, NP, 0}
};
#endif

#ifdef HAL_UART_MODULE_ENABLED
WEAK const PinMap PinMap_UART_RX[] = {
// {PA_1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USART4)}, // LoRa dedicated pin
// {PA_3, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)},
// {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART2)},
{PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)},
// this one original{PA_13, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)},
{PA_15, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART2)}, // Not available on board
// {PB_4, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USART5)}, // Not available on board
{PD_2, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USART5)},
{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)},
// {PB_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_LPUART1)}, // Not available on board
{PB_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_LPUART1)}, // Not available on board
// {PC_0, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, // Not available on board
{NC, NP, 0}
};
#endif
HardwareSerial SerialLP1(LPUART1);
HardwareSerial Serial(USART1);
HardwareSerial Serial2(USART2);
HardwareSerial Serial4(USART4);
HardwareSerial Serial5(USART5);
void setup(){
Serial.begin(9600);//serial and serial1 are the same port
SerialLP1.begin(9600);
Serial2.begin(9600);
Serial4.begin(9600);
Serial5.begin(9600);
}
void loop() {
Serial.println("this is port serial");
SerialLP1.println("this is port serialLP1");
Serial2.println("this is port serial2");
Serial4.println("this is port serial4");
Serial5.println("this is port serial5");
delay(500);
}
P.S. UART support enabled, no serial (selected in board menu)
Last edited by razvitm on Tue Sep 22, 2020 1:40 pm, edited 2 times in total.

User avatar
fpiSTM
Posts: 742
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 27
Location: Le Mans
Contact:

Re: Thunderpack STM32L072xx

Post by fpiSTM »

You have the answer. As you can see the PinMap array are weak so simply redefine it at sketch level.
Soon all Alternative pins will be available so no need to comment except to save space.

razvitm
Posts: 33
Joined: Sat Apr 11, 2020 12:35 pm

Re: Thunderpack STM32L072xx

Post by razvitm »

Why can I use all the serial ports with the Discovery L072 board but I can't get all the 5 serial ports to work on the PX-HER0 or the THUNDERPACK boards?
What am I missing? Are they not enabled in some files in their respective Variants folder?
The reason I'm asking is because all 5 serial ports and SPI work on the Discovery board but i2c doesn't work on the discovery board, but i2c works on the PX-HER0.
I mean instanciating the serial ports works on all 3 boards but only with discovery I get actual data coming out of the pins, on the other two, only 1 or 2 serial ports work, the rest of them are dead when i scope the tx pins.

User avatar
fpiSTM
Posts: 742
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 27
Location: Le Mans
Contact:

Re: Thunderpack STM32L072xx

Post by fpiSTM »

As said all is dependent to the PeripheralPins.c.
For PX_HERO not all the USART are available. Choice of the variant submitter.

razvitm
Posts: 33
Joined: Sat Apr 11, 2020 12:35 pm

Re: Thunderpack STM32L072xx

Post by razvitm »

But if I modify the PeripheralPins.C to include all the ports, possibly copy this from the discovery board, don't I have to set peripheral clocks for the other serial ports in order for them to work?

User avatar
fpiSTM
Posts: 742
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 27
Location: Le Mans
Contact:

Re: Thunderpack STM32L072xx

Post by fpiSTM »

Redefine peripheralPins.c at sketch level and instantiate them as described in the wiki as explained earlier in this topic...

Post Reply

Return to “STM32L0 based boards”