Just started with MQX, the K60 and Keil. How do I enable a pin set and use the ALT function to get ot the serial ports? I need 4 of them...

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

Just started with MQX, the K60 and Keil. How do I enable a pin set and use the ALT function to get ot the serial ports? I need 4 of them...

Jump to solution
731 Views
brianpaterson
Contributor III

Having just started with the K60, the first thing I found was the disabled pins - such as PTE4 and PTE5.

I need to enable the pins and set the ALT function to the UART. I also require 4 uarts...

I set the user_config.h to enable the TTYx set and ttya: is transmitting correctly.

Any thoughts or demo code I can get a bootstrap from?

Brian

0 Kudos
1 Solution
492 Views
brianpaterson
Contributor III

Thanks Luis - I'll try it and get back shortly!

A non-obvious spot to set stuff!

Thanks,

Brian

Edit: OK, I see. I also imagine that the I2C and the other buses work in a similar way.

Many thanks for pointing me in the right direction!

Here's another problem, but is associated with the first issue: When I change from one "ALT" function to another. do you have some magic code to illustrate this function? What I'd like to do is save off the initial function and invoke the second, third, etc. and be able to go back and forth between the functions.

Thanks again Luis!

Brian

View solution in original post

0 Kudos
2 Replies
492 Views
LuisCasado
NXP Employee
NXP Employee

Hello,

Go to the file:

C:\Freescale\Freescale_MQX_4_0\mqx\source\bsp\twrk60n512\init_gpio.c

Make the modifications you need in ports (ALT) and rebuild the BSP.

Function:

_mqx_int _bsp_serial_io_init

(

    /* [IN] Serial device number */

    uint_8 dev_num,

    /* [IN] Required functionality */

    uint_8 flags

)

{

    SIM_MemMapPtr   sim = SIM_BASE_PTR;

    PORT_MemMapPtr  pctl;

    /* Setup GPIO for UART devices */

    switch (dev_num)

    {

        case 0:

            pctl = (PORT_MemMapPtr)PORTD_BASE_PTR;

            if (flags & IO_PERIPHERAL_PIN_MUX_ENABLE)

            {

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

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

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

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

……

Luis

0 Kudos
493 Views
brianpaterson
Contributor III

Thanks Luis - I'll try it and get back shortly!

A non-obvious spot to set stuff!

Thanks,

Brian

Edit: OK, I see. I also imagine that the I2C and the other buses work in a similar way.

Many thanks for pointing me in the right direction!

Here's another problem, but is associated with the first issue: When I change from one "ALT" function to another. do you have some magic code to illustrate this function? What I'd like to do is save off the initial function and invoke the second, third, etc. and be able to go back and forth between the functions.

Thanks again Luis!

Brian

0 Kudos