官網地址
http://www.nuvoton.com.cn/board/numaker-m031tc/
http://www.nuvoton.com.cn/products/microcontrollers/arm-cortex-m0-mcus/m031-series/m031tb0ae/
資源下載地址
開發必備BSP
http://www.nuvoton.com.cn/export/resource-files/M031_Series_BSP_CMSIS_V3.02.000.zip
解壓縮文件,複製一份demo代碼改個名字(複製GPIO_OutputInput,改名GPIO_LED)
M031_Series_BSP_CMSIS_V3.02.000\SampleCode\StdDriver\GPIO_OutputInput
M031_Series_BSP_CMSIS_V3.02.000\SampleCode\StdDriver\GPIO_LED
直接用Keil打開項目M031_Series_BSP_CMSIS_V3.02.000\SampleCode\StdDriver\GPIO_LED\KEIL\GPIO_OutputInput.uvproj
修改main.c代碼
#include "stdio.h"
#include "NuMicro.h"
static void SYS_Init(void)
{
/* Unlock protected registers */
SYS_UnlockReg();
/* Enable HIRC */
CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);
/* Waiting for HIRC clock ready */
CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);
/* Switch HCLK clock source to HIRC */
CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKDIV0_HCLK(1));
/* Set both PCLK0 and PCLK1 as HCLK/2 */
CLK->PCLKDIV = (CLK_PCLKDIV_APB0DIV_DIV2 | CLK_PCLKDIV_APB1DIV_DIV2);
/* Update System Core Clock */
/* User can use SystemCoreClockUpdate() to calculate PllClock, SystemCoreClock and CycylesPerUs automatically. */
SystemCoreClockUpdate();
/* Lock protected registers */
SYS_LockReg();
}
static void delay_ms(uint16_t nDelay)
{
uint16_t nIndex;
for(nIndex = 0; nIndex < nDelay; nIndex++)
{
CLK_SysTickDelay(1000);//delay one ms
}
}
int32_t main(void)
{
/* Init System, IP clock and multi-function I/O. */
SYS_Init();
GPIO_SetMode(PB,BIT14,GPIO_MODE_OUTPUT);
while(1){
PB14 = 1;
delay_ms(1000);
PB14 = 0;
delay_ms(1000);
}
}
板子上的LED燈是PB14
設置PB14爲輸出 GPIO_SetMode(PB,BIT14,GPIO_MODE_OUTPUT);
循環1秒鐘亮滅LED燈
寫在最後,產品是M0的32位處理器,估計是新唐產品以32位主了,8位的51資料少的可憐
有時間再試試1折買的其他板子