Question about uart_interrupt example code

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Question about uart_interrupt example code

跳至解决方案
763 次查看
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 */
    );
}

 

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
757 次查看
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

 

在原帖中查看解决方案

1 回复
758 次查看
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