本帖最后由 binoo7 于 2021-8-3 12:26 编辑
最近刚申请了一个NuMaker-M471的开发板,照片忘了拍了,红色的挺喜庆,作为小白的我,第一次使用这个开发板,不知道怎么操作
板子收到的当天,小管家给我了三个链接
说真的,我这三个文件都下载了,但是很可惜,没法用,前两个是手册,我可以打开看,来了解相关的资料,第三个是应用相关的,不过我没有板级支持包,根本没法编译,这就让我很难受了,不过幸好我知道去官网问,他们给我了两个链接
这两个就比较友好了,里面由开发板相关的资料,在这里我和大家一起分享一下
资料比较大,好像无法上传,那就把链接发到这里吧,大家有空了下载一下,根据小管家和客服的资料,可以很容易的来搭建起开发环境,等有空了,点亮一个LED灯来测试一下板子M471示例代码在这个文件内M471_Series_BSP_CMSIS_V3.00.000,比较大,大家自行下载啊
这里面有个说明书,先看一下readme的介绍
那就是说如果我们想测试的话,就要从std这个文件夹里找一个例程来测试了,
官方还是很良心的,给我们这么多的例程,不过开发板因为没有外围电路,有些需要外围电路的就没法测试了
学习第一步,点灯来开路
看这里面没有其他包了,别害怕,其实是隐藏了,都还在
编译一下,没有错误,可以下载了
/**************************************************************************//**
* [url=home.php?mod=space&uid=288409]@file[/url] main.c
* [url=home.php?mod=space&uid=895143]@version[/url] V3.00
* [url=home.php?mod=space&uid=247401]@brief[/url] Show how to set GPIO pin mode and use pin data input/output control.
*
* SPDX-License-Identifier: Apache-2.0
* [url=home.php?mod=space&uid=17282]@CopyRight[/url] (C) 2020 Nuvoton Technology Corp. All rights reserved.
******************************************************************************/
#include "stdio.h"
#include "NuMicro.h"
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 HIRC clock (Internal RC 48 MHz) */
CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);
/* Wait for HIRC clock ready */
CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);
/* Set core clock as 96MHz from PLL */
CLK_SetCoreClock(FREQ_96MHZ);
/* Set PCLK0/PCLK1 to HCLK/2 */
CLK->PCLKDIV = (CLK_PCLKDIV_APB0DIV_DIV2 | CLK_PCLKDIV_APB1DIV_DIV2);
/* Enable UART clock */
CLK_EnableModuleClock(UART0_MODULE);
/* Select UART clock source from HIRC */
CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART0SEL_HIRC, CLK_CLKDIV0_UART0(1));
/* Update System Core Clock */
/* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */
SystemCoreClockUpdate();
/*----------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*----------------------------------------------------------------------*/
/* Set GPB multi-function pins for UART0 RXD and TXD */
SYS->GPB_MFPH = (SYS->GPB_MFPH & ~(SYS_GPB_MFPH_PB12MFP_Msk | SYS_GPB_MFPH_PB13MFP_Msk)) |
(SYS_GPB_MFPH_PB12MFP_UART0_RXD | SYS_GPB_MFPH_PB13MFP_UART0_TXD);
/* Lock protected registers */
SYS_LockReg();
}
/*----------------------------------------------------------------------*/
/* Init UART0 */
/*----------------------------------------------------------------------*/
void UART0_Init(void)
{
/* Reset UART0 */
SYS_ResetModule(UART0_RST);
/* Configure UART0 and set UART0 baud rate */
UART_Open(UART0, 115200);
}
int32_t main(void)
{
int32_t i32Err, i32TimeOutCnt;
/* Init System, IP clock and multi-function I/O. */
SYS_Init();
/* Init UART0 for printf */
UART0_Init();
printf("\n\nCPU [url=home.php?mod=space&uid=72445]@[/url] %dHz\n", SystemCoreClock);
printf("+-------------------------------------------------+\n");
printf("| PB.3(Output) and PC.1(Input) Sample Code |\n");
printf("+-------------------------------------------------+\n\n");
/*-----------------------------------------------------------------------------------------------------*/
/* GPIO Basic Mode Test --- Use Pin Data Input/Output to control GPIO pin */
/*-----------------------------------------------------------------------------------------------------*/
printf(" >> Please connect PB.3 and PC.1 first << \n");
printf(" Press any key to start test by using [Pin Data Input/Output Control] \n\n");
getchar();
/* Configure PB.3 as Output mode and PC.1 as Input mode then close it */
GPIO_SetMode(PB, BIT3, GPIO_MODE_OUTPUT);
GPIO_SetMode(PC, BIT1, GPIO_MODE_INPUT);
i32Err = 0;
printf("GPIO PB.3(output mode) connect to PC.1(input mode) ......");
/* Use Pin Data Input/Output Control to pull specified I/O or get I/O pin status */
/* Set PB.3 output pin value is low */
PB3 = 0;
/* Set time out counter */
i32TimeOutCnt = 100;
/* Wait for PC.1 input pin status is low for a while */
while(PC1 != 0)
{
if(i32TimeOutCnt > 0)
{
i32TimeOutCnt--;
}
else
{
i32Err = 1;
break;
}
}
/* Set PB.3 output pin value is high */
PB3 = 1;
/* Set time out counter */
i32TimeOutCnt = 100;
/* Wait for PC.1 input pin status is high for a while */
while(PC1 != 1)
{
if(i32TimeOutCnt > 0)
{
i32TimeOutCnt--;
}
else
{
i32Err = 1;
break;
}
}
/* Print test result */
if(i32Err)
{
printf(" [FAIL].\n");
}
else
{
printf(" [OK].\n");
}
/* Configure PB.3 and PC.1 to default Quasi-bidirectional mode */
GPIO_SetMode(PB, BIT3, GPIO_MODE_QUASI);
GPIO_SetMode(PC, BIT1, GPIO_MODE_QUASI);
while(1);
}
附件:链接
M471系列DS/TRM/BSP如下
TRM
https://www.nuvoton.com/resource-download.jsp?tp_GUID=DA05-M471
DS
https://www.nuvoton.com/resource-download.jsp?tp_GUID=DA00-M471VxKx
BSP
https://github.com/OpenNuvoton/M471BSP
NuMaker-M471KI相关资料链接地址如下,也可关注我们21论坛网友的相关帖子。
开发板介绍:
https://www.nuvoton.com.cn/board/numaker-m471ki/
开发板快速指南:
https://www.nuvoton.com.cn/export/resource-files/UM_NuMaker-M471KI_EN_Rev1.00.pdf
|