1. Unboxing
On the eve of the Spring Festival, I received the N32A455 development board with the National Technology automotive MCU on board! A development board, a MiniUSB data cable...
2. Preparation
2.1. Download development materials:
- Download the development board related information from ftp://download.nationstech.com: N32A455xx_V1.2.0.zip under ftp://download.nationstech.com/2-Automotive-Grade MCU/
- Go to https://www.nationstech.com/zlxz455/ to download the relevant information.
- Download the official information through the evaluation activity link
- Um... I still recommend downloading from the FTP server, which is updated more timely. The current version that can be downloaded from the official website is version 1.1, and the latest version of the FTP server is 1.2
2.2. Install KEIL integrated development environment chip support package
In the N32A455xx_V1.2.0\6-Software Development Kit directory, double-click Nationstech.N32A455_DFP.1.0.0.pack to install:
3. Get familiar with onboard functions
The development board model we evaluated this time is N32A455VEL7-EVB, so the corresponding schematic is N32A455xx_V1.2.0\5-Hardware Evaulation Board\N32A455VEL7-EVB_V1.1.pdf. According to the N32A455VEL7-EVB development board hardware user guide, the functions of the development board are as follows:
- Power supply mode of the development board: 12V power supply through the DC socket, 5V power supply through the MiniUSB interface
- Onboard NSLINK program download and debugging tool, supports JTAG and SWD connection methods, and also has a virtual serial port
- Support 2-way CAN and 2-way LIN
- Support TF card, SDIO interface
- Onboard VS1053B audio circuit
- Onboard EEPROM
- Onboard SPI FLASH and QSPI FLASH
- Onboard 5 mechanical buttons, 1 reset button, 1 wake-up button, 3 function buttons
- Onboard three-color LED light, adjustable resistor with ADC function
- All the pins of the chip are led out through the pin header
4. Basic Engineering
The official sample programs are stored in the N32A455xx_V1.2.0\6-Software Development Kit\Nationstech.N32A455_Library.1.1.0 directory. The driver library programs are stored in the firmware folder, and the sample programs based on the development board are stored in the projects\n32a455_EVAL folder. We refer to the examples\GPIO\LedBlink sample program, examples\GPIO\LedBlink sample program, and examples\USART\Printf sample program to create a new basic project.
4.1. Create a project: Project name->Select chip model->OK
4.2. Add project source code: startup program, CMSIS, driver library, user program
4.3.Configure the project
4.4. Programming
#ifndef __MAIN_H__
#define __MAIN_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdio.h>
#include "n32a455.h"
/* PA11_RLED */
#define RLED_RCC RCC_APB2_PERIPH_GPIOA
#define RLED_GPIO GPIOA
#define RLED_PIN GPIO_PIN_11
/* PB10_BLED */
#define BLED_RCC RCC_APB2_PERIPH_GPIOB
#define BLED_GPIO GPIOB
#define BLED_PIN GPIO_PIN_10
/* PA12_GLED */
#define GLED_RCC RCC_APB2_PERIPH_GPIOA
#define GLED_GPIO GPIOA
#define GLED_PIN GPIO_PIN_12
/* PD12_KEY */
#define S3_RCC RCC_APB2_PERIPH_GPIOD
#define S3_GPIO GPIOD
#define S3_PIN GPIO_PIN_12
/* PC6_KEY */
#define S4_RCC RCC_APB2_PERIPH_GPIOC
#define S4_GPIO GPIOC
#define S4_PIN GPIO_PIN_6
/* PC7_KEY */
#define S5_RCC RCC_APB2_PERIPH_GPIOC
#define S5_GPIO GPIOC
#define S5_PIN GPIO_PIN_7
#ifdef __cplusplus
}
#endif
#endif
#include "main.h"
void LED_Init(void)
{
GPIO_InitType GPIO_InitStructure;
RCC_EnableAPB2PeriphClk(RLED_RCC, ENABLE);
GPIO_InitStruct(&GPIO_InitStructure);
GPIO_InitStructure.Pin = RLED_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitPeripheral(RLED_GPIO, &GPIO_InitStructure);
GPIO_WriteBit(RLED_GPIO, RLED_PIN, Bit_SET);
RCC_EnableAPB2PeriphClk(BLED_RCC, ENABLE);
GPIO_InitStruct(&GPIO_InitStructure);
GPIO_InitStructure.Pin = BLED_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitPeripheral(BLED_GPIO, &GPIO_InitStructure);
GPIO_WriteBit(BLED_GPIO, BLED_PIN, Bit_SET);
RCC_EnableAPB2PeriphClk(GLED_RCC, ENABLE);
GPIO_InitStruct(&GPIO_InitStructure);
GPIO_InitStructure.Pin = GLED_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitPeripheral(GLED_GPIO, &GPIO_InitStructure);
GPIO_WriteBit(GLED_GPIO, GLED_PIN, Bit_SET);
}
void LED_ON(GPIO_Module *GPIOn, uint16_t PINn)
{
GPIO_WriteBit(GPIOn, PINn, Bit_RESET);
}
void LED_OFF(GPIO_Module *GPIOn, uint16_t PINn)
{
GPIO_WriteBit(GPIOn, PINn, Bit_SET);
}
void LED_Toggle(GPIO_Module *GPIOn, uint16_t PINn)
{
if (GPIO_ReadOutputDataBit(GPIOn, PINn) == Bit_RESET)
{
GPIO_WriteBit(GPIOn, PINn, Bit_SET);
}
else
{
GPIO_WriteBit(GPIOn, PINn, Bit_RESET);
}
}
void KEY_Init(void)
{
GPIO_InitType GPIO_InitStructure;
RCC_EnableAPB2PeriphClk(S3_RCC, ENABLE);
GPIO_InitStruct(&GPIO_InitStructure);
GPIO_InitStructure.Pin = S3_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitPeripheral(S3_GPIO, &GPIO_InitStructure);
RCC_EnableAPB2PeriphClk(S4_RCC, ENABLE);
GPIO_InitStruct(&GPIO_InitStructure);
GPIO_InitStructure.Pin = S4_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitPeripheral(S4_GPIO, &GPIO_InitStructure);
RCC_EnableAPB2PeriphClk(S5_RCC, ENABLE);
GPIO_InitStruct(&GPIO_InitStructure);
GPIO_InitStructure.Pin = S5_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitPeripheral(S5_GPIO, &GPIO_InitStructure);
}
void USART_Configuration(void)
{
GPIO_InitType GPIO_InitStructure;
USART_InitType USART_InitStructure;
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA | RCC_APB2_PERIPH_AFIO, ENABLE);
GPIO_InitStruct(&GPIO_InitStructure);
GPIO_InitStructure.Pin = GPIO_PIN_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitPeripheral(GPIOA, &GPIO_InitStructure);
RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_USART1, ENABLE);
USART_StructInit(&USART_InitStructure);
USART_InitStructure.BaudRate = 115200;
USART_InitStructure.WordLength = USART_WL_8B;
USART_InitStructure.StopBits = USART_STPB_1;
USART_InitStructure.Parity = USART_PE_NO;
USART_InitStructure.Mode = USART_MODE_TX;
USART_InitStructure.HardwareFlowControl = USART_HFCTRL_NONE;
USART_Init(USART1, &USART_InitStructure);
USART_Enable(USART1, ENABLE);
}
int main(void)
{
LED_Init();
KEY_Init();
USART_Configuration();
printf("\r\nN32A455VEL7-EVB V1.1 %s %s", __DATE__, __TIME__);
while (1)
{
GPIO_WriteBit(RLED_GPIO, RLED_PIN, GPIO_ReadInputDataBit(S3_GPIO, S3_PIN));
GPIO_WriteBit(BLED_GPIO, BLED_PIN, GPIO_ReadInputDataBit(S4_GPIO, S4_PIN));
GPIO_WriteBit(GLED_GPIO, GLED_PIN, GPIO_ReadInputDataBit(S5_GPIO, S5_PIN));
}
}
int fputc(int ch, FILE* f)
{
USART_SendData(USART1, (uint8_t)ch);
while (USART_GetFlagStatus(USART1, USART_FLAG_TXDE) == RESET);
return (ch);
}
5. Compile and run
5.1. Printing Output
5.2. Run the video
15
6. Attachments