当前位置:网站首页>Stm32mp1 cortex M4 Development Chapter 11: expansion board buzzer control

Stm32mp1 cortex M4 Development Chapter 11: expansion board buzzer control

2022-06-21 09:13:00 Huaqing vision it open laboratory

Write it at the front :

This article is 《ARM Cortex-M4 Bare metal development 》 One in a series ,, The total of the series 14 piece . The development platform used by the author is Huaqing vision FS-MP1A Development board (STM32MP157 Development board ),Cortex-M4 In addition to talking about bare metal development M4 Outside bare metal development , Will also explain through M4 Control various sensor actuator modules on the resource expansion board ( Including air temperature and humidity sensor 、LED The lamp 、 Nixie tube 、 Buzzer 、 Vibration motor 、 Key interrupt 、 Fans, etc ), This is M4 An article in the control resource expansion board .

The resource expansion board is FS-MP1A Expansion module of development board , Mainly consists of 10 More than one kind of auxiliary mainstream sensor 、 Executive device 、 Bus control device , Very convenient for project expansion . It can expand and develop smart families 、 Intelligent medical treatment 、 Intelligent security 、 Industrial control 、 Image recognition 、 Environmental detection, etc 10 About comprehensive projects , Huaqing vision development board will also provide supporting documentation for all projects 、 Experiment source code 、 Applications and other information .

in the light of FS-MP1A Development board , except Cortex-M4 Bare metal development , There are also many other series of tutorials , Include Cortex-A7 Development of article 、FreeRTOS piece 、Linux Foundation and application development 、Linux System transplantation 、Linux Driving development 、 Hardware design 、 Artificial intelligence machine vision 、Qt Application programming 、Qt Comprehensive project practice, etc . Welcome to your attention , more stm32mp157 Develop tutorials and videos , Technical exchange can be added Q Group 459754978, Thank you for attention .

FS-MP1A Development board details : TaoBao - Amoy ! I like

Catalog

1.  Introduction to resource expansion board

1.1.  Hardware introduction

1.1.  Resource expansion board developable project

2. Expansion board buzzer control

2.1 Experimental principle

2.2. The experiment purpose

2.3. Experimental environment

2.4. The experimental steps


1.  Introduction to resource expansion board

1.1.  Hardware introduction

1.1.  Resource expansion board developable project

2. Expansion board buzzer control

2.1 Experimental principle

Open the schematic diagram of the expansion board. By comparing the expansion board, you can see that the expansion board has 1 A buzzer SP1, Here's the picture :

As can be seen from the above figure, through TIM4_CH1 The level changes the on-off of the control circuit to drive the buzzer .

Comparison diagram of interface between expansion board and backplane

See the schematic diagram TIM4_CH1 Corresponding PB6, Check the chip manual PB6 It can be used as PWM TIMER4 The passage of 1 Use , This article implements how to pass PWM Drive the buzzer :

Schematic network number Corresponding pin Pin function Pin function code
TIM4_CH1PB6TIM4_CH1AF2

2.2. The experiment purpose

Understand the working principle of buzzer

Study TIM in PWM How to use , Master how to use STM32MP157A Chip output PWM Wave control buzzer

2.3. Experimental environment

FS-MP1A Development platform

ST-Link Emulator

STM32CubeIDE Development software

PC machine XP、Window7/10 (32/64bit)

2.4. The experimental steps

MX To configure

According to the schematic diagram , To configure PB6 The pin is set to TIM4_CH1. Switch to TIM4 label , Check to “M4”,“Channel1” choice “PWM Generation CH1”, All configurations are shown in the figure below .

The above is the configuration process of new projects , May refer to 12.3.2 Chapter to import the existing project , Project storage path 【 Huaqing vision -FS-MP1A Development of information \02- Program source code \ARM Architecture and interface technology \Cortex-M4\10_EX_PWM_BEEP】

Code design

Find the created project , open main.c, Perfect timer interrupt callback function , In this function , Use “__HAL_TIM_SET_COMPARE()” Registers can be modified CCR, Achieve different duty cycles .

Interrupt the timer to start the function “HAL_TIM_Base_Start_IT()” And timers PWM Output start function “HAL_TIM_PWM_Start()” Put it all together .

Last main function call “TIM_PWM_Start()” You can start TIM interrupt , By changing pulse The value of can output different duty cycles PWM, The buzzer can be controlled to emit sounds of different frequencies .

Hardware platform : Huaqing vision FS-MP1A Development board (STM32MP157)

Download some development tutorials : Add QQ Group 459754978, There are in the group file .

Watch some video courses : Personal space of Huaqing vision R & D Center _ Bili, Bili _Bilibili

Taobao purchase link : Huaqing vision stm32mp157 linux Development board stm32 Single chip microcomputer arm Develop embedded learning board

Mobile Taobao sharing code : Copy the text of this line and open hand Amoy ₤T4FPXn3YYJ2₤

原网站

版权声明
本文为[Huaqing vision it open laboratory]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206210908576778.html

随机推荐