/**
******************************************************************************
* @file stm32g4xx_hal_hrtim.c
* @author MCD Application Team
* @brief TIM HAL module driver.
* This file provides firmware functions to manage the following
* functionalities of the High Resolution Timer (HRTIM) peripheral:
* + HRTIM Initialization
* + DLL Calibration Start
* + Timer Time Base Unit Configuration
* + Simple Time Base Start/Stop
* + Simple Time Base Start/Stop Interrupt
* + Simple Time Base Start/Stop DMA Request
* + Simple Output Compare/PWM Channel Configuration
* + Simple Output Compare/PWM Channel Start/Stop Interrupt
* + Simple Output Compare/PWM Channel Start/Stop DMA Request
* + Simple Input Capture Channel Configuration
* + Simple Input Capture Channel Start/Stop Interrupt
* + Simple Input Capture Channel Start/Stop DMA Request
* + Simple One Pulse Channel Configuration
* + Simple One Pulse Channel Start/Stop Interrupt
* + HRTIM External Synchronization Configuration
* + HRTIM Burst Mode Controller Configuration
* + HRTIM Burst Mode Controller Enabling
* + HRTIM External Events Conditioning Configuration
* + HRTIM Faults Conditioning Configuration
* + HRTIM Faults Enabling
* + HRTIM ADC trigger Configuration
* + Waveform Timer Configuration
* + Waveform Event Filtering Configuration
* + Waveform Dead Time Insertion Configuration
* + Waveform Chopper Mode Configuration
* + Waveform Compare Unit Configuration
* + Waveform Capture Unit Configuration
* + Waveform Output Configuration
* + Waveform Counter Start/Stop
* + Waveform Counter Start/Stop Interrupt
* + Waveform Counter Start/Stop DMA Request
* + Waveform Output Enabling
* + Waveform Output Level Set/Get
* + Waveform Output State Get
* + Waveform Burst DMA Operation Configuration
* + Waveform Burst DMA Operation Start
* + Waveform Timer Counter Software Reset
* + Waveform Capture Software Trigger
* + Waveform Burst Mode Controller Software Trigger
* + Waveform Timer Pre-loadable Registers Update Enabling
* + Waveform Timer Pre-loadable Registers Software Update
* + Waveform Timer Delayed Protection Status Get
* + Waveform Timer Burst Status Get
* + Waveform Timer Push-Pull Status Get
* + Peripheral State Get
@verbatim
==============================================================================
##### Simple mode v.s. waveform mode #####
==============================================================================
[..] The HRTIM HAL API is split into 2 categories:
(#)Simple functions: these functions allow for using a HRTIM timer as a
general purpose timer with high resolution capabilities.
HRTIM simple modes are managed through the set of functions named
HAL_HRTIM_Simple<Function>. These functions are similar in name and usage
to the one defined for the TIM peripheral. When a HRTIM timer operates in
simple mode, only a very limited set of HRTIM features are used.
Following simple modes are proposed:
(++)Output compare mode,
(++)PWM output mode,
(++)Input capture mode,
(++)One pulse mode.
(#)Waveform functions: These functions allow taking advantage of the HRTIM
flexibility to produce numerous types of control signal. When a HRTIM timer
operates in waveform mode, all the HRTIM features are accessible without
any restriction. HRTIM waveform modes are managed through the set of
functions named HAL_HRTIM_Waveform<Function>
##### How to use this driver #####
==============================================================================
[..]
(#)Initialize the HRTIM low level resources by implementing the
HAL_HRTIM_MspInit() function:
(##)Enable the HRTIM clock source using __HRTIMx_CLK_ENABLE()
(##)Connect HRTIM pins to MCU I/Os
(+++) Enable the clock for the HRTIM GPIOs using the following
function: __HAL_RCC_GPIOx_CLK_ENABLE()
(+++) Configure these GPIO pins in Alternate Function mode using
HAL_GPIO_Init()
(##)When using DMA to control data transfer (e.g HAL_HRTIM_SimpleBaseStart_DMA())
(+++)Enable the DMAx interface clock using __DMAx_CLK_ENABLE()
(+++)Initialize the DMA handle
(+++)Associate the initialized DMA handle to the appropriate DMA
handle of the HRTIM handle using __HAL_LINKDMA()
(+++)Initialize the DMA channel using HAL_DMA_Init()
(+++)Configure the priority and enable the NVIC for the transfer
complete interrupt on the DMA channel using HAL_NVIC_SetPriority()
and HAL_NVIC_EnableIRQ()
(##)In case of using interrupt mode (e.g HAL_HRTIM_SimpleBaseStart_IT())
(+++)Configure the priority and enable the NVIC for the concerned
HRTIM interrupt using HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ()
(#)Initialize the HRTIM HAL using HAL_HRTIM_Init(). The HRTIM configuration
structure (field of the HRTIM handle) specifies which global interrupt of
whole HRTIM must be enabled (Burst mode period, System fault, Faults).
It also contains the HRTIM external synchronization configuration. HRTIM
can act as a master (generating a synchronization signal) or as a slave
(waiting for a trigger to be synchronized).
(#)Start the high resolution unit using HAL_HRTIM_DLLCalibrationStart(). DLL
calibration is executed periodically and compensate for potential voltage
and temperature drifts. DLL calibration period is specified by the
CalibrationRate argument.
(#)HRTIM timers cannot be used until the high resolution unit is ready. This
can be checked using HAL_HRTIM_PollForDLLCalibration(): this function returns
HAL_OK if DLL calibration is completed or HAL_TIMEOUT if the DLL calibration
is still going on when timeout given as argument expires. DLL calibration
can also be started in interrupt mode using HAL_HRTIM_DLLCalibrationStart_IT().
In that case an interrupt is generated when the DLL calibration is completed.
Note that as DLL calibration is executed on a periodic basis an interrupt
will be generated at the end of every DLL calibration operation
(worst case: one interrupt every 14 micro seconds !).
(#) Configure HRTIM resources shared by all HRTIM timers
(##)Burst Mode Controller:
(+++)HAL_HRTIM_BurstModeConfig(): configures the HRTIM burst mode
controller: operating mode (continuous or one-shot mode), clock
(source, prescaler) , trigger(s), period, idle duration.
(##)External Events Conditioning:
(+++)HAL_HRTIM_EventConfig(): configures the conditioning of an
external event channel: source, polarity, edge-sensitivity.
External event can be used as triggers (timer reset, input
capture, burst mode, ADC triggers, delayed protection)
They can also be used to set or reset timer outputs. Up to
10 event channels are available.
(+++)HAL_HRTIM_EventPrescalerConfig(): configures the
stm32/蓝桥杯嵌入式LCD实例
需积分: 0 142 浏览量
更新于2022-11-20
收藏 7.49MB RAR 举报
STM32是一款基于ARM Cortex-M内核的微控制器,由意法半导体(STMicroelectronics)生产,广泛应用在嵌入式系统设计中。蓝桥杯是一项全国性的电子与信息技术竞赛,旨在提升大学生在嵌入式、单片机等领域的实践能力。在蓝桥杯的竞赛中,LCD(Liquid Crystal Display)液晶显示器的使用是常见的任务之一,因为它们能够提供直观的用户界面。
LCD实例在STM32中的实现通常涉及到以下几个关键知识点:
1. **GPIO配置**:STM32与LCD的连接主要是通过GPIO引脚进行的,包括数据线和控制线。这些引脚需要被配置为推挽输出或开漏输出,并设置合适的上下拉电阻。例如,RS(寄存器选择)、RW(读写选择)、E(使能信号)以及D0-D7(数据线)等。
2. **HAL库使用**:STM32的HAL库提供了高级抽象层,简化了硬件操作。在LCD实例中,开发者需要使用HAL_GPIO_Init()函数初始化GPIO,使用HAL_Delay()函数进行延时控制,以及可能用到的HAL_SPI_Transmit()或HAL_I2C_Master_Transmit()等函数来传输数据。
3. **LCD控制器**:LCD通常有自己的控制器,如HD44780或其他类型的控制器。理解其工作原理和指令集至关重要,因为需要向LCD发送特定的命令来设置显示模式、清屏、定位光标、写入字符等。
4. **帧缓冲区**:在STM32中,可以预先在内存中创建一个帧缓冲区,将要显示的内容存储在其中,然后一次性将缓冲区内容传送到LCD,提高显示效率。
5. **时序控制**:LCD的读写操作需要精确的时序配合。例如,E信号的高低电平变化用于启动和结束读写操作,RS和RW的设置决定是读还是写,以及数据线上的数据何时稳定有效等。
6. **驱动程序开发**:为了方便使用,开发者会编写LCD驱动程序,封装上述的硬件操作。驱动程序通常包含初始化函数、写命令函数、写数据函数以及清除屏幕等常用功能。
7. **字符与图形显示**:LCD不仅可以显示ASCII字符,还可以通过点阵图形显示自定义字符或图像。这需要对字符编码和点阵字模有深入理解。
8. **中断与DMA**:在处理大量数据时,可以利用STM32的中断或DMA(直接内存访问)功能,提高数据传输速度,减轻CPU负担。
9. **电源管理**:考虑到功耗,LCD的背光控制也是需要考虑的。STM32可以调整PWM信号来调节背光亮度。
10. **调试技巧**:在开发过程中,使用示波器检查信号波形、使用逻辑分析仪查看数据传输、使用串口输出调试信息等都是有效的调试手段。
STM32在蓝桥杯嵌入式LCD实例中涉及的知识点广泛,涵盖了硬件接口设计、软件驱动编写、时序控制等多个方面,是学习嵌入式系统开发的重要实践环节。
LJ&H
- 粉丝: 30
- 资源: 1
最新资源
- 操作系统实验ucore lab3
- DG储能选址定容模型matlab 程序采用改进粒子群算法,考虑时序性得到分布式和储能的选址定容模型,程序运行可靠 这段程序是一个改进的粒子群算法,主要用于解决电力系统中的优化问题 下面我将对程序进行详
- final_work_job1(1).sql
- 区块链与联邦学习结合:FedChain项目详细复现指南
- 西门子S7 和 S7 Plus 协议开发示例
- 模块化多电平变流器 MMC 的VSG控制 同步发电机控制 MATLAB–Simulink仿真模型 5电平三相MMC,采用VSG控制 受端接可编辑三相交流源,直流侧接无穷大电源提供调频能量 设置频率
- 微电网(两台)主从控制孤岛-并网平滑切的分析 分析了: 1.孤岛下VF控制 2.并网下PQ控制 3.孤岛下主从控制 4.孤岛到并网的平滑切控制 5.除模型外还对分布式发电与主动配电网一些常见问题做了
- 第四组二手产品.zip
- 基于小程序的智慧物业平台源代码(java+小程序+mysql+LW).zip
- MVIMG_20241222_194113.jpg