MKL33 debug console and use of UART0

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MKL33 debug console and use of UART0

1,320 Views
arnogir
Senior Contributor II

Hello

 

I'm on a custom board with a Kinetis MKL33Z256.

This board use many UART.

The UART0 is used to communciate with a Wifi module (ESP32) through AT command on serial port.

 

For now, I start to devellop without activate the ESP32 then no characters was received/sent on the UART0.

All is Ok, the project is configured on "SDK Debug Console -> Semihost console" then when I made printf on the C code, I see the text into in the MCUXpresso console.

 

My question is how this work with Serial UART0?

Because since I activatet the ESP32 module, I send and received character on the UART0, but I get an Hard fault:

Screen.png

 

I suspect there is a conflict between the UART 0 used and the console.

I do not know exactly how work the "debug console" and the interaction with UART0??

This is my UART config

Screen2.png

 

Screen3.png

 

Is somebody can help me?

 

Regards

Labels (1)
0 Kudos
7 Replies

1,293 Views
arnogir
Senior Contributor II

Hello,

I'm know the UART.

I'm using UART0 to use a wifi device (ESP32)

I'm using the UART1 to communicate with a BMS.

I'm not using the UART2.

 

Usualy, I use the printf into the code, only in debug to display some useful information during devellopment.

I recently did that on the MKL27 which used all uart for application and I printed some information to my MCUXpresso consol for debug purpose.

 

But here, with my MKL33 project, this seems crash to an hardfault when I receive data from the UART0 (I not yet run the UART1, I will test the BMS later)

 

Is it possible to use in the same time the UART0, UART1 and print some useful inromation, only for debug purpose to the MCUXpresso consol.

This seem be ok on MKL27 but not on MKL33?? Maybe the project is different, but I don't know what parameter check..??

I hope to be clear enough

0 Kudos

1,288 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

Sorry if the last information was not helpful.

My question is how this work with Serial UART0? Because since I activatet the ESP32 module, I send and received character on the UART0, this seems crash to an hardfault when I receive data from the UART0.
I review your information again, I recommend changing your code to the interrupt mode and DMA.

Is it possible to use in the same time the UART0, UART1 and print some useful inromation, only for debug purpose to the MCUXpresso consol.
Not at the same time but is possible to use both, in a separate console.

If you have more questions please let me know.

Best regards,
Pavel

 

0 Kudos

1,238 Views
arnogir
Senior Contributor II

Hello

Sorry for the long reply, I was locked on this site and I must make verify my e-mail. This is ok now!

 

I found my mistake. 

Into the UART interrupt callback, I call again HAL_UartReceiveNonBlocking to read the next byte.

But I changed by mistake the pointer on a global variable buffer to a local buffer (into the stack)... This is why, when data received, it was written into this stack at a time where this address was used for other thing...

Sorry for that.

 

But with semihost, I make a printf to the console(in ground loop) of the received data on the UART0.

But Semihost should have prior interrupt than UART0? Because some data are missed sometime from the real received data..

Without printf, all run correctly.

0 Kudos

1,209 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

But with semihost, I make a printf to the console(in ground loop) of the received data on the UART0. But Semihost should have prior interrupt than UART0? Because some data are missed sometime from the real received data. Without printf, all run correctly.

What do you mean by ground loop? I recommend reviewing this thread to get more details about the semihost [MCUXpresso IDE and Semihosting - NXP Community] [What is Semihosting? - NXP Community].

Best regards,
Pavel

0 Kudos

1,315 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

The configurations look good but you can not use the debug console as a sniffer [to connect 3 devices], If you want to use the UART as a debugger console, I suggest using 2 UART in the Master device, 1 UART for commands, and the other for communication for devices. I apologize if my explanation is not clear, please let me know if you need more information.

Best regards,
Pavel

0 Kudos

1,313 Views
arnogir
Senior Contributor II

Hello

 

I don't no want use the UART to Debug but the Debug console via the JTAG probe.

I already used by the past another Kinetis KL27 using the 3 UART for the application (serial gateway)

Durring devellopment I configured and used the 3 UART for the application while during the debuging, I used the "printf" which printed the output to the MCUXpresso console.

 

I'm using P&E micro Multilink probe.

 

I think I do the same currently with the MKL33: I using UART 0 and 1 for my application. And use printf to print some debug information to the MCUXpresso console.

I think my project is bad configured for that? Would you advice me how correctly configure and use the UART0 and UART1 while printf work properly to the MCUXpresso console?

Ragrds

0 Kudos

1,301 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello,

Well, the UART communication is a protocol point to point.

Pavel_Hernandez_0-1663188225359.png

If you need to connect another device you need to set up another UART port.

Would you advice me how correctly configure and use the UART0 and UART1 while printf work properly to the MCUXpresso console?

If you want to use the mk33 as interpreter from the pc console that's the way, but depend of your application.

Best regards,
Pavel

 

0 Kudos