Study STM32 summary of single chip microcomputer (msp430, c8051, etc.) general learning method

Publisher:幸福约定123Latest update time:2015-02-05 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. A board has the necessary power supply lines and the necessary simulation download and debug lines (such as J-link for STM32)
 
2. Install the development environment: keil4 (c51 or ARM series registration), it seems that there is also msp430 series. First, make sure what series the board is. IAR EWARM is (ARM series environment developed by IAR System)
 
3. Install the driver: various drivers in the software
 
4. Configure and select DEVICE in the development environment (there are many different devices registered for different series), and choose to download the debug driver
 
(1) Create a new project and save it in folder a
 
(2) Create a new file (refer to file standardization), save it in a, or copy the existing supporting files
 
(3) Add files to the project
 
5. The microcontroller has supporting Chinese information, files, and example programs
 
6. Compare the Chinese information, understand the functions of the supporting file functions, and use them (look carefully at the registers used)
 
Main() Function
 
1. Initialization function: generally there are system initialization, delay initialization, LED initialization, serial port initialization
 
2. Processing function: Do the main processing work. You can directly write the processing function without creating a new processing file.
 
File standardization: (You can refer to "STM32 Incomplete Manual")
 
1. The beginning of main() and other .c files must include the corresponding .h files
 
2. Generally, there are .c and .h files for system, delay and LED.
 
The .c file contains the corresponding processing functions, and the .h file contains various function name declarations and various macro definitions in the .c file.
 
 
 
The system file is mainly used to configure the corresponding function registers, and we mainly write the processing program.
 
How to download the program:
 
1. USB to serial port: software download, full-duplex asynchronous serial communication, USB cable connected to USB_232 to connect PL2303 (PL2303 driver needs to be installed), the data should have the corresponding download software, only a file generated by the development environment compilation (such as the .hex file generated by keil)
 
2. JTAG/Adapter: Hardware download, driver needs to be installed, select driver in Debug in Keil
 
 
 
The timer of the general microcontroller development board is used:
The program consists of two programs:
 
1.TIMER_Init() initialization program: configure system clock, enable switch, load value and other configuration registers
 
2. TIMER_IRQ() interrupt program entry: When the timer reaches the specified time, it jumps directly to the interrupt entry program operation.
 
General method for external interruption: (For details, see the external interruption experiment in the "STM32 Incomplete Manual")
 
The state change of the LED is controlled by controlling the high and low levels of the I/O port through external buttons.
 
1. Set the output mode of the I/O port (generally, the MCU I/O has several output modes: such as input/output, external interrupt, floating input, etc.), generally a pull-up resistor is required
 
2. Configure the external interrupt register and set the mapping relationship between the I/O port and the interrupt line
 
3. Configure registers and set trigger conditions, such as rising edge trigger, falling edge trigger, etc.
 
4. Configure the register bit to enable interrupts
 
5. Write an interrupt service function. When the microcontroller detects an interrupt on the I/O, it will execute the interrupt service program.
Reference address:Study STM32 summary of single chip microcomputer (msp430, c8051, etc.) general learning method

Previous article:Debounce of Buttons in MCU
Next article:Analysis of code for determining big and small ends

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号