How to proprely remap peripherals in MQX4.1 BSP for K60?

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

How to proprely remap peripherals in MQX4.1 BSP for K60?

Jump to solution
1,416 Views
ARQuattr
Contributor IV

I am trying to remap a UART port to different pins on a K60 custom board running MQX4.1 and the TWRK60F120M BSP. The BSP uses UART0 RX/TX on pins PTA1 and PTA2, but I have pins PTA15 and PTA14 wired for UART0. The UART is enabled in the user_config.h file and I modified the _bsp_serial_io_init function in the init_gpio.c file, changing these lines for the UART0 case (changing only the bit numbers to 15 and 14):

  pctl->PCR[15] = 0 | PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK;

  pctl->PCR[14] = 0 | PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK;

...but this doesn't work. If I leave the original PCR settings and wire the RX input to PTA1, it works OK, so I'm not sure why changing to the other pins is not working. When I use the above PCR settings it doesn't read the UART on either RX pin (PTA1 or PTA15). I was testing only RX so far.

Since PTA14 and PTA15 are also used by the ENET, I disabled all the ENET options, setting RTCSCFG_ENABLE_IP4, RTCSCFG_ENABLE_UDP, RTCSCFG_ENABLE_TCP, RTCSCFG_ENABLE_STATS, RTCSCFG_ENABLE_GATEWAYS, RTCSCFG_ENABLE_LWDNS, and RTCSCFG_ENABLE_ICMP to 0 in user_config.h. This didn't help.  (BTW, is there a better/easier way to simply disable all RTCS features?)

I also have it printing out the state of the PCR registers for both pins to confirm it was set correctly by _bsp_serial_io_init and wasn't subsequently changed.  The PCR registers for both PTA14 and PTA15 read 0x240, as I believe they should be.

I tried the same things on an actual tower board and had the same results so I don't think there is a hardware issue.

Is there some other step I'm missing to remap that UART port?

Tags (4)
0 Kudos
Reply
1 Solution
1,016 Views
DavidS
NXP Employee
NXP Employee

Hi Angelo,

I suspect that one of the following software configurations in the BSP is wrong:

Enable the #define BSPCFG_ENABLE_TTYA in user_config.h to 1.

In twrk60f120m.h setup Default IO to use ttya as follows:

#ifndef BSP_DEFAULT_IO_CHANNEL

#if BSPCFG_ENABLE_TTYA <--HERE

#define BSP_DEFAULT_IO_CHANNEL "ttya:" <--HERE //DES was "ttyf:" /* OSJTAG-COM polled mode */

#define BSP_DEFAULT_IO_CHANNEL_DEFINED

#else

#define BSP_DEFAULT_IO_CHANNEL NULL

#endif

#else

Change the PCR settings for UART0 from PTA1/2 to PTA14/15 AND fix the MUX setting in init_gpio.c as follows:

/* Setup GPIO for UART devices */

switch (dev_num)

{

case 0:

pctl = (PORT_MemMapPtr)PORTA_BASE_PTR;

if (flags & IO_PERIPHERAL_PIN_MUX_ENABLE)

{

#if 1 //DES 1=test for using PTA14/15 as alternate UART interface for TWR-K60F120M, 0=default code

/* PTA1 as RX function (Alt.3) + drive strength */

pctl->PCR[15] = 0 | PORT_PCR_MUX(3) | PORT_PCR_DSE_MASK;

/* PTA2 as TX function (Alt.3) + drive strength */

pctl->PCR[14] = 0 | PORT_PCR_MUX(3) | PORT_PCR_DSE_MASK;

#else

/* PTA1 as RX function (Alt.3) + drive strength */

pctl->PCR[1] = 0 | PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK;

/* PTA2 as TX function (Alt.3) + drive strength */

pctl->PCR[2] = 0 | PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK;

#endif

}

Re-compile the RTOS and MQX Application.

My hardware setup.

I just used my MQX4.1.1TWR-K60F120MTWR-SER card.

On TWR-SER card remove jumpers J17 and J19 (but record how they were configured so you can restore the setting: Default on 1-2 pins).

I installed jumper wire from TWR-K60F120M J23 pin 1 to TWR-SER J19 pin 1. This PTA14 UART0_TX.

I installed jumper wire from TWR-K60F120M B15 Primary riser side to TWR-SER J17 pin 1. This PTA15 UART0_RX.

I ran a modified hello world example so I could test both TX and RX signal paths.

Regards,

David

View solution in original post

0 Kudos
Reply
7 Replies
1,016 Views
soledad
NXP Employee
NXP Employee

Hi Angelo,

Please check the below thread and let me know if this helps :smileywink:

Cannot get any input using UART with MQX
Have a great day,
Sol

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

0 Kudos
Reply
1,016 Views
ARQuattr
Contributor IV

Hi Soledad, thanks for your reply.  I checked all the things mentioned but they don't help unfortunately.  Also, I was using ittya for this port from the beginning.

0 Kudos
Reply
1,016 Views
DavidS
NXP Employee
NXP Employee

Hi Angelo,

Please check your BSP to see if you are initializing Ethernet as the PTA14 and PTA15 are initialized in the _bsp_enet_io_init() function in the init_gpio.c file.  I suspect that the ENET is getting configured after you have changed setup the serial port to use PAT14/15.

Regards,

David

0 Kudos
Reply
1,016 Views
ARQuattr
Contributor IV

Hi David, thanks for your reply.  As I noted, I tried to disable all the ENET options although I'm not sure if I did it correctly/completely.  Also, I checked the PCR registers and they look OK.

0 Kudos
Reply
1,017 Views
DavidS
NXP Employee
NXP Employee

Hi Angelo,

I suspect that one of the following software configurations in the BSP is wrong:

Enable the #define BSPCFG_ENABLE_TTYA in user_config.h to 1.

In twrk60f120m.h setup Default IO to use ttya as follows:

#ifndef BSP_DEFAULT_IO_CHANNEL

#if BSPCFG_ENABLE_TTYA <--HERE

#define BSP_DEFAULT_IO_CHANNEL "ttya:" <--HERE //DES was "ttyf:" /* OSJTAG-COM polled mode */

#define BSP_DEFAULT_IO_CHANNEL_DEFINED

#else

#define BSP_DEFAULT_IO_CHANNEL NULL

#endif

#else

Change the PCR settings for UART0 from PTA1/2 to PTA14/15 AND fix the MUX setting in init_gpio.c as follows:

/* Setup GPIO for UART devices */

switch (dev_num)

{

case 0:

pctl = (PORT_MemMapPtr)PORTA_BASE_PTR;

if (flags & IO_PERIPHERAL_PIN_MUX_ENABLE)

{

#if 1 //DES 1=test for using PTA14/15 as alternate UART interface for TWR-K60F120M, 0=default code

/* PTA1 as RX function (Alt.3) + drive strength */

pctl->PCR[15] = 0 | PORT_PCR_MUX(3) | PORT_PCR_DSE_MASK;

/* PTA2 as TX function (Alt.3) + drive strength */

pctl->PCR[14] = 0 | PORT_PCR_MUX(3) | PORT_PCR_DSE_MASK;

#else

/* PTA1 as RX function (Alt.3) + drive strength */

pctl->PCR[1] = 0 | PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK;

/* PTA2 as TX function (Alt.3) + drive strength */

pctl->PCR[2] = 0 | PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK;

#endif

}

Re-compile the RTOS and MQX Application.

My hardware setup.

I just used my MQX4.1.1TWR-K60F120MTWR-SER card.

On TWR-SER card remove jumpers J17 and J19 (but record how they were configured so you can restore the setting: Default on 1-2 pins).

I installed jumper wire from TWR-K60F120M J23 pin 1 to TWR-SER J19 pin 1. This PTA14 UART0_TX.

I installed jumper wire from TWR-K60F120M B15 Primary riser side to TWR-SER J17 pin 1. This PTA15 UART0_RX.

I ran a modified hello world example so I could test both TX and RX signal paths.

Regards,

David

0 Kudos
Reply
1,016 Views
ARQuattr
Contributor IV

Thanks David, I see my mistake - I didn't notice the MUX needed to change also (I left it Alt 2, when it needed to change to Alt 3).  I will try this, but I'm fairly sure that is the issue.

One other question - is there a single define that can be disable to turn off all RTCS?

Thanks again,

Angelo

0 Kudos
Reply
1,016 Views
DavidS
NXP Employee
NXP Employee

Hi Angelo,

Glad to help.

Simplest method is “don’t” use it ☺

With the hello world example it never initializes the ENET interface so you don’t have to go an comment out code in the BSP.

Regards,

David

0 Kudos
Reply