FAQ

FAQ No.:0000243  Issue Date:2018-11-27

How to change the UART port when using the UART function of NuMicro_ISP_Programming_Tool for ISP update?

When using the UART function of NuMicro_ISP_Programming_Tool for ISP update, there are three steps to change the UART port.

 

1. In targetdev.h, find define, change the UART port and the name of the interrupt subroutine to the name of the target PORT

(For different chips, the name of the interrupt subroutine may be slightly different, please refer to the interrupt vector table.)

2. In main.c, find the SYS_Init(), which has the clock setting for the UART, and change the original UART PORT setting to the target UART PORT setting.
3. In main.c, find the SYS_Init(); there are MFP settings for the UART at the bottom; change the MFP to the MFP of the target PORT.

(1) /* Set PD multi-function pins for UART0 RXD(PD.0) and TXD(PD.1) */

 

For example: Change the UART port of the NUC126 ISP update from

UART0 to UART1

Step 1 Change PORT Define (targetdev.h)

Before change

#define UART_T UART0

#define UART_T_IRQHandler UART02_IRQHandler

#define UART_T_IRQn UART02_IRQn

After change

#define UART_T UART1

#define UART_T_IRQHandler UART1_IRQHandler

#define UART_T_IRQn UART1_IRQn

 

Step 2 Change the clock setting of UART PORT (main.c)

Before change

CLK->APBCLK0 |= CLK_APBCLK0_UART0CKEN_Msk;

CLK->CLKSEL1 = (CLK->CLKSEL1 & (~CLK_CLKSEL1_UARTSEL_Msk)) | CLK_CLKSEL1_UARTSEL_HIRC;

CLK->CLKDIV0 = (CLK->CLKDIV0 & (~CLK_CLKDIV0_UARTDIV_Msk)) | CLK_CLKDIV0_UART(1);

After change

CLK->APBCLK0 |= CLK_APBCLK0_UART1CKEN_Msk;

CLK->CLKSEL1 = (CLK->CLKSEL1 & (~CLK_CLKSEL1_UARTSEL_Msk)) | CLK_CLKSEL1_UARTSEL_HIRC;

CLK->CLKDIV0 = (CLK->CLKDIV0 & (~CLK_CLKDIV0_UARTDIV_Msk)) | CLK_CLKDIV0_UART(1);

P.S. The UART Clock settings of different chips may be slightly different. Refer to the Sample Code in the BSP or the Clock chapter in the Technical Reference Manual.

 

Step 3 Change MFP to the target port (main.c)

Before change

/* Set PD multi-function pins for UART0 RXD(PD.0) and TXD(PD.1) */

SYS->GPD_MFPL = (SYS->GPD_MFPL & (~SYS_GPD_MFPL_PD0MFP_Msk)) | SYS_GPD_MFPL_PD0MFP_UART0_RXD;

SYS->GPD_MFPL = (SYS->GPD_MFPL & 

(~SYS_GPD_MFPL_PD1MFP_Msk)) | SYS_GPD_MFPL_PD1MFP_UART0_TXD;

After change

/* Set PD multi-function pins for UART0 RXD(PE.9) and TXD(PE.8) */

SYS->GPE_MFPH = (SYS->GPE_MFPH & (~SYS_GPE_MFPH_PE9MFP_Msk)) | SYS_GPE_MFPH_PE9MFP_UART1_RXD;

SYS->GPE_MFPH = (SYS->GPE_MFPH & (~SYS_GPE_MFPH_PE8MFP_Msk)) | SYS_GPE_MFPH_PE8MFP_UART1_TXD;

Products: 8bit 8051 MCUs , ARM Cortex-M0 MCUs , ARM Cortex-M23 MCUs , ARM Cortex-M4 MCUs
Applications:
Function: In System Programming (ISP) Tool
Keyword: ISP, upgrade, UART

Share

Enter the Email address you like to share*
Your email*
Your name*
Validate Code*

User Feedback

Please rate our website
Email
Name*
Validate Code*

微信扫一扫,关注新唐MCU。

Login myNuvoton

to stay informed of any changes to the documents you download.
If you don't want to login, just close this page and download directly.