cancel
Showing results for 
Search instead for 
Did you mean: 

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

yjae
Associate II

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

27 REPLIES 27
yjae
Associate II

​so

 __HAL_RCC_USART4_CLK_ENABLE();

 __HAL_RCC_GPIOC_CLK_ENABLE();

I fixed it like this.

(This way there is no error.)

yjae
Associate II

this is right?

yjae
Associate II

this is right?

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
Up vote any posts that you find helpful, it shows what's working..
yjae
Associate II

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

Why does this error occur?​

(_USART4_CLK_ENABLE(); this part)

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
Up vote any posts that you find helpful, it shows what's working..
yjae
Associate II

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?

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
Up vote any posts that you find helpful, it shows what's working..