This post was last edited by 805721366 on 2022-6-26 14:27
Thank you for being selected to evaluate the National Technology low-power N32L43x series chip development board
The N32L43x series uses a 32-bit ARM Cortex-M4 core with a maximum main frequency of 108MHz, supports floating-point operations and DSP instructions, integrates up to 128KB embedded encryption FLash, 32KB SRAM, integrates low-power peripherals for flow measurement, and rich high-performance analog devices. It has a built-in 12-bit 5Msps ADC, 2 independent rail-to-rail operational amplifiers, 2 high-speed comparators, and a 1Msps 12-bit DAC. It supports up to 24 channels of capacitive touch buttons, integrates up to 320 segments of Segment LCD drivers, integrates multiple U(S)ART, I2C, SPI, USB, CAN and other digital communication interfaces, and has a built-in cryptographic algorithm hardware acceleration engine.
1. Preliminary preparation
Download the official FTP database: Use the file explorer to enter ftp://58.250.18.138 anonymous user login, no password
Install the chip Keil support package
Pack Installer -> File -> Import... Select the support package Nationstech.N32L43x_DFP.0.1.0.pack to install
After successful installation
2. Create a new test project
Set Options for Target and select N32L436RB as the chip model
Check Create HEX File
Add .h header file path
Select the emulator model
The project is as follows
3. PWM initialization
Set LED2 drive pin PB4 to PWM output, PWM period 400us
PWM initialization code
/**
* @brief PWM初始化
*/
void hal_pwmInit(void)
{
GPIO_InitType GPIO_InitStructure;
TIM_TimeBaseInitType TIM_TimeBaseStructure;
OCInitType TIM_OCInitStructure;
/* TIM3 clock enable */
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM3, ENABLE);
/* GPIOB clock enable */
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOB | RCC_APB2_PERIPH_AFIO, ENABLE);
GPIO_InitStruct(&GPIO_InitStructure);
GPIO_InitStructure.Pin = LED2_PIN;
GPIO_InitStructure.GPIO_Current = GPIO_DC_4mA;
//GPIO_InitStructure.GPIO_Pull = GPIO_No_Pull;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Alternate = GPIO_AF2_TIM3;
GPIO_InitPeripheral(LED2_PORT, &GPIO_InitStructure);
//GPIO_ResetBits(LED2_PORT, LED2_PIN);
/* Time base configuration */
TIM_TimeBaseStructure.Prescaler = 108-1; //分频值108 108MHz/108 = 1MHz 1us
TIM_TimeBaseStructure.Period = 400-1; //周期值400,定时周期400*1us = 400us
TIM_TimeBaseStructure.CntMode = TIM_CNT_MODE_UP;
TIM_TimeBaseStructure.ClkDiv = 0;
TIM_InitTimeBase(TIM3, &TIM_TimeBaseStructure);
/* PWM1 Mode configuration: Channel1 */
TIM_OCInitStructure.OcMode = TIM_OCMODE_PWM1;
TIM_OCInitStructure.OutputState = TIM_OUTPUT_STATE_ENABLE;
TIM_OCInitStructure.OcPolarity = TIM_OC_POLARITY_HIGH;
TIM_OCInitStructure.Pulse = 0;
TIM_InitOc1(TIM3, &TIM_OCInitStructure);
//使能预装载寄存器
TIM_ConfigOc1Preload(TIM3, TIM_OC_PRE_LOAD_ENABLE);
//使能自动重装载的预装载寄存器允许位
TIM_ConfigArPreload(TIM3, ENABLE);
/* TIM3 enable counter */
TIM_Enable(TIM3, ENABLE);
}
4. The effects are as follows
WeChat_20220626141907
5. Test code
N32L43_LEDBreathingtest.rar
(419.4 KB, downloads: 2)
|