[National Technology N32G457 Review] 2. Unboxing + Lighting
[Copy link]
This post was last edited by fxyc87 on 2022-1-20 13:01
Previous post: [National Technology N32G457 Review] 1. Data Preparation
Unboxing photos: development board + MINI USB cable
I have made an empty MDK template, project template.7z click here to download
Although it was lighting, I encountered many pitfalls. For example, LED2 could not light up. Later, I read the manual and found out that the pins were used.
#include "n32g45x.h"
#include "n32g45x_gpio.h"
void Delay(uint32_t ms);
static uint32_t Tick=0;
int main(){
//SystemInit(); .s中已调用,此处无需调用
SystemCoreClockUpdate();
SysTick_Config(SystemCoreClock/1000);
//开启IO时钟 GPIOA,B,afio
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA|RCC_APB2_PERIPH_GPIOB|RCC_APB2_PERIPH_AFIO,ENABLE);
//PB4默认是JW-RESET 需要用该功能,见手册101页
GPIO_ConfigPinRemap(GPIO_RMP_SW_JTAG_NO_NJTRST,ENABLE);
//初始化IO
GPIO_InitType gpio;
gpio.Pin=GPIO_PIN_5|GPIO_PIN_4; //LED3,LED2
gpio.GPIO_Mode=GPIO_Mode_Out_PP;
gpio.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitPeripheral(GPIOB,&gpio);
gpio.Pin=GPIO_PIN_8; //LED1
gpio.GPIO_Mode=GPIO_Mode_Out_PP;
gpio.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitPeripheral(GPIOA,&gpio);
//点亮指示灯
while(1){
Delay(500);
GPIO_WriteBit(GPIOA,GPIO_PIN_8,Bit_SET);
GPIO_WriteBit(GPIOB,GPIO_PIN_4,Bit_SET);
GPIO_WriteBit(GPIOB,GPIO_PIN_5,Bit_SET);
Delay(500);
GPIO_WriteBit(GPIOA,GPIO_PIN_8,Bit_RESET);
GPIO_WriteBit(GPIOB,GPIO_PIN_4,Bit_RESET);
GPIO_WriteBit(GPIOB,GPIO_PIN_5,Bit_RESET);
}
}
void Delay(uint32_t ms){
SysTick->VAL=0;
Tick=0;
while(Tick<ms);
}
void SysTick_Handler(void){
Tick++;
}
//end
Lighting Video
|