Skip to main content
yjae
Associate II
August 24, 2018
Solved

Can you tell me how to set up serial port in keil?

  • August 24, 2018
  • 27 replies
  • 5191 views

I'm a beginner. I'd appreciate your help.

This topic has been closed for replies.
Best answer by Tesla DeLorean

The L073RZ is capable of using DMA for USART4, the VCOM.C is not illustrative of this, but there might be examples under the HAL trees.

STM32Cube_FW_L0_V1.10.0\Projects\STM32L073RZ-Nucleo\Examples\UART\UART_TwoBoards_ComDMA

27 replies

yjae
yjaeAuthor
Associate II
September 1, 2018

this is right?

yjae
yjaeAuthor
Associate II
September 1, 2018

this is right?

Tesla DeLorean
Guru
September 1, 2018

That looks reasonable to enable the GPIO and USART peripheral involved, not sure why this needs additional validation. You should be able to check the peripheral registers via the debugger view. Or do additional checks on the functionality by sending a stream of characters, like 'U', and looking at that on a scope or terminal.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
yjae
yjaeAuthor
Associate II
September 1, 2018

'.\sx1272mb2das\NUCLEO_CUBE_LORA.axf: Error: L6218E: Undefined symbol __HAL_RCC_UART4_CLK_ENABLE '

Why does this error occur?​

(_USART4_CLK_ENABLE(); this part)

Tesla DeLorean
Guru
September 1, 2018

Make sure you are building the code for the right target architecture

P-NUCLEO-LRWAN1 STM32L073RZ using SX1272MB2xAS

Confirm the C command line is passed the define STM32L073xx

Grep or find-in-files for

__HAL_RCC_USART4_CLK_ENABLE

Should see

#define __HAL_RCC_USART4_CLK_ENABLE() SET_BIT(RCC->APB1ENR, (RCC_APB1ENR_USART4EN))

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
yjae
yjaeAuthor
Associate II
September 3, 2018

5 to 6 lines of code you gave me

__USART4_CLK_ENABLE();

__GPIOC_CLK_ENABLE();

Is this right? This results in an error.

__HAL_RCC_USART4_CLK_ENABLE();

__HAL_RCC_GPIOC_CLK_ENABLE();

This won't cause an error.Is this right?

Tesla DeLorean
Guru
September 3, 2018

We're going in circles.

Go with the code that compiles and works. USART4 is your target, not mine, I provided a template I believe is a good starting point, adjust to fit. A complete working and tested example demonstrating end-to-end functionality would take significant time/effort, something that would need to be adequately funded.

stm32_hal_legacy.h seems to convert USART4 references to UART4, the macro expansions look to be an issue. I'm using earlier version of the LRWAN library, and where appropriate pulling into newer/different HAL libraries.

__HAL_RCC_USART4_CLK_ENABLE(); // exists

__HAL_RCC_UART4_CLK_ENABLE(); // does not

>>Is this right?

Look, the compiler/linker can tell you if it can get closure. You'll need to be agile/adaptive when adding functionality to the examples, the stuff provided by ST is rough around the edges, you're apt to run into issues either in the compile/link stages, or the robustness of the examples.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..