最近接了一个项目,用的是MINI54ZDE,手上并没有实际板子。
使用内部RC作为时钟源,用串口打印I2C收到的数据,并控制相应IO状态.
但是现在发现IO可以正常控制,但是串口和i2c都没有工作,串口没有波形,i2C上有数据,但是mcu接收不到,下面是配置代码,请老铁们给看看
系统及外设时钟配置:
void SYS_Init(void)
{
/* Unlock protected registers */
SYS_UnlockReg();
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
// /* Set P5 multi-function pins for XTAL1 and XTAL2 */
// SYS->P5_MFP &= ~(SYS_MFP_P50_Msk | SYS_MFP_P51_Msk);
// SYS->P5_MFP |= (SYS_MFP_P50_XTAL1 | SYS_MFP_P51_XTAL2);
/* Enable external 12MHz XTAL, internal 22.1184MHz */
CLK_EnableXtalRC(CLK_PWRCON_HIRC_EN_Msk);
/* Waiting for clock ready */
CLK_WaitClockReady(CLK_CLKSTATUS_IRC22M_STB_Msk);
/* Switch HCLK clock source to XTL */
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC,CLK_CLKDIV_HCLK(2));
/* STCLK to XTL STCLK to XTL */
CLK_SetSysTickClockSrc(CLK_CLKSEL0_STCLK_S_HIRC_DIV2);
/* Enable IP clock */
CLK_EnableModuleClock(UART_MODULE);
CLK_EnableModuleClock(I2C_MODULE);
/* Select IP clock source */
CLK_SetModuleClock(UART_MODULE,CLK_CLKSEL1_UART_S_HIRC,CLK_CLKDIV_UART(1));
/*---------------------------------------------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*---------------------------------------------------------------------------------------------------------*/
/* Set P0 multi-function pins for UART RXD and TXD */
SYS->P0_MFP &= ~(SYS_MFP_P01_Msk | SYS_MFP_P00_Msk);
SYS->P0_MFP |= (SYS_MFP_P01_RXD | SYS_MFP_P00_TXD);
/* Set P3.4 and P3.5 for I2C SDA and SCL */
SYS->P3_MFP = SYS_MFP_P34_SDA | SYS_MFP_P35_SCL;
/* Lock protected registers */
SYS_LockReg();
/* Update System Core Clock */
SystemCoreClockUpdate();
}
上电相关配置:
int32_t main (void)
{
uint32_t i;
unsigned char debugdata[5];
/* Init System, IP clock and multi-function I/O */
SYS_Init();
GPIO_Init();
/* Init UART to 115200-8n1 for print message */
UART_Open(UART0, 115200);
/* Init I2C */
I2C_Init();
/* I2C enter no address SLV mode */
I2C_SET_CONTROL_REG(I2C, I2C_SI | I2C_AA);
......
|