/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
* File Name : readme.txt
* Author : MCD Application Team
* Version : V1.0
* Date : 10/08/2007
* Description : Description of the TIM Example3.
********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
本例展示了如何设置TIM工作在输出比较-非主动模式(Output Compare Inactive mode),并产生相应的中断。
TIM2时钟设置为36MHz,预分频设置为35999,TIM2计数器时钟可表达为:
TIM2 counter clock = TIMxCLK / (Prescaler +1) = 1 KHz
设置TIM2_CCR1寄存器值为1000, CCR1寄存器值1000除以TIM2计数器时钟频率1KHz,为1000毫秒。因此,经过1000毫秒的时延,置PC.06输出为低电平。
同理,根据寄存器TIM2_CCR2 、TIM2_CCR3和 TIM2_CCR4的值,经过500毫秒的时延,置PC.07输出为低电平;经过250毫秒的时延,置PC.08输出为低电平;经过125毫秒的时延,置PC.09输出为低电平。
输出比较寄存器的值决定时延的大小,当计数器的值小于这个值的时候,点亮与PC.06-PC.09相连的LED;当计数器的值达到这个值得时候,产生中断,在TIM2的4个通道相应的中断里,把它们一一关闭。
Example description
===================
This example shows how to configure the TIM peripheral in Output Compare Inactive
mode with the corresponding Interrupt requests for each channel.
The TIMxCLK frequency is set to 36 MHz, the Prescaler is set to 35999 and used in
Output Compare Inactive Mode.
TIM2 counter clock = TIMxCLK / (Prescaler +1) = 1 KHz
The TIM2 CC1 register value is equal to 1000:
TIM2_CC1 delay = CCR1_Val/TIM2 counter clock = 1000 ms
so the PC.06 is reset after a delay equal to 1000 ms.
The TIM2 CC2 register value is equal to 500:
TIM2_CC2 delay = CCR2_Val/TIM2 counter clock = 500 ms
so the PC.07 is reset after a delay equal to 500 ms.
The TIM2 CC3 register value is equal to 250:
TIM2_CC3 delay = CCR3_Val/TIM2 counter clock = 250 ms
so the PC.08 is reset after a delay equal to 250 ms.
The TIM2 CC4 register value is equal to 125:
TIM2_CC4 delay = CCR4_Val/TIM2 counter clock = 125 ms
so the PC.09 is reset after a delay equal to 125 ms.
While the counter is lower than the Output compare registers values, which
determines the Output delay, the PC.06, PC.07, PC.08 and PC.09 pin are turned on.
When the counter value reaches the Output compare registers values, the Output
Compare interrupts are generated and, in the handler routine, these pins are turned off.
Directory contents
==================
stm32F10x_conf.h Library Configuration file
stm32F10x_it.c Interrupt handlers
stm32F10x_it.h Interrupt handlers header file
main.c Main program
Hardware environment
====================
Connect an oscilloscope on:
- PC.06
- PC.07
- PC.08
- PC.09
to show the different signals.
How to use it
=============
In order to make the program work, you must do the following:
- Create a project and setup all your toolchain's start-up files
- Compile the directory content files and required Library files:
+ stm32F10x_lib.c
+ stm32F10x_tim.c
+ stm32F10x_gpio.c
+ stm32F10x_rcc.c
+ stm32F10x_nvic.c
+ stm32F10x_flash.c
- Link all compiled files and load your image into either RAM or Flash
- Run the example
******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE******
没有合适的资源?快使用搜索试试~ 我知道了~
STM32+TIM.rar_32输出outpp_STM32 TIM2_STM32时钟输出_stm32 中断电平_stm32-
共56个文件
h:25个
c:22个
txt:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 8 浏览量
2022-09-21
04:58:31
上传
评论
收藏 146KB RAR 举报
温馨提示
本例展示了如何设置TIM工作在输出比较-非主动模式(Output Compare Inactive mode),并产生相应的中断。 TIM2时钟设置为36MHz,预分频设置为35999,TIM2计数器时钟可表达为: TIM2 counter clock = TIMxCLK / (Prescaler +1) = 1 KHz 设置TIM2_CCR1寄存器值为1000, CCR1寄存器值1000除以TIM2计数器时钟频率1KHz,为1000毫秒。因此,经过1000毫秒的时延,置PC.06输出为低电平。 同理,根据寄存器TIM2_CCR2 、TIM2_CCR3和 TIM2_CCR4的值,经过500毫秒的时延,置PC.07输出为低电平;经过250毫秒的时延,置PC.08输出为低电平;经过125毫秒的时延,置PC.09输出为低电平。 输出比较寄存器的值决定时延的大小,当计数器的值小于这个值的时候,点亮与PC.06-PC.09相连的LED;当计数器的值达到这个值得时候,产生中断,在TIM2的4个通道相应的中断里,把它们一一关闭。
资源推荐
资源详情
资源评论
收起资源包目录
STM32+TIM.rar (56个子文件)
Example3
stm32f10x_adc.c 54KB
stm32f10x_spi.h 9KB
stm32f10x_tim.h 28KB
stm32f10x_usart.h 11KB
stm32f10x_dma.h 12KB
tim_text3.dep 8KB
stm32f10x_flash.c 32KB
stm32f10x_type.h 3KB
stm32f10x_i2c.h 15KB
tim_text3.eww 43KB
main.c 9KB
stm32f10x_rcc.c 42KB
stm32f10x_wwdg.c 8KB
stm32f10x_iwdg.h 3KB
stm32f10x_nvic.h 16KB
stm32f10x_tim.c 97KB
stm32f10x_systick.h 3KB
stm32f10x_map.h 20KB
stm32f10x_it.c 23KB
stm32f10x_bkp.h 4KB
stm32f10x_iwdg.c 6KB
stm32f10x_gpio.c 21KB
stm32f10x_pwr.c 11KB
stm32f10x_pwr.h 4KB
tim_text3.ewd 31KB
stm32f10x_lib.c 7KB
stm32f10x_exti.h 6KB
stm32f10x_conf.h 5KB
stm32f10x_can.h 12KB
stm32f10x_adc.h 16KB
stm32f10x_tim1.c 112KB
cortexm3_macro.h 2KB
stm32f10x_rcc.h 13KB
settings
tim_text3.dni 552B
tim_text3.cspy.bat 2KB
tim_text3.dbgdt 14KB
tim_text3.wsdt 2KB
stm32f10x_rtc.h 4KB
stm32f10x_flash.h 10KB
stm32f10x_can.c 31KB
stm32f10x_bkp.c 11KB
stm32f10x_tim1.h 34KB
stm32f10x_it.h 3KB
stm32f10x_lib.h 3KB
stm32f10x_rtc.c 12KB
stm32f10x_wwdg.h 3KB
stm32f10x_systick.c 7KB
Debug
stm32f10x_usart.c 33KB
stm32f10x_i2c.c 44KB
stm32f10x_spi.c 25KB
stm32f10x_nvic.c 28KB
stm32f10x_exti.c 8KB
readme.txt 4KB
stm32f10x_gpio.h 12KB
stm32f10x_dma.c 23KB
www.pudn.com.txt 218B
共 56 条
- 1
资源评论
小波思基
- 粉丝: 85
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功