Question about uart_interrupt example code

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

Question about uart_interrupt example code

Jump to solution
761 Views
stdcerr
Contributor IV

Hi,

I've opened the uart_interrupt code in MCUXpresso and am interested in changing the code from using UART0 to usiung UART4 on MK64FN1M0VLL12.

I have modified the UART macros & port settings but am unsure what to do about the following macros:

  • SIM_SOPT5_UART0TXSRC_MASK
  • SIM_SOPT5_UART0TXSRC
  • SOPT5_UART0TXSRC_UART_TX

in function BOARD_InitPins. What's their functiuonality exactly and how can I adjust it to apply to UART4 instead of UART0. My changed BOARD_InitPins() code looks like:

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

  PORT_SetPinMux(PORTC, 14u, kPORT_MuxAlt3);           /* PORTC14 (pin 86) is configured as UART4_RX */
  PORT_SetPinMux(PORTC, 15u, kPORT_MuxAlt3);           /* PORTC15 (pin 87) is configured as UART4_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 */
    );
}

 

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
755 Views
mjbcswitzerland
Specialist V

Hi

UART0 and UART1 Tx pins can be set to be modulated by timers (for example as used to drive IR LEDs).

The other UARTs Tx pins don't support this so you don't need to change anything.

The code that you show is just disabling the modulation function, which is the default, and thus not normally of interest.

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or product development requirements

 

View solution in original post

1 Reply
756 Views
mjbcswitzerland
Specialist V

Hi

UART0 and UART1 Tx pins can be set to be modulated by timers (for example as used to drive IR LEDs).

The other UARTs Tx pins don't support this so you don't need to change anything.

The code that you show is just disabling the modulation function, which is the default, and thus not normally of interest.

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or product development requirements