Trouble using printf/debug_printf using MQX/KSDK/PEx with FRDM-K22F

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble using printf/debug_printf using MQX/KSDK/PEx with FRDM-K22F

Jump to solution
608 Views
dave408
Senior Contributor II

I still haven't got a good understanding of how determining what pins are used for the UART that eventually sends its data to the virtual COM port when using the Segger jlink firmware.

I have a bare metal project where printf goes to the console window in KDS, which is pretty nice.

I have a FRDM-K64F project that connects fsl_debug_console to UART0, and output from debug_printf goes to the virtual COM port.  I have to open a terminal program to see the output, but that's fine.  Rx goes to UART1_RX_TGTMCU and Tx goes to UART1_TX_TGTMCU.  The issue for me here is that I wouldn't have known how to determine those are the right pins, if I hadn't read someone else's tutorial.  :smileysad:

I have a FRDM-K22F project that connects fsl_debug_console to UART0, and I have assigned Tx to PTB17, but none of the options are free or make sense.  For example, here are the available options:

  • PTB17 - available, assigned, but not working with debug_printf
  • PTA2/UART0_TX/FTM0_CH7/JTAG_TDO/TRACE_SWO/EZP_DO - in conflict
  • PTD7/UART0_TX/FTM0_CH7/FTM0_FLT1/SPI1_SIN - in conflict with SPI

Rx has no available options:

  • PTB16 - in use, but if it's the one that *must* be used, that's fine, I can change to another GPIO
  • CMP0_Output - not available with the CPU package
  • CMP1_Output - also not available
  • PTD6 - in conflict with SPI
  • PTA1/UART0_RX/FTM0_CH6/JTAG_TDI/ESP_DI - in conflict with other property, though it's not one that I set up

So how does one determine what pins should be assigned to the UART that will go to the virtual COM port or the console window?

At this point, I really only need Tx working so I can output to the terminal, but I can't even get that to work when set to PTB17, which is the only available option...

1 Solution
124 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Dave:

The correct interface for the FRDM-K22F virtual COM (via OpenSDA) is UART1,  pins PTE0/PTE1. Usual ways to determine this:

1) From the board user guide:

pastedImage_7.png

2) The board schematics:

pastedImage_12.png

:smileyalert: IMPORTANT: A bug has been identified with the fsl_debug_console component for FRDM-K22F. It generates an erroneous UART index in the file DbgCs1.h:

#define BOARD_DEBUG_UART_INSTANCE 2


Please change it to 1 and disable code generation only for that component:


pastedImage_11.png


Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

5 Replies
125 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Dave:

The correct interface for the FRDM-K22F virtual COM (via OpenSDA) is UART1,  pins PTE0/PTE1. Usual ways to determine this:

1) From the board user guide:

pastedImage_7.png

2) The board schematics:

pastedImage_12.png

:smileyalert: IMPORTANT: A bug has been identified with the fsl_debug_console component for FRDM-K22F. It generates an erroneous UART index in the file DbgCs1.h:

#define BOARD_DEBUG_UART_INSTANCE 2


Please change it to 1 and disable code generation only for that component:


pastedImage_11.png


Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

124 Views
dave408
Senior Contributor II

Hi Jorge, I'm currently revisiting my K64F project, and figured I'd close the loop and see how your explanation matches up.  Can you please explain one more thing?  I'm looking at the K64F schematic right now, and this is what I see:

pastedImage_1.png

Normally, I believe I have the osa1 UART device set to UART0, and RxD and TxD are UART1_RX_TGTMCU and UART1_TX_TGTMCU.  Is this a bug in PEx?  I'm jumping between so many projects right now I can't remember if this is the one where printf to the virtual COM port isn't working, but if not, maybe this is why.

If I select UART1 from Device, then I can't assign the RxD and TxD signals in PEx as they appear in the schematic.

0 Kudos
124 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hi Dave:

That is for the K20 MCU (OpenSDA interface).

Actually the pins used from the K64 MCU correspond to UART0 module. Check the next image:

K64_UART.png

Regards!

Jorge Gonzalez

0 Kudos
124 Views
dave408
Senior Contributor II

AH!  Such a dumb mistake on my end.  Thank you for the clarification.

0 Kudos
124 Views
dave408
Senior Contributor II

Ok, thank you, I will give that a try!

EDIT -- Yup, that did the trick!!!  Thanks!

0 Kudos