Change the Default OSJTAG-COM UART

cancel
Showing results for 
Search instead for 
Did you mean: 

Change the Default OSJTAG-COM UART

Jump to solution
467 Views
Contributor III

Hi All,

I am using a custom MK70FN1M0VMJ12 board. I am using MQX-4.1 and keil uvision. I am using twrk70f120m code.

First of all will the code run in my custom board ?

And I wanted to change the pin mux as per the custom board and use the default OSJTAG-COM uart in UART-0.

My UART-0 pins are 

PTB16/UART0_RX

PTB17/UART0_TX

So I changed the Init_gpio in the bsp library to

 case 0:
            pctl = (PORT_MemMapPtr)PORTB_BASE_PTR;
            if (flags & IO_PERIPHERAL_PIN_MUX_ENABLE)
            {
                /* PTF17 as RX function (Alt.4) + drive strength */
                pctl->PCR[16] = 0 | PORT_PCR_MUX(4) | PORT_PCR_DSE_MASK;
                /* PTF18 as TX function (Alt.4) + drive strength */
                pctl->PCR[17] = 0 | PORT_PCR_MUX(4) | PORT_PCR_DSE_MASK;
            }
            if (flags & IO_PERIPHERAL_PIN_MUX_DISABLE)
            {
                /* PTF17 default */
                pctl->PCR[16] = 0;
                /* PTF18 default */
                pctl->PCR[17] = 0;
            }
            if (flags & IO_PERIPHERAL_CLOCK_ENABLE)
            {
                /* start SGI clock */
                sim->SCGC4 |= SIM_SCGC4_UART0_MASK;
            }
            if (flags & IO_PERIPHERAL_CLOCK_DISABLE)
            {
                /* stop SGI clock */
                sim->SCGC4 &= (~ SIM_SCGC4_UART0_MASK);
            }
            break;

I wanted to use this as default debug uart port as in OSJTAG-COM

So I changed in twrk70f120m.h 

/*
** Interrupt-driven TTY device (UART0)
** MGCT: <option type="bool"/>
*/
#ifndef BSPCFG_ENABLE_ITTYA
    #define BSPCFG_ENABLE_ITTYA             1
#endif

#ifndef BSP_DEFAULT_IO_CHANNEL
    #if BSPCFG_ENABLE_ITTYA
        #define BSP_DEFAULT_IO_CHANNEL                        "ittya:"    /* OSJTAG-COM   polled mode   */
        #define BSP_DEFAULT_IO_CHANNEL_DEFINED
    #else
        #define BSP_DEFAULT_IO_CHANNEL                        NULL
    #endif

And in user_config.h

#define BSPCFG_ENABLE_ITTYA      1

I rebuilt the library and I flashed the test code.

But No prints are coming in that UART-0.

Is there any other thing to change ?

Please Help.

Regards,

Vibhu.

1 Solution
26 Views
NXP TechSupport
NXP TechSupport

Please also try to put 

#define BSP_DEFAULT_IO_CHANNEL "ttya:"

 in user_config.h

BSP_DEFAULT_IO_CHANNEL is default to ttya in your original post,    the macro in user_config.h can overwrite this macro.

You also can put a breakpoint in init_bsp.c (in MQX 4.1)

/* Initialize the default serial I/O */
_io_serial_default_init();

make sure this function is called by MQX.

this function will init default serial uart port.  and will open the default IO_CHANNNEL.---ttya:

If everything is OK, and still can't get the output, then you need to check your hardware.  to make sure the debug port you connected is really uart0 in your custom board? 

Regards

Daniel

View solution in original post

20 Replies
26 Views
NXP TechSupport
NXP TechSupport

if ittya: does not work, please also check ttya:

0 Kudos
26 Views
Contributor III

Hi danielchen@fsl‌,

How do I check if that pin is used for any other purpose ? 

Any other configurations I need to change to make the UART work ?

Regards,

Vibhu

0 Kudos
26 Views
NXP TechSupport
NXP TechSupport

Hi  Vibhu:

Please refer to the K70 data sheet , PTB16 AND PTB17,   UART0_RX and UART0_TX is ALT3, but in you orignal post, ALT is 4, that 's wrong.

pastedImage_1.png

Regards

Daniel

26 Views
Contributor III

Hi danielchen@fsl‌,

Thank you for the correction. I changed the

PORT_PCR_MUX(4) to PORT_PCR_MUX(3)

But still I am not able to receive or send anything in the UART0. 

Regards,

Vibhu

0 Kudos
26 Views
NXP TechSupport
NXP TechSupport

Hi Vibhu:

You can check the register settings:

For PORTB_PCR16 and PORTB_PCR17,  MUX bits:   Alternative 3.

pastedImage_1.png

For SIM_SCGC4 :  uart0 clock enabled.

pastedImage_2.png

0 Kudos
26 Views
Contributor III

Hi danielchen@fsl‌,

Which is the tool which you have used to check this ? How do I check this in keil ?

Regards,

Vibhu.

27 Views
NXP TechSupport
NXP TechSupport

Please also try to put 

#define BSP_DEFAULT_IO_CHANNEL "ttya:"

 in user_config.h

BSP_DEFAULT_IO_CHANNEL is default to ttya in your original post,    the macro in user_config.h can overwrite this macro.

You also can put a breakpoint in init_bsp.c (in MQX 4.1)

/* Initialize the default serial I/O */
_io_serial_default_init();

make sure this function is called by MQX.

this function will init default serial uart port.  and will open the default IO_CHANNNEL.---ttya:

If everything is OK, and still can't get the output, then you need to check your hardware.  to make sure the debug port you connected is really uart0 in your custom board? 

Regards

Daniel

View solution in original post

26 Views
Contributor III

Hi danielchen@fsl‌,

Thank you very much for you help.

It seems that the ALT configuration was the issue.

Now I am able to send and get data in the uart, But however I am not still able to get the prints when I use printf.

I did change as you specified but still I am not able to get the printf.

Can you please help me

Regards,

Vibhu

0 Kudos
26 Views
NXP TechSupport
NXP TechSupport

Hi Vibhu:

I am happy to know the uart0 is working now.

Now you can check :

1. trace : _io_serial_default_init();

this function set the default debug uart.

2.  trance  printf:

In the end, it will call _io_fputc -> _io_serial_polled_write (if it is poll).

Regards

Daniel

26 Views
Contributor III

Hi danielchen@fsl‌,

How do I check the function whether it is called ?

The function is in the build lib. If I put breakpoint in the lib build and debug my code will it go there ? Will I be able to see it ?

And 

_bsp_serial_io_init

The above function is used to assign the pin. But how is it called in the mqx examples ? Where or how is it called to initialize the uart pins ?

Regards,

Vibhu.

0 Kudos
26 Views
NXP TechSupport
NXP TechSupport

Hi Vibhu:

Set a break point at _bsp_serial_io_init, it can hit.  My codewarrior can, I think Keil should can.

_bsp_serial_io_init is called in BSP,  before application starts.

Regards

Daniel

0 Kudos
26 Views
Contributor III

Hi danielchen@fsl‌,

If i put breakpoint in the build file (freescale mqx->mqx->build->uv4->bsp_twrk70f120m) and debug my application file.. unfortunately it is not going to that break point.. it is only going to the breakpoint which i put in my application.

Regards,

Vibhu

0 Kudos
26 Views
Contributor III

Hi danielchen@fsl‌,

Is there any other function which I can use instead of printf in mqx ? I wanted to use debug prints to print the values. Is there any other function which I can use ? Like UART specific function ?

Regards,

Vibhu

0 Kudos
24 Views
NXP TechSupport
NXP TechSupport

https://community.nxp.com/docs/DOC-93913 

Please check above link

26 Views
NXP TechSupport
NXP TechSupport

I am using codewarrior. For Keil, it should have the same register view

0 Kudos
26 Views
Contributor III

soledaddanielchen@fsl

Little help please.. 

0 Kudos
26 Views
NXP TechSupport
NXP TechSupport

Hi Vibhu:

I would suggest you check the hardware first, whether uart0 is routed correctly.

You can use your scope to check the signals of the UART0 RX TX.

If the hardware link is OK, then you can check from the software perspective. 

The general way to change the default debug channel is:

change the BSP_DEFAULT_IO_CHANNEL configuration option to other channel:

For example:

#define BSP_DEFAULT_IO_CHANNEL "ttya:"

Enable the channel in the user_config.h

BSPCFG_ENABLE_TTYA       1

Rebuilt all the libraries.


Please also read the MQX_BSP_Porting_Guide.pdf for more details.

Regards

Daniel

0 Kudos
26 Views
Contributor III

Hi Daniel,

The hardware pin is directly connected to the pin where i am using a TTL converter to connect it to pc and check.. so I guess the hardware part is direct. In software, I made the changes which I mentioned in my post.. Is there any other things to change ? 

I tried both ttya and ittya no luck.

Regards,

Vibhu.

0 Kudos
26 Views
NXP TechSupport
NXP TechSupport

From the software perspective, it should work,

You need to double check the uart pin configuration, is it used for other funciton at the same time?

0 Kudos
26 Views
Contributor III

Hi Daniel,

The uart pins were used for tss, but i commented those out. I couldn't find any other place where the pins were used. 

0 Kudos