MCUXpresso FRDM-K64F UART example questions

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

MCUXpresso FRDM-K64F UART example questions

2,576 Views
dave408
Senior Contributor II

I started to play with MCUXpresso earlier today and was trying to get two demos working on the FRDM-K64F.  I got them working, but I needed to make changes.  In doing so, I came up with a couple of questions.

  1. The polling demo uses PTB16 and PTB17 and UART3.  Why use those PORTB pins when they aren't accessible on the FRDM-K64F?  Or did I miss something?  I looked at the mbed pinout image, as well as the schematics, and it looks like PTB16 and PTB17 are used for OpenSDA.  Once I changed them to PORTC and enabled the right clock, the demo worked fine.
  2. The polling demo also has this code in BOARD_InitPins():

    SIM->SOPT5 = ((SIM->SOPT5 &
    (~(SIM_SOPT5_UART0TXSRC_MASK))) // Mask bits to zero which are setting
    | SIM_SOPT5_UART0TXSRC(SOPT5_UART0TXSRC_UART_TX) // UART 0 transmit data source select: UART0_TX pin
    );

    Why is that there if the demo is using UART3?
  3. And why would it use UART3 if PTB16 and PTB17 can only be assigned to UART0?
  4. Interestingly enough, the interrupt demo uses UART0 and PTB16 and PTB17, which are correct.  Except the same thing goes here, I don't understand why NXP would pick those PORTB pins when they aren't on the Arduino-compatible headers.
0 Kudos
4 Replies

1,814 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Dave:

This demo configured UART0, could you please let me know where do you see UART3?

void BOARD_InitPins(void) {
  CLOCK_EnableClock(kCLOCK_PortB);                           /* Port B Clock Gate Control: Clock enabled */

  PORT_SetPinMux(PORTB, PIN16_IDX, kPORT_MuxAlt3);           /* PORTB16 (pin 62) is configured as UART0_RX */
  PORT_SetPinMux(PORTB, PIN17_IDX, kPORT_MuxAlt3);           /* PORTB17 (pin 63) is configured as UART0_TX */
  SIM->SOPT5 = ((SIM->SOPT5 &
    (~(SIM_SOPT5_UART0TXSRC_MASK)))                          /* Mask bits to zero which are setting */
      | SIM_SOPT5_UART0TXSRC(SOPT5_UART0TXSRC_UART_TX)       /* UART 0 transmit data source select: UART0_TX pin */
    );
}

Regards

Daniel

0 Kudos

1,814 Views
dave408
Senior Contributor II

I'd better double-check things to make sure it wasn't something I had done!  In hindsight, maybe that's what happened.  This does highlight my main question, which is, why is the demo using PTB16 and PTB17 instead of something like PTC16 and PTC17 that are clearly marked on the arduino headers?

You are probably right that the demo was UART0 and I misidentified things in my original post, and I apologize for that.

I believe I did get the UART interrupt demo working with PTC16 and PTC17 using UART3, but am I correct that UART3 doesn't have a TX/RX pin selection register?  (i.e. like SOPT5 for UART0/1)

0 Kudos

1,814 Views
dave408
Senior Contributor II

I'll answer my last question - doesn't look like UART3 has the same sort of selection, so I should be able to delete that code from the demo and still have a working UART.  I need to read up on UART0 to understand what SOPT5 is doing.

0 Kudos

1,814 Views
mjbcswitzerland
Specialist V


Hi Dave

UART0 is connected to the OpenSDA's VCOM interface pins on PTB16 and PTB17 so that is why these are used as default.

The SIM_SOPT5 controls special connections to UARTs 0 and 1 pins but these are not relevant for normal UART operation (they allow the output to be modulated with a timers - eg. for driving infra red diodes, and the input to be from a comparator - eg. when special switching levels are desired).

For UART3 the differences are that it is clocked from the bus clock and not the system clock (as UARTs 0 and 1 are) and for connections on PTC16 and PTC17 the connections are made in the PORTC_PCRx registers (ALT3).

Regards

Mark


Kinetis: http://www.utasker.com/kinetis.html
Kinetis K64:
- http://www.utasker.com/kinetis/FRDM-K64F.html
- http://www.utasker.com/kinetis/TWR-K64F120M.html
- http://www.utasker.com/kinetis/TEENSY_3.5.html
- http://www.utasker.com/kinetis/Hexiwear-K64F.html
UART: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF
[including full DMA driven (free-running) rx and tx for FreeRTOS based developments]

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M

For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html