/* ALT_MFP , ALT2_MFP~ALT4_MFP清零复位 */
SYS->ALT_MFP &=~(
SYS_ALT_MFP_PA0_Msk| SYS_ALT_MFP_PA1_Msk |
);
SYS->ALT2_MFP &=~(
SYS_ALT_MFP_PA0_Msk| SYS_ALT_MFP_PA1_Msk |
);
SYS->ALT3_MFP &=~(
SYS_ALT_MFP3_PA0_Msk | SYS_ALT_MFP3_PA1_Msk |
SYS_ALT_MFP3_PA2_Msk | SYS_ALT_MFP3_PA3_Msk |
);
SYS->ALT4_MFP &=~( SYS_ALT_MFP4_PA1_Msk| SYS_ALT_MFP4_PA2_Msk |
);
/* ALT_MFP , ALT2_MFP~ALT4_MFP设置 */
SYS->ALT_MFP |=(
SYS_ALT_MFP_PA0_UART5_TXD | SYS_ALT_MFP_PA1_UART5_RXD |
);
SYS->ALT2_MFP |=(
SYS_ALT_MFP_PA0_UART5_TXD | SYS_ALT_MFP_PA1_UART5_RXD |
);
SYS->ALT3_MFP |=(
SYS_ALT_MFP3_PA0_UART5_TXD | SYS_ALT_MFP3_PA1_UART5_RXD |
SYS_ALT_MFP3_PA2_UART3_TXD | SYS_ALT_MFP3_PA3_UART3_RXD |
);
SYS->ALT4_MFP |=(
SYS_ALT_MFP4_PA0_UART5_TXD | SYS_ALT_MFP4_PA1_UART5_RXD |
SYS_ALT_MFP4_PA2_UART3_TXD | SYS_ALT_MFP4_PA3_UART3_RXD |
);
这样的形式太累,容易出错,
其实看了几个ALT_MFP寄存器的定义就明白了 . 一般的功能都无需触及他,关于pwm和定时等相关时,才需要操作. 平常,还是和M0516一样 操作对应端口的MFP就可以了
如下:
#include "M0518.h";
/*
* @brief This function provides the configued MFP registers
* @param None
* @return None
*/
void SYS_Init(void)
{
//SYS->ALT_MFP = 0x00000000;
//SYS->ALT_MFP2 = 0x00000000;
//SYS->ALT_MFP3 = 0x00000000;
//SYS->ALT_MFP4 = 0x0000000C;
//SYS->GPA_MFP = 0x0000000C;
//SYS->GPB_MFP = 0x00000033;
//SYS->GPC_MFP = 0x000000C0;
//SYS->GPD_MFP = 0x0000C000;
//SYS->GPF_MFP = 0x000000C0;
//If the defines do not exist in your project, please refer to the related sys.h in the sys_h folder appended to the tool package.
SYS->ALT_MFP = 0x00000000;
SYS->ALT_MFP2 = 0x00000000;
SYS->ALT_MFP3 = 0x00000000;
SYS->ALT_MFP4 = SYS_ALT_MFP4_PA3_UART3_RXD | SYS_ALT_MFP4_PA2_UART3_TXD;
SYS->GPA_MFP = SYS_GPA_MFP_PA3_UART3_RXD | SYS_GPA_MFP_PA2_UART3_TXD;
SYS->GPB_MFP = SYS_GPB_MFP_PB5_UART1_TXD | SYS_GPB_MFP_PB4_UART1_RXD | SYS_GPB_MFP_PB1_UART0_TXD | SYS_GPB_MFP_PB0_UART0_RXD;
SYS->GPC_MFP = SYS_GPC_MFP_PC7_UART4_RXD | SYS_GPC_MFP_PC6_UART4_TXD;
SYS->GPD_MFP = SYS_GPD_MFP_PD15_UART2_TXD | SYS_GPD_MFP_PD14_UART2_RXD;
SYS->GPF_MFP = SYS_GPF_MFP_PF7_ICE_DAT | SYS_GPF_MFP_PF6_ICE_CLK;
return;
}
|
|