AutoChips AC7801x motor demo board review (Part 2): Development environment setup + lighting
[Copy link]
This post was last edited by my student number on 2020-11-14 16:54
The previous post completed the introduction of hardware. This post records how to build a development environment and burn a lighting code.
Mainly refer to the posts on the next forum and Jiefa's document "AC7801x Development Board Instructions Manual"
The following is described in the "AC7801x Development Board Manual":
For forum friends, there is no need to explain how to install and harmonize KEIL. Here you need to download the chip support package AutoChips.AC780x_DFP.1.0.2 from the official website of Jiefa. After downloading, double-click to open it, and the system will install it to the KEIL directory.
In KEIL, select "Project"->"open project" to run the module demo provided by Jiefa; however, those demos are equipped with another set of hardware, so I decided to build a project from scratch.
First open KEIL, select "Project"->"New uVision Project" in the menu bar, select the project path, and enter the project name
Select the target chip AC78013FDLA in the device options that appear
Check the files you want to add to the project
Click "option for target" in the upper right corner to set parameters
The chip crystal frequency is selected as 8Mhz
Output, check "Generate HEX file"
In the INCLUDE PATH of the C/C++ option, enter the following path:
At this step, let's first introduce how to download the program. This motor board has a reserved JTAG interface and also supports four-wire SWD. You can use the ST-LINK on the ST NUCLEO board to download the program. The wiring method is as follows:
Remove the two jumper caps on the NUCLEO CN2 socket, and use Dupont wires or other devices to connect PIN2 (SWCLK), PIN3 (GND), and PIN4 (SWDIO) of CN4 on the NUCLEO board to PIN9 (JTCK_SWCLK), PIN8 (GND), and PIN7 (JTMS_SWDIO) of J1 on the motor board.
Connect NUCLEO to PC via USB cable. After powering on the motor board, select ST-Link Debugger in "Debug" in "option for target".
Click setting on the right. If the connection is normal, the information of the target chip will be displayed.
In "Utilities", uncheck "Use Debug Driver" and select ST-LINK in the drop-down menu of "Use Target Driver for Flash Programing".
Click on the setting on the right, check the box before "Reset and Run", so that the chip can run automatically after each download without waiting for the reset operation
At this point, the development environment is complete. Here is a simple lighting
First, add the main.c file to the project and add the following code:
#include "ac780x.h"
#include "ac780x_gpio.h"
int main(void )
{
SystemInit(); //CLOCK Setting
InitDelay(); //Initilize Parameter used in function mdelay() and udelay()
GPIO_SetFunc(GPIOA, GPIO_PIN6, GPIO_FUN0); //set GPIO as common GPIO
GPIO_SetDir(GPIOA, GPIO_PIN6, GPIO_OUT); //set OUTPUT direction
GPIO_SetFunc(GPIOB, GPIO_PIN3, GPIO_FUN0); //set GPIO as common GPIO
GPIO_SetDir(GPIOB, GPIO_PIN3, GPIO_OUT); //set OUTPUT direction
while(1)
{
GPIO_SetPinLevel(GPIOA, GPIO_PIN6, GPIO_LEVEL_HIGH); //OUTPUT HIGH LEVEL
GPIO_SetPinLevel(GPIOB, GPIO_PIN3, GPIO_LEVEL_LOW); //OUTPUT LOW LEVEL
mdelay(1000); //DELAY 1s
GPIO_SetPinLevel(GPIOA, GPIO_PIN6, GPIO_LEVEL_LOW); //OUTPUT HIGH LEVEL
GPIO_SetPinLevel(GPIOB, GPIO_PIN3, GPIO_LEVEL_HIGH); //OUTPUT LOW LEVEL
mdelay(1000); //DELAY 1S
}
}
After the compilation is correct, it can be downloaded into the chip
For contrast, an LED light was flashed on the hand.
The effect is as follows:
|