Answer:
Refer to: STM32 Development – Introduction to STM32The cores are different: F1 is Cortex-M3, F4 is Cortex-M4; Different clock frequencies: F1 has a clock frequency of 72MHz, F4 has 168MHz; Floating point operations: F1 has no floating-point unit, F4 has one; Functional performance: F4 peripherals are richer and more powerful than F1, such as GPIO toggle rate, pull-up and pull-down resistor configurations, ADC accuracy, etc.; Memory size: F1 has a maximum of 64K internal SRAM, while F4 has 192K (112+64+16).
Answer:
Refer to: STM32 Development – Startup ProcessSet initial address via the Boot pin, initialize stack pointer __initial_sp pointing to the reset program Reset_Handler, set exception interrupt HardFault_Handler, set system clock SystemInit, call C library function _main
Answer:
Refer to: STM32 Development – Detailed Explanation of GPIOGPIO has 8 working modes (gpio_init.GPIO_Mode): (1) GPIO_Mode_AIN Analog Input (2) GPIO_Mode_IN_FLOATING Floating Input (3) GPIO_Mode_IPD Pull-down Input (4) GPIO_Mode_IPU Pull-up Input (5) GPIO_Mode_Out_OD Open Drain Output (6) GPIO_Mode_Out_PP Push-pull Output (7) GPIO_Mode_AF_OD Alternate Function Open Drain Output (8) GPIO_Mode_AF_PP Alternate Function Push-pull Output
APB2 is responsible for AD, I/O, advanced TIM, UART 1.APB1 is responsible for DA, USB, SPI, I2C, CAN, UART 2345, general TIM, PWR
GPIO block diagram analysis:Refer to: STM32-GPIO Detailed Explanation
-
Question 1: Introduction to serial communication methods? Synchronous communication: I2C half-duplex, SPI full-duplex; Asynchronous communication: RS485 half-duplex, RS232 full-duplex
-
Question 2: UART configuration? The general steps for UART configuration can be summarized as follows: (1) Enable UART clock, enable GPIO clock (2) Reset UART (3) Set GPIO port mode TX GPIO working mode: GPIO_Mode_AF_PP; // Alternate Function Push-pull Output RX GPIO working mode: GPIO_Mode_IN_FLOATING; // Floating Input (4) UART parameter initialization mainly includes: baud rate setting (115200), 8 data bits, 1 stop bit, no parity, no hardware flow control, transmit and receive mode. (5) Enable interrupts and initialize NVIC (this step is only needed if interrupts are to be enabled) (6) Enable UART (7) Write interrupt handler
-
Question 3: Main features of USART? (1) Full-duplex operation (independent reception and transmission of data); (2) In synchronous operation, can synchronize the master clock or slave clock; (3) Independent high-precision baud rate generator, does not occupy timer/counter; (4) Supports 5, 6, 7, 8, and 9 data bits, 1 or 2 stop bits serial data frame structure; (5) Hardware-supported parity bit generation and checking; (6) Data overflow detection; (7) Frame error detection; (8) Noise filter and digital low-pass filter including detection of erroneous start bits; (9) Three completely independent interrupts, TX transmission complete, TX data register empty, RX reception complete; (10) Supports multi-master communication mode; (11) Supports double-speed asynchronous communication mode.
Answer:
Refer to: STM32 Development – Detailed Explanation of Serial PortApplication scenarios: GPS, Bluetooth, 4G modules
-
Question 1: What are the three types of signals in the I2C bus during data transmission? (1) Start signal: When SCL is high, SDA transitions from high to low to start data transmission. (2) Stop signal: When SCL is high, SDA transitions from low to high to end data transmission. (3) Acknowledge signal: The receiving IC sends a specific low pulse to the transmitting IC after receiving 8 bits of data, indicating that the data has been received. The CPU sends a signal to the controlled unit and waits for an acknowledgment signal from the controlled unit. After receiving the acknowledgment signal, the CPU decides whether to continue transmitting signals based on the actual situation. If no acknowledgment signal is received, it is judged that the controlled unit has failed.
-
Question 2: How to configure the I2C master mode port? Hardware mode: Alternate function open-drain output, neither pull-up nor pull-down. (Fast mode: 400 Kbit/s) Software simulation: Push-pull output, configure pull-up resistor.
-
Question 3: I2C arbitration mechanism? Refer to: S5PV210 Development – How Much Do You Know About I2C? (3) The I2C arbitration mechanism is straightforward once you understand the wired-AND principle. Simply put, it follows the principle of “low level priority”, meaning whoever sends a low level first will gain control of the bus.
Answer:
Refer to: STM32 Development – PMIC, I2C Detailed ExplanationHardware mode: Communication speed setting: /* STM32 I2C Fast Mode */#define I2C_Speed 400000
/* Communication speed */I2C_InitStructure.I2C_ClockSpeed = I2C_Speed;
Software simulation: If no communication speed is set, how to calculate it?Through the I2C bus bit delay function i2c_Delay:
static void i2c_Delay(void)
{
uint8_t i;
/*
The following time is obtained through the Anfu Lai AX-Pro logic analyzer test.
When the CPU main frequency is 72MHz, running in internal Flash, MDK project not optimized
When the loop count is 10, SCL frequency = 205KHz
When the loop count is 7, SCL frequency = 347KHz, SCL high level time 1.5us, SCL low level time 2.87us
When the loop count is 5, SCL frequency = 421KHz, SCL high level time 1.25us, SCL low level time 2.375us
IAR project compilation efficiency is high, cannot be set to 7
*/
for (i = 0; i < 10; i++);
}
Application scenarios: PMIC, accelerometer, gyroscope
-
Question 1: How many lines does SPI need? The SPI interface generally uses 4 lines for communication: MISO master device data input, slave device data output. MOSI master device data output, slave device data input. SCLK clock signal, generated by the master device. CS slave device chip select signal, controlled by the master device.
-
Question 2: What are the four modes of SPI communication? SPI has four working modes, which differ in SCLK, specifically determined by CPOL and CPHA. (1) CPOL: (Clock Polarity), clock polarity: SPI’s CPOL indicates whether the level of SCLK is low (0) or high (1) when idle: CPOL=0 means idle is low, so when SCLK is active, it is high (active-high); CPOL=1 means idle is high, so when SCLK is active, it is low (active-low);
(2) CPHA:(Clock Phase), clock phase: The phase corresponds to the data sampling on which edge (first or second), 0 corresponds to the first edge, 1 corresponds to the second edge. For: CPHA=0, it indicates the first edge: for CPOL=0, idle is low, the first edge is from low to high, so it is the rising edge; for CPOL=1, idle is high, the first edge is from high to low, so it is the falling edge; CPHA=1 indicates the second edge: for CPOL=0, idle is low, the second edge is from high to low, so it is the falling edge; for CPOL=1, idle is high, the first edge is from low to high, so it is the rising edge;
-
Question 3: How to determine which mode to use? (1) First confirm the SCLK polarity required by the slave, whether it is low or high when not working, thus confirming CPOL as 0 or 1. Looking at the schematic, we set the idle state of the serial synchronous clock to high, so we choose SPI_CPOL_High. That is, CPOL is 1 (2) Then confirm from the slave chip datasheet’s timing diagram whether the slave chip samples data on the falling or rising edge of SCLK. Translate: W25Q32JV accesses via the SPI compatible bus, which includes four signals: serial clock (CLK), chip select (/CS), serial data input (DI), and serial data output (DO). The standard SPI instruction uses the DI input pin to serially write instructions, addresses, or data to the device on the rising edge of CLK. The DO output pin is used to read data or status from the device on the falling edge of CLK. Supports SPI bus operations in mode 0 (0,0) and 3 (1,1). Modes 0 and 3 concern the normal state of the CLK signal when the SPI bus master is in standby and no data is being transmitted to the serial Flash. For mode 0, the CLK signal is typically low at the falling and rising edges / CS. For mode 3, the CLK signal is typically high at the falling and rising edges of /CS. Since the idle state of the serial synchronous clock is high, we choose the second edge transition, thus selecting SPI_CPHA_2Edge. That is, CPHA is 1 namely, we choose mode 3 (1,1).
Answer:
Refer to: STM32 Development – Detailed Explanation of W25Q32JV SPI FlashRefer to: Detailed Explanation of CPOL and CPHA in SPIApplication scenarios: SPI Flash, W25Q32 memory capacity 32Mb (4M x 8), i.e., 4M byte
-
Question 1: Summarize CAN? The CAN controller determines the bus level based on the voltage difference between CAN_L and CAN_H. The bus level is divided into dominant and recessive levels, one of which is sent by the sender by changing the bus level to send messages to the receiver.
-
Question 2: Steps to initialize CAN configuration? (1) Configure the multiplexing function of the relevant pins, enable the CAN clock (2) Set the CAN operating mode and baud rate, etc. (CAN initialization loopback mode, baud rate 500Kbps) (3) Set the filter
-
Question 3: CAN data transmission format? CanTxMsg TxMessage; TxMessage.StdId=0x12; // Standard Identifier TxMessage.ExtId=0x12; // Set extended identifier TxMessage.IDE=CAN_Id_Standard; // Standard frame TxMessage.RTR=CAN_RTR_Data; // Data frame TxMessage.DLC=len; // Data length to be sent Send 8 bytes for(i=0;i<len;i++) TxMessage.Data[i]=msg[i]; // data
Answer:
Refer to: STM32 Development – Detailed Explanation of CAN Bus
-
Question 1: What is DMA? Direct Memory Access (DMA) is used to provide high-speed data transfer between peripherals and memory or between memory and memory. Data can move quickly through DMA without CPU intervention, saving CPU resources for other operations.
-
Question 2: How many DMA transfer modes are there? DMA_Mode_Circular Circular mode DMA_Mode_Normal Normal buffer mode Application scenarios: GPS, Bluetooth, both use circular acquisition, DMA_Mode_Circular mode.
Answer:
Refer to: STM32 Development – Detailed Explanation of DMA
A relatively important function, obtaining the current remaining data size, based on the set receive buffer size minus the current remaining data size, to get the current received data size.
-
Question 1: Describe the interrupt handling process? (1) Initialize the interrupt, set the trigger method to rising edge/falling edge/both edges. (2) Trigger the interrupt, enter the interrupt service function
-
Question 2: How many external interrupts does STM32’s interrupt controller support? STM32’s interrupt controller supports 19 external interrupt/event requests: From the diagram, GPIO pins GPIOx.0~GPIOx.15 (x=A, B, C, D, E, F, G) correspond to interrupt lines 0 ~ 15. Additionally, the four EXTI lines are connected as follows: ● EXTI line 16 connects to PVD output ● EXTI line 17 connects to RTC alarm event ● EXTI line 18 connects to USB wakeup event ● EXTI line 19 connects to Ethernet wakeup event (only for interconnect products) Interrupt service function list: IO external interrupts in the interrupt vector table only allocate 7 interrupt vectors, meaning only 7 interrupt service functions can be used. EXTI0_IRQHandler EXTI1_IRQHandler EXTI2_IRQHandler EXTI3_IRQHandler EXTI4_IRQHandler EXTI9_5_IRQHandler EXTI15_10_IRQHandler
Answer:
Refer to: STM32 Development – Detailed Explanation of External Interrupts
STM32 has 5 clock sources: HSI, HSE, LSI, LSE, PLL. ① HSI is a high-speed internal clock, RC oscillator, frequency is 8MHz, accuracy is not high. ② HSE is a high-speed external clock, can connect quartz/ceramic resonators, or connect external clock sources, frequency range is 4MHz~16MHz. ③ LSI is a low-speed internal clock, RC oscillator, frequency is 40kHz, providing low-power clock. ④ LSE is a low-speed external clock, connected to a quartz crystal with a frequency of 32.768kHz. ⑤ PLL is a phase-locked loop frequency multiplier output, whose clock input source can be selected as HSI/2, HSE, or HSE/2. The frequency multiplier can be selected from 2 to 16 times, but the maximum output frequency must not exceed 72MHz.
Answer:
Refer to: STM32 Development – Detailed Explanation of Clock System
Answer:
A task, also called a thread. UCOS has a task scheduling mechanism, scheduled based on the priority of tasks. One is hardware interrupts, where the system pushes the current task-related variables onto the stack and then executes the interrupt service program, returning after completion. The other is switching between tasks, which uses task scheduling; each task has its own stack, and the same principle applies, pushing onto the stack, then executing another program, and then popping back.
Not every task is executed in order of priority; rather, high-priority tasks run exclusively unless they voluntarily yield, otherwise low-priority tasks cannot preempt them, while high-priority tasks can reclaim CPU occupancy previously yielded to low-priority tasks. Therefore, ucOS tasks need to include wait delays so that ucOS can switch out to allow low-priority tasks to execute.
Answer:
In UCOSII, communication between tasks is achieved using semaphores, mailboxes (message mailboxes), and message queues, which are referred to as events, along with global variables.Semaphores: Refer to: UCOSII Semaphore Usage Summary (Illustrative Explanation) Semaphores are used to: 1. Control the usage rights of shared resources (satisfying mutual exclusion conditions) 2. Indicate the occurrence of a certain time 3. Synchronize the behavior of two tasks
Application example: The mutex semaphore serves as a mutual exclusion condition, initialized to 1. The goal is to call the serial port to send a command and must wait for the return “OK” character before sending the next command. Each task may use this sending function, and conflicts must be avoided!
Mailbox (message mailbox):
Message queue: Concept: (1) A message queue is essentially an array of mailboxes. (2) Both tasks and interrupts can put a message into the queue, and tasks can retrieve messages from the message queue. (3) Messages that enter the queue first are sent to tasks first (FIFO). (4) Each message queue has a waiting list of tasks waiting for messages; if there are no messages in the queue, the waiting tasks are suspended until messages arrive.
Application scenario: Receive buffer in the serial port receiving program. Store external events.
Answer:
Understand the Modbus protocol. Structure: Frame header (SDTC) + Frame length + Command + Serial number + Data + CRC check.
Answer:
μC/OS-II is designed specifically for embedded applications, μC/OS-II has high execution efficiency, small footprint, excellent real-time performance, and strong scalability; the minimum kernel can be compiled to 2KB. μC/OS-II has been ported to almost all well-known CPUs. Linux is free, secure, stable, and widely applicable, used in embedded systems, servers, and personal computers. Both μC/OS-II and Linux are suitable for embedded systems. However, μC/OS-II is specifically designed for embedded systems, resulting in higher operational efficiency and lower resource usage. Linux can be used as a server, with high usage. Although Linux was not specifically developed for servers, its open-source code can be modified, making the differences between the two not significant; the main distribution Red Hat Linux is widely used on servers.
Question: Git submission process?
Answer:
1. Display modified files in the working path:
$ git status
2. Enter the modified file directory:
$ cd -
3. Show differences from the last submitted version:
$ git diff
4. Add all current modifications to the next submission:
$ git add .
5. Add relevant functionality description (use this for the first submission)
$ git commit -s
Also, note: Function: Modify the functionality of the code Ticket: Corresponding Bug number Note: Each folder must be submitted once again. 6. Check the submitted code
$ tig .
7. Do not modify published submission records! (Use this for future submissions)
$ git commit --amend
In command mode: 😡 (write file and exit) 8. Push to the server
$ git push origin HEAD:refs/for/master
-
Question 1: Comparison of the three?
Answer:
Comparison of ucosii and freeRTOS: (1) freeRTOS only supports TCP/IP, while uCOSii has extensive support for peripherals like FS, USB, GUI, CAN, etc. (We chose uCOSii for our tbox which requires CAN) (2) freeRTOS is free for commercial use, while uCOSii requires payment for commercial applications. (3) Communication between tasks: freeRTOS only supports queues, semaphores, and mutexes. uCOSii supports all of these plus event flags, mailboxes. (4) Theoretically, freeRTOS can manage more than 64 tasks, while uCOSii can only manage 64.
Comparison of ucosii and ucosiii: From μC/OS-II to μC/OS-III, what are the differences? A significant change is that there were originally only 0~63 priority levels, and these could not be repeated; now it allows multiple tasks to use the same priority level, and within the same priority level, it supports time-slicing scheduling; secondly, it allows users to dynamically configure real-time operating system kernel resources during program execution, such as tasks, task stacks, semaphores, event flags, message queues, message counts, mutex semaphores, memory block divisions, and timers, which can be changed during program execution. This way, users can avoid resource allocation issues during program compilation. Improvements have also been made in resource reuse. In μC/OS-II, the maximum number of tasks is 64, while from version 2.82 onwards, it is 256. In μC/OS-III, users can have any number of tasks, semaphores, mutex semaphores, event flags, message lists, timers, and any allocated memory block capacity, limited only by the RAM available on the user’s CPU. This is a significant expansion. (Question: Teacher Shao, is this number fixed at startup, or can it be defined later?) It can be freely defined at configuration time, as long as your RAM is sufficient. The fourth point is that many functions have been added, and the functionality is always increasing; you can take a look at this.
-
Question 1: How many types of low power modes are there? What are the wake-up methods?
Answer:
-
Question 1: How many layers are there in the architecture of the Internet of Things? What functions does each layer perform?
Answer:
Divided into three layers, the Internet of Things architecture can be divided into the perception layer, network layer, and application layer. (1) Perception layer: Responsible for information collection and transmission between things, information collection technologies include sensors, barcodes, QR codes, RFID technology, audio and video, and other multimedia information; information transmission includes short and long-distance data transmission technologies, self-organizing networking technologies, collaborative information processing technologies, middleware technologies for information collection, etc. The perception layer is the core capability for comprehensive perception of the Internet of Things, which includes key technologies, standardization, and industrialization aspects that urgently need breakthroughs, focusing on having more precise and comprehensive perception capabilities and solving issues of low power consumption, miniaturization, and low cost. (2)Network layer: Utilizes wireless and wired networks to encode, authenticate, and transmit collected data. The widely covered mobile communication network is the infrastructure for realizing the Internet of Things, which is the most standardized, industrialized, and mature part of the three layers of the Internet of Things, focusing on optimizing and improving the application characteristics of the Internet of Things, forming a collaborative perception network. (3)Application layer: Provides rich applications based on the Internet of Things, which is the fundamental goal of the Internet of Things development, combining Internet of Things technology with industry information needs to realize a collection of widely intelligent applications, focusing on industry integration, development and utilization of information resources, low-cost high-quality solutions, information security assurance, and effective development of business models.
-
Question 1: What methods are there for memory management in UCOS?
Answer:
The system manages memory partitions through memory control blocks associated with the memory partitions.
Dynamic memory management functions include: create dynamic memory partition function OSMemCreate(); request to obtain memory block function OSMemGet(); release memory block function OSMemPut();
Answer:
There are 5 states: sleep state, ready state, running state, waiting state (waiting for a certain event to occur), and interrupt service state.
The 5 state transition relationships of UCOSII tasks:
-
Question 1: Briefly describe the functional characteristics of the STM32 ADC system? (1) 12-bit resolution (2) Automatic calibration (3) Programmable data alignment (conversion results support left or right alignment stored in 16-bit data registers) (4) Single and continuous conversion modes
Refer to: STM32 Development – Detailed Explanation of ADC
-
Question 1: Briefly describe the basic process of setting the system clock? (1) Enable HSE, wait for it to be ready, then set Flash wait operations. (2) Set AHB, APB1, APB2 prescaler coefficients to determine their relationship with the system clock. (3) Set CFGR register to determine PLL clock source and multiplication factor (HSE external 8M * 9 times = 72MHz). (4) Enable PLL, switch the system clock source to PLL.
-
Question 1: What are the causes? (1) Array out-of-bounds operations; (2) Memory overflow, accessing out of bounds; (3) Stack overflow, program runaway; (4) Interrupt handling errors;
-
Question 2: How to handle it? (1) Find the address remapping of HardFault_Handler in startup_stm32f10x_cl.s and rewrite it, making it jump to the HardFaultHandle function. (2) Print to check the registers R0, R1, R2, R3, R12, LR, PC, PSR. (3) Check the Fault status register group (SCB->CFSR and SCB->HFSR)
Refer to: STM32 Development – HardFault_Handler Handling Refer to: Cortex-M3 and Cortex-M4 Fault Exception Applications – Basic Knowledge
-
Question 1: What method does sim7600 TTS speech use?
Answer:
(1) Use unicode encoding to synthesize voice AT+CTTS=1,”6B228FCE4F7F75288BED97F3540862107CFB7EDF” The content is “Welcome to the voice synthesis system”, the module sends and receives Chinese SMS using unicode encoding, so it is easy to read SMS aloud; (2) Directly input text, ordinary characters use ASCII code, Chinese characters use GBK encoding. AT+CTTS=2,”Welcome to the voice synthesis system”
-
Question 1: Given that the STM32 system clock is 72MHz, how to set the relevant registers to achieve a 20ms timer?
Answer:
Refer to: STM32 Development – Systick Timer By SysTick_Config(SystemCoreClock / OS_TICKS_PER_SEC)) // 1ms timer
Where:
uint32_t SystemCoreClock = SYSCLK_FREQ_72MHz; /*!< System Clock Frequency (Core Clock) */
#define SYSCLK_FREQ_72MHz 72000000
#define OS_TICKS_PER_SEC 1000 /* Set the number of ticks in one second
If 20ms is needed, a global variable can be set, initialized to 20, so that each time the SysTick interrupts, this global variable reduces by 1, until it reaches 0, meaning the SysTick interrupts 20 times, totaling 20ms. Thus, a 20ms timer is achieved.
-
Question 1: How to run if there are two tasks with the same priority?
Answer:
Make the priority of the task obtaining the semaphore temporarily elevated to one level higher than the highest priority of all tasks during the use of shared resources, so that this task is not interrupted by other tasks, allowing it to quickly use and release the shared resources, and then restore the task to its original priority level after releasing the semaphore.
-
Question 1: What state machine is used?
Answer:
Refer to: STM32 Development – State Machine and State Transition Logic
Finite State Machine (FSM), also known as finite state automaton, abbreviated as state machine.Refer to: Detailed Explanation and Implementation of Finite State Machine FSM
Assuming the state transitions of the state machine are shown in the table below:
Implementation: (using switch statements)
// Write horizontally
void event0func(void)
{
switch(cur_state)
{
case State0:
action0;
cur_state = State1;
break;
case State1:
action1;
cur_state = State2;
break;
case State2:
action1;
cur_state = State0;
break;
default:break;
}
}
void event1func(void)
{
switch(cur_state)
{
case State0:
action4;
cur_state = State1;
break;
default:break;
}
}
void event2func(void)
{
switch(cur_state)
{
case State0:
action5;
cur_state = State2;
break;
case State1:
action6;
cur_state = State0;
break;
default:break;
}
}
-
Question 1: Comparison of STM32F407 and STM32F103 main functions and resources?
Answer:
Refer to: Comparison of STM32F407 and STM32F103 Main Functions and Resources
Statement:
This account maintains neutrality regarding all original and reprinted articles’ statements and viewpoints; the articles are only for readers’ learning and communication. The copyrights of articles, images, etc., are owned by the original authors; if there is any infringement, please contact for deletion.


【Tutorial】 Electromagnetic Compatibility
【Tutorial】 Principles and Applications of Microcontrollers
【Data】 20 Smart Home System Design Materials
【Data】 400+ Animated Electronic Circuit Courseware + 147G Hardware Design and Development Video Materials
【Data】 100+ Switching Power Supply Design Materials
【Data】 800+ Microcontroller Design Materials, Mastering Microcontroller Circuit Design~
【Data】 10G+ AD Packaging Library Files, Meeting 99% of Your Development Needs!
【Data】 60+ Inverter Power Supply Materials, Supporting New Energy Application Development

