文件名称:STM32+TIM
- 所属分类:
- 单片机(51,AVR,MSP430等)
- 资源属性:
- [C/C++] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 213kb
- 下载次数:
- 0次
- 提 供 者:
- c***
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
本例展示了如何设置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个通道相应的中断里,把它们一一关闭。-err
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个通道相应的中断里,把它们一一关闭。-err
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Example3
........\cortexm3_macro.h
........\Debug
........\main.c
........\readme.txt
........\settings
........\........\tim_text3.cspy.bat
........\........\tim_text3.dbgdt
........\........\tim_text3.dni
........\........\tim_text3.wsdt
........\stm32f10x_adc.c
........\stm32f10x_adc.h
........\stm32f10x_bkp.c
........\stm32f10x_bkp.h
........\stm32f10x_can.c
........\stm32f10x_can.h
........\stm32f10x_conf.h
........\stm32f10x_dma.c
........\stm32f10x_dma.h
........\stm32f10x_exti.c
........\stm32f10x_exti.h
........\stm32f10x_flash.c
........\stm32f10x_flash.h
........\stm32f10x_gpio.c
........\stm32f10x_gpio.h
........\stm32f10x_i2c.c
........\stm32f10x_i2c.h
........\stm32f10x_it.c
........\stm32f10x_it.h
........\stm32f10x_iwdg.c
........\stm32f10x_iwdg.h
........\stm32f10x_lib.c
........\stm32f10x_lib.h
........\stm32f10x_map.h
........\stm32f10x_nvic.c
........\stm32f10x_nvic.h
........\stm32f10x_pwr.c
........\stm32f10x_pwr.h
........\stm32f10x_rcc.c
........\stm32f10x_rcc.h
........\stm32f10x_rtc.c
........\stm32f10x_rtc.h
........\stm32f10x_spi.c
........\stm32f10x_spi.h
........\stm32f10x_systick.c
........\stm32f10x_systick.h
........\stm32f10x_tim.c
........\stm32f10x_tim.h
........\stm32f10x_tim1.c
........\stm32f10x_tim1.h
........\stm32f10x_type.h
........\stm32f10x_usart.c
........\stm32f10x_usart.h
........\stm32f10x_wwdg.c
........\stm32f10x_wwdg.h
........\tim_text3.dep
........\tim_text3.ewd
........\tim_text3.eww
........\cortexm3_macro.h
........\Debug
........\main.c
........\readme.txt
........\settings
........\........\tim_text3.cspy.bat
........\........\tim_text3.dbgdt
........\........\tim_text3.dni
........\........\tim_text3.wsdt
........\stm32f10x_adc.c
........\stm32f10x_adc.h
........\stm32f10x_bkp.c
........\stm32f10x_bkp.h
........\stm32f10x_can.c
........\stm32f10x_can.h
........\stm32f10x_conf.h
........\stm32f10x_dma.c
........\stm32f10x_dma.h
........\stm32f10x_exti.c
........\stm32f10x_exti.h
........\stm32f10x_flash.c
........\stm32f10x_flash.h
........\stm32f10x_gpio.c
........\stm32f10x_gpio.h
........\stm32f10x_i2c.c
........\stm32f10x_i2c.h
........\stm32f10x_it.c
........\stm32f10x_it.h
........\stm32f10x_iwdg.c
........\stm32f10x_iwdg.h
........\stm32f10x_lib.c
........\stm32f10x_lib.h
........\stm32f10x_map.h
........\stm32f10x_nvic.c
........\stm32f10x_nvic.h
........\stm32f10x_pwr.c
........\stm32f10x_pwr.h
........\stm32f10x_rcc.c
........\stm32f10x_rcc.h
........\stm32f10x_rtc.c
........\stm32f10x_rtc.h
........\stm32f10x_spi.c
........\stm32f10x_spi.h
........\stm32f10x_systick.c
........\stm32f10x_systick.h
........\stm32f10x_tim.c
........\stm32f10x_tim.h
........\stm32f10x_tim1.c
........\stm32f10x_tim1.h
........\stm32f10x_type.h
........\stm32f10x_usart.c
........\stm32f10x_usart.h
........\stm32f10x_wwdg.c
........\stm32f10x_wwdg.h
........\tim_text3.dep
........\tim_text3.ewd
........\tim_text3.eww