/**
******************************************************************************
* @file stm8a_tim1.c
* @brief This file contains all the functions for the TIM1 peripheral.
* @author STMicroelectronics - APG Application Team
* @version V1.0.1
* @date 09/22/2008
******************************************************************************
*
* THE PRESENT FIRMWARE 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 FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2008 STMicroelectronics</center></h2>
* @image html logo.bmp
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8a_tim1.h"
/* LINKER SECTIONS DEFINITION FOR THIS FILE ONLY */
#ifdef USE_COSMIC_SECTIONS
#pragma section (TIM1_CODE)
#pragma section const {TIM1_CONST}
#pragma section @near [TIM1_URAM]
#pragma section @near {TIM1_IRAM}
#pragma section @tiny [TIM1_UZRAM]
#pragma section @tiny {TIM1_IZRAM}
#endif
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
static void TI1_Config(u8 TIM1_ICPolarity, u8 TIM1_ICSelection,
u8 TIM1_ICFilter);
static void TI2_Config(u8 TIM1_ICPolarity, u8 TIM1_ICSelection,
u8 TIM1_ICFilter);
static void TI3_Config(u8 TIM1_ICPolarity, u8 TIM1_ICSelection,
u8 TIM1_ICFilter);
static void TI4_Config(u8 TIM1_ICPolarity, u8 TIM1_ICSelection,
u8 TIM1_ICFilter);
/**
* @addtogroup TIM1_Public_Functions
* @{
*/
/**
* @brief Deinitializes the TIM1 peripheral registers to their default reset values.
* @par Parameters:
* None
* @retval void None
* @par Required preconditions:
* None
* @par Called functions:
* None
* @par Example:
* Initialize TIM1 registers to their reset values.
* @code
* TIM1_DeInit();
* @endcode
*/
void TIM1_DeInit(void)
{
TIM1->CR1 = TIM1_CR1_RESET_VALUE;
TIM1->CR2 = TIM1_CR2_RESET_VALUE;
TIM1->SMCR = TIM1_SMCR_RESET_VALUE;
TIM1->ETR = TIM1_ETR_RESET_VALUE;
TIM1->IER = TIM1_IER_RESET_VALUE;
TIM1->SR2 = TIM1_SR2_RESET_VALUE;
/* Disable channels */
TIM1->CCER1 = TIM1_CCER1_RESET_VALUE;
TIM1->CCER2 = TIM1_CCER2_RESET_VALUE;
/* Configure channels as inputs: it is necessary if lock level is equal to 2 or 3 */
TIM1->CCMR1 = 0x01;
TIM1->CCMR2 = 0x01;
TIM1->CCMR3 = 0x01;
TIM1->CCMR4 = 0x01;
/* Then reset channel registers: it also works if lock level is equal to 2 or 3 */
TIM1->CCER1 = TIM1_CCER1_RESET_VALUE;
TIM1->CCER2 = TIM1_CCER2_RESET_VALUE;
TIM1->CCMR1 = TIM1_CCMR1_RESET_VALUE;
TIM1->CCMR2 = TIM1_CCMR2_RESET_VALUE;
TIM1->CCMR3 = TIM1_CCMR3_RESET_VALUE;
TIM1->CCMR4 = TIM1_CCMR4_RESET_VALUE;
TIM1->CNTRH = TIM1_CNTRH_RESET_VALUE;
TIM1->CNTRL = TIM1_CNTRL_RESET_VALUE;
TIM1->PSCRH = TIM1_PSCRH_RESET_VALUE;
TIM1->PSCRL = TIM1_PSCRL_RESET_VALUE;
TIM1->ARRH = TIM1_ARRH_RESET_VALUE;
TIM1->ARRL = TIM1_ARRL_RESET_VALUE;
TIM1->CCR1H = TIM1_CCR1H_RESET_VALUE;
TIM1->CCR1L = TIM1_CCR1L_RESET_VALUE;
TIM1->CCR2H = TIM1_CCR2H_RESET_VALUE;
TIM1->CCR2L = TIM1_CCR2L_RESET_VALUE;
TIM1->CCR3H = TIM1_CCR3H_RESET_VALUE;
TIM1->CCR3L = TIM1_CCR3L_RESET_VALUE;
TIM1->CCR4H = TIM1_CCR4H_RESET_VALUE;
TIM1->CCR4L = TIM1_CCR4L_RESET_VALUE;
TIM1->OISR = TIM1_OISR_RESET_VALUE;
TIM1->EGR = 0x01; /* TIM1_EGR_UG */
TIM1->DTR = TIM1_DTR_RESET_VALUE;
TIM1->BKR = TIM1_BKR_RESET_VALUE;
TIM1->RCR = TIM1_RCR_RESET_VALUE;
TIM1->SR1 = TIM1_SR1_RESET_VALUE;
}
/**
* @brief Initializes the TIM1 Time Base Unit according to the specified parameters.
* @param[in] TIM1_Prescaler specifies the Prescaler value.
* @param[in] TIM1_CounterMode specifies the counter mode from @ref TIM1_CounterMode_TypeDef .
* @param[in] TIM1_Period specifies the Period value.
* @param[in] TIM1_RepetitionCounter specifies the Repetition counter value
* @retval void None
* @par Required preconditions:
* None
* @par Called functions:
* None
* @par Example:
* Initialize TIM1 registers according to the specified parameters.
* @code
* u16 My_Prescaler = 0x0000;
* TIM1_CounterMode_TypeDef My_CounterMode = TIM1_COUNTERMODE_UP;
* u16 My_Period = 0x7FFF;
* u8 My_RepetitionCounter = 0x00
* TIM1_TimeBaseInit(My_Prescaler, My_CounterMode, My_Period, My_RepetitionCounter);
* @endcode
*/
void TIM1_TimeBaseInit(u16 TIM1_Prescaler,
TIM1_CounterMode_TypeDef TIM1_CounterMode,
u16 TIM1_Period,
u8 TIM1_RepetitionCounter)
{
/* Check parameters */
assert_param(IS_TIM1_COUNTER_MODE_OK(TIM1_CounterMode));
/* Set the Autoreload value */
TIM1->ARRH = (u8)(TIM1_Period >> 8);
TIM1->ARRL = (u8)(TIM1_Period);
/* Set the Prescaler value */
TIM1->PSCRH = (u8)(TIM1_Prescaler >> 8);
TIM1->PSCRL = (u8)(TIM1_Prescaler);
/* Select the Counter Mode */
TIM1->CR1 = (u8)(((TIM1->CR1) & (u8)(~(TIM1_CR1_CMS | TIM1_CR1_DIR))) | (u8)(TIM1_CounterMode));
/* Set the Repetition Counter value */
TIM1->RCR = TIM1_RepetitionCounter;
}
/**
* @brief Initializes the TIM1 Channel1 according to the specified parameters.
* @param[in] TIM1_OCMode specifies the Output Compare mode from @ref TIM1_OCMode_TypeDef.
* @param[in] TIM1_OutputState specifies the Output State from @ref TIM1_OutputState_TypeDef.
* @param[in] TIM1_OutputNState specifies the Complementary Output State from @ref TIM1_OutputNState_TypeDef.
* @param[in] TIM1_Pulse specifies the Pulse width value.
* @param[in] TIM1_OCPolarity specifies the Output Compare Polarity from @ref TIM1_OCPolarity_TypeDef.
* @param[in] TIM1_OCNPolarity specifies the Complementary Output Compare Polarity from @ref TIM1_OCNPolarity_TypeDef.
* @param[in] TIM1_OCIdleState specifies the Output Compare Idle State from @ref TIM1_OCIdleState_TypeDef.
* @param[in] TIM1_OCNIdleState specifies the Complementary Output Compare Idle State from @ref TIM1_OCIdleState_TypeDef.
* @retval void None
* @par Required preconditions:
* None
* @par Called functions:
* None
* @par Example:
* Initialize the TIM1 Channel1 according to specified parameters.
* @code
* TIM1_OCMode_TypeDef My_OCMode = TIM1_OCMODE_PWM1;
* TIM1_OutputState_TypeDef My_OutputState = TIM1_OUTPUTSTATE_ENABLE;
* TIM1_OutputNState_TypeDef My_OutputNState = TIM1_OUTPUTNSTATE_DISABLE;
* u16 My_Pulse = 0x3FFF;
* TIM1_OCPolarity_TypeDef My_OCPolarity = TIM1_OCPOLARITY_HIGH;
* TIM1_OCNPolarity_TypeDef My_OCNPolarity = TIM1_OCNPOLARITY_LOW;
* TIM1_OCIdleState_TypeDef My_OCIdleState = TIM1_OCIDLESTATE_RESET;
* TIM1_OCIdleState_TypeDef My_OCNIdleState = TIM1_OCNIDLESTATE_RESET;
* TIM1_OC1Init( My_OCMode, My_OutputState, My_OutputNState, My_Pulse, My_OCPolarity, My_OCNPolarity, My_OCIdleState, My_OCNIdleState);
* @endcode
*/
void TIM1_OC1Init(TIM1_OCMode_TypeDef TIM1_OCMode,
TIM1_OutputState_TypeDef TIM1_OutputState,
TIM1_OutputNState_TypeDef TIM1_OutputNState,
u16 TIM1_Pulse,
TIM1_OCPolarity_TypeDef TIM1_OCPolarity,
TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity,
TIM1_OCIdleState_TypeDef TIM1_OCIdleState,
没有合适的资源?快使用搜索试试~ 我知道了~
stm8a_fwlib.rar_STM8A_stm_stm8a_fwlib_stm8a_it.h_车规级
共655个文件
c:235个
h:193个
o:80个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 93 浏览量
2022-07-15
16:07:53
上传
评论
收藏 7.74MB RAR 举报
温馨提示
意法半导体车规级8位MCU STM8A的开发库及所以功能模块的示例代码。 对学习使用STM8A软件工程师很有用。
资源推荐
资源详情
资源评论
收起资源包目录
stm8a_fwlib.rar_STM8A_stm_stm8a_fwlib_stm8a_it.h_车规级 (655个子文件)
stm8a_tim1.c 98KB
stm8a_tim2.c 54KB
stm8a_i2c.c 51KB
stm8a_tim3.c 46KB
stm8a_i2c--.c 41KB
复件 Tv.c 37KB
stm8a_usart.c 33KB
stm8a_linuart.c 32KB
Radio.c 30KB
stm8a_it.c 29KB
App_function.c 28KB
stm8a_linuart1.c 28KB
stm8a_adc1.c 25KB
stm8a_clk.c 25KB
mono_lcd.c 22KB
TV_2IN1.c 21KB
TDA7415.c 20KB
stm8a_flash.c 20KB
eeprom_24C02.c 19KB
Communication.c 19KB
Radio1.c 19KB
stm8a_it.c 17KB
stm8a_adc.c 16KB
stm8a_spi.c 16KB
microsd.c 16KB
stm8a_tim4.c 15KB
stm8a_it.c 15KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
Tv.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
Power.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 14KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
stm8a_it.c 13KB
Dsa.c 12KB
Radio_pll.c 12KB
i2c.c 11KB
stm8a_gpio.c 10KB
ir.c 10KB
main.c 10KB
main.c 10KB
TvTuner.c 9KB
stm8a_awu.c 9KB
stm8a_itc.c 9KB
main.c 8KB
Tuner.c 8KB
共 655 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
周楷雯
- 粉丝: 80
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功