M481ZIDAE cannot get UART1 to work · Issue #15 · OpenNuvoton/M480BSP · GitHub

您所在的位置:网站首页 nueclipse M481ZIDAE cannot get UART1 to work · Issue #15 · OpenNuvoton/M480BSP · GitHub

M481ZIDAE cannot get UART1 to work · Issue #15 · OpenNuvoton/M480BSP · GitHub

2023-02-15 06:34| 来源: 网络整理| 查看: 265

Hi, We are evaluating M481ZIDAE for a product to replace STM32F411 and i have to say the peripheral library and the toolchain really leave to be desired. We use NUEclipse and NuLink and there is not even a way to load and run the firmware directly without starting a debug session, this is really annoying, for the least, please let us know how to setup the run configuration so that the run button directly load and run the firmware without opening a debug session, without that the productivity is deeply affected.

Other than that we have some issues with the BSP, at first it looked decent but as soon as we started to use it, it became clear that it was going to be a pain, basically it is full of defines which we have no way to know which one to use other than parsing sources or technical manual, it is really not how a peripheral library should be in 202 (maybe you should check how things are done by ST and other vendors).

That being said, here is the immediate problems we are facing now, starting with the M481ZIDAE :

We need to use UART1 on PB2 and PB3 for printf, so we changed one of the example and the printf retarget to use UART1, sadly it does not work at all :

#include #include "NuMicro.h" #include "gpio.h" #define PLL_CLOCK 192000000 void SYS_Init(void) { /* Unlock protected registers */ SYS_UnlockReg(); /* Set XT1_OUT(PF.2) and XT1_IN(PF.3) to input mode */ PF->MODE &= ~(GPIO_MODE_MODE2_Msk | GPIO_MODE_MODE3_Msk); /* Enable External XTAL (4~24 MHz) */ CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk); /* Waiting for 12MHz clock ready */ CLK_WaitClockReady(CLK_STATUS_HXTSTB_Msk); /* Set core clock as PLL_CLOCK from PLL */ CLK_SetCoreClock(PLL_CLOCK); /* Set PCLK0/PCLK1 to HCLK/2 */ CLK->PCLKDIV = (CLK_PCLKDIV_PCLK0DIV2 | CLK_PCLKDIV_PCLK1DIV2); /* Enable UART clock */ CLK_EnableModuleClock(UART1_MODULE); CLK_EnableModuleClock(TMR0_MODULE); /* Select UART clock source from HXT */ CLK_SetModuleClock(UART1_MODULE, CLK_CLKSEL1_UART1SEL_HXT, CLK_CLKDIV0_UART1(1)); CLK_SetModuleClock(TMR0_MODULE, CLK_CLKSEL1_TMR0SEL_HXT, 0); /* Update System Core Clock */ SystemCoreClockUpdate(); /* Set PB multi-function pins for UART1 RXD(PB.2) and TXD(PB.3) */ SYS->GPB_MFPL = (SYS->GPB_MFPL & (~SYS_GPB_MFPL_PB2MFP_Msk)) | SYS_GPB_MFPL_PB2MFP_UART1_RXD; SYS->GPB_MFPL = (SYS->GPB_MFPL & (~SYS_GPB_MFPL_PB3MFP_Msk)) | SYS_GPB_MFPL_PB3MFP_UART1_TXD; /* Lock protected registers */ SYS_LockReg(); } int main() { SYS_Init(); SYS_ResetModule(UART1_RST); UART_Open(UART1, 115200); printf("\n\nCPU @ %dHz\n", SystemCoreClock); while(1){ printf("test uart1\n"); TIMER_Delay(TIMER0, 200000); } }

Also, we have a LED on PB15 and even getting this LED to blink doesnt work :

#include #include "NuMicro.h" #include "gpio.h" #define PLL_CLOCK 192000000 void SYS_Init(void) { /* Unlock protected registers */ SYS_UnlockReg(); /* Set XT1_OUT(PF.2) and XT1_IN(PF.3) to input mode */ PF->MODE &= ~(GPIO_MODE_MODE2_Msk | GPIO_MODE_MODE3_Msk); /* Enable External XTAL (4~24 MHz) */ CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk); /* Waiting for 12MHz clock ready */ CLK_WaitClockReady(CLK_STATUS_HXTSTB_Msk); /* Set core clock as PLL_CLOCK from PLL */ CLK_SetCoreClock(PLL_CLOCK); /* Set PCLK0/PCLK1 to HCLK/2 */ CLK->PCLKDIV = (CLK_PCLKDIV_PCLK0DIV2 | CLK_PCLKDIV_PCLK1DIV2); /* Enable UART clock */ CLK_EnableModuleClock(TMR0_MODULE); /* Update System Core Clock */ /* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */ SystemCoreClockUpdate(); /* Lock protected registers */ SYS_LockReg(); } int main() { SYS_Init(); GPIO_SetMode(PB, BIT15, GPIO_MODE_OUTPUT); while(1){ GPIO_TOGGLE(PB15); TIMER_Delay(TIMER0, 200000); } }

Honestly i dont know how such simple things can be failing, and it is not very reassuring for the evaluation. Ultimately what we need to do with this MCU is to have continuous acquisition of ADC samples via DMA at 12bit-1.6MSPS from differential input PB0 - PB1 into a 16KB (or 2*8KB) buffer, with interrupts at half and full transfer (hopefully there is a function to do double buffering too) and process the samples continuously during acquisition with the DSP library. We also need to use the I2C on PA2 - PA3 for control of an external chip.

All that should be very simple, at least it is with the STM32F411 so i hope you guy can help us to setup the IDE and get that done.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3