本文整理汇总了C++中TIM_GetCounter函数的典型用法代码示例。如果您正苦于以下问题:C++ TIM_GetCounter函数的具体用法?C++ TIM_GetCounter怎么用?C++ TIM_GetCounter使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIM_GetCounter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hardwareBlinking
void hardwareBlinking(void)
{
TIM_Cmd(TIM2, DISABLE);
TIM_ITConfig(TIM2, TIM_IT_CC1, DISABLE);
/* change the period of the ISR */
factor = (factor+1)%2;
TIM_PrescalerConfig(TIM2, 12000, TIM_PSCReloadMode_Immediate);
/* restart interrupt on TIM3 */
TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);
TIM_Cmd(TIM2, ENABLE);
for(;;){
int num = TIM_GetCounter(TIM2);
if(num == 6000){
STM_EVAL_LEDOn(LED3);
STM_EVAL_LEDOff(LED4);
}
else if(num == 12000){
STM_EVAL_LEDOff(LED3);
STM_EVAL_LEDOn(LED4);
break;
}
}
hardwareBlinking();
}
示例2: USART1_IRQHandler
/*******************************************************************************
* Function Name : USART1_IRQHandler
* Description : This function handles USART1 global interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void USART1_IRQHandler(void)
{
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
Rx_Buffer[data]=USART_ReceiveData(USART1);
Usart_Putnum(Rx_Buffer[data]);
if(Rx_Buffer[data]==1){
/* Enable ADC1 DMA */
ADC_DMACmd(ADC1, ENABLE);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Enable ADC1 reset calibaration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibaration */
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
/* Start ADC1 Software Conversion */
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
}
else if(Rx_Buffer[data]==2)
ADC_Cmd(ADC1, DISABLE);
else if(Rx_Buffer[data]==3)
Usart_Putnum(TIM_GetCounter(TIM4));
}
//{
//Rx_Buffer[data]=data;
//data++;
//USART_ClearITPendingBit(USART1, USART_IT_RXNE);
/*Rx_Buffer[data]=USART_ReceiveData(USART1);
Usart_Putnum(Rx_Buffer[data]);
data++;*/
/*
if(Rx_Buffer[data]==1)
Usart_Putnum(10);
else if(Rx_Buffer[data]==2)
Usart_Putnum(20);
*/
}
示例3: IRstudydata
/******************************************
程序功能:红外接收中断服务程序
参程序数:无
返回参数:无
*******************************************/
void IRstudydata(void)
{
uint16_t datatimerbuf; //红外接收数据缓存
// if(hwred_bit_status != GPIO_ReadInputPin(IR_PORT, IRRED_PIN))
// {
// hwred_bit_status = (BitStatus)!hwred_bit_status;
if( bit_is_clear(Irtxflag,IRRXFINSH) && IRstudyflag)
{
datatimerbuf = TIM_GetCounter(TIM2);//- TIMECOUNT;
TIM_SetCounter(TIM2,0);
if(bit_is_clear(IRrxflag,IRRXSTART))
{
sbi_(IRrxflag,IRRXSTART);
memset((void *)Irtimebuf,'\0',300);
irdatalen = 0;
// uart_print(&irdatalen,1);
}
else if(irdatalen < TEMPTIMEBUF)
{
Irtimebuf[irdatalen] = datatimerbuf;
irdatalen++;
}
}
// }
}
示例4: EXTI9_5_IRQHandler
/**********************************************************************
* 名 称:EXTI9_5_IRQHandler()
* 功 能:外部中断通道5中断
* 入口参数:
* 出口参数:
***********************************************************************/
void EXTI9_5_IRQHandler (void)
{
OSIntEnter();
if(EXTI_GetITStatus(EXTI_Line5) != RESET)
{
if(SONICDEVICE.step == 1)
{
TIM_SetCounter(TIM6,0);
TIM_Cmd(TIM6, ENABLE);
SONICDEVICE.step = 2;
}
else if(SONICDEVICE.step == 2)
{
SONICDEVICE.databuff[SONICDEVICE.nextindex] = TIM_GetCounter(TIM6);
if(SONICDEVICE.nextindex == 9)
{
SONICDEVICE.nextindex = 0;
}
else
{
SONICDEVICE.nextindex ++;
}
TIM_Cmd(TIM6, DISABLE);
SONICDEVICE.step = 0;
}
EXTI_ClearFlag(EXTI_Line5); //清除中断标志(必须)
EXTI_ClearITPendingBit(EXTI_Line5);
}
OSIntExit();
}
示例5: bsp_timer_scheduleIn
/**
\brief Schedule the callback to be called in some specified time.
The delay is expressed relative to the last compare event. It doesn't matter
how long it took to call this function after the last compare, the timer will
expire precisely delayTicks after the last one.
The only possible problem is that it took so long to call this function that
the delay specified is shorter than the time already elapsed since the last
compare. In that case, this function triggers the interrupt to fire right away.
This means that the interrupt may fire a bit off, but this inaccuracy does not
propagate to subsequent timers.
\param delayTicks Number of ticks before the timer expired, relative to the
last compare event.
*/
void bsp_timer_scheduleIn(PORT_TIMER_WIDTH delayTicks)
{
PORT_TIMER_WIDTH newCompareValue;
PORT_TIMER_WIDTH temp_last_compare_value;
//enable it if not enabled.
TIM_Cmd(TIM2, ENABLE);
temp_last_compare_value = bsp_timer_vars.last_compare_value;
newCompareValue = bsp_timer_vars.last_compare_value+delayTicks;
bsp_timer_vars.last_compare_value = newCompareValue;
if (delayTicks < (TIM_GetCounter(TIM2)-temp_last_compare_value))
{
// setting the interrupt flag triggers an interrupt
TIM2->SR |= (u16)TIM_FLAG_CC1;
}
else
{
// this is the normal case, have timer expire at newCompareValue
TIM_SetCompare1(TIM2,newCompareValue);
TIM_ClearFlag(TIM2, TIM_FLAG_CC1);
TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);
}
}
示例6: CMX7262_Transcode
uint16_t CMX7262_Transcode (CMX7262_TypeDef *pCmx7262, uint16_t uMode)
{
uint16_t uData;
// Set the codec mode.
CBUS_Write16(VCTRL_REG,(uint16_t *)&uMode,1,pCmx7262->uInterface);
// Wait until we have confirmation of the mode being set.
TIM_SetCounter(TIM5,0);
while (TIM_GetCounter(TIM5) < CMX7262_TRANSCODE_TIMEOUT)
{
CBUS_Read16 (IRQ_STATUS_REG,&uData,1,pCmx7262->uInterface);
pCmx7262->uIRQ_STATUS_REG |= uData;
if ((pCmx7262->uIRQ_STATUS_REG & REGDONE) == REGDONE)
{
// Clear the REGDONE bit in the shadow regsiter.
pCmx7262->uIRQ_STATUS_REG &= (uint16_t)(~REGDONE);
return 1;
}
}
// If we get here we have timed out and the mode selection was not successful,
// so return 0.
return 0;
}
示例7: EXTI2_3_IRQHandler
extern "C" void EXTI2_3_IRQHandler(void) {
uint32_t count = TIM_GetCounter(TIM14);
if (EXTI_GetITStatus(EXTI_Line2)) {
EXTI_ClearITPendingBit(EXTI_Line2);
if (GPIOA->IDR & GPIO_Pin_2) {
s_dht11_outer.startTime = count;
} else {
if (count < s_dht11_inner.startTime)
s_dht11_outer.buffer[s_dht11_outer.bufferCnt++] = count + (255 - s_dht11_outer.startTime);
else
s_dht11_outer.buffer[s_dht11_outer.bufferCnt++] = count - s_dht11_outer.startTime;
}
if (s_dht11_outer.bufferCnt == s_bitsCount) {
dht11_process(&s_dht11_outer);
}
}
if (EXTI_GetITStatus(EXTI_Line3)) {
EXTI_ClearITPendingBit(EXTI_Line3);
if (GPIOA->IDR & GPIO_Pin_3) {
s_dht11_inner.startTime = count;
} else {
if (count < s_dht11_inner.startTime)
s_dht11_inner.buffer[s_dht11_inner.bufferCnt++] = count + (255 - s_dht11_inner.startTime);
else
s_dht11_inner.buffer[s_dht11_inner.bufferCnt++] = count - s_dht11_inner.startTime;
}
if (s_dht11_inner.bufferCnt == s_bitsCount) {
dht11_process(&s_dht11_inner);
s_dht11_inner.bufferCnt = 0;
}
}
}
示例8: OSProbe_TmrRd
CPU_INT32U OSProbe_TmrRd (void)
{
#if (OS_PROBE_TIMER_SEL == 2)
return ((CPU_INT32U)TIM_GetCounter(TIM2));
#elif (OS_PROBE_TIMER_SEL == 3)
return ((CPU_INT32U)TIM_GetCounter(TIM3));
#elif (OS_PROBE_TIMER_SEL == 4)
return ((CPU_INT32U)TIM_GetCounter(TIM4));
#endif
}
示例9: ENC_Get_Electrical_Angle
/*******************************************************************************
* Function Name : ENC_Get_Electrical_Angle
* Description : Returns the absolute electrical Rotor angle
* Input : None
* Output : None
* Return : Rotor electrical angle: 0 -> 0 degrees,
* S16_MAX-> 180 degrees,
* S16_MIN-> -180 degrees
*******************************************************************************/
s16 ENC_Get_Electrical_Angle(void)
{
s32 temp;
temp = (s32)(TIM_GetCounter(ENC_TIMER)) * (s32)(U32_MAX / (4*ENCODER_PPR));
return((s16)(temp/65536)); // s16 result
}
示例10: ENC_Get_AnglularPosition
/******************角位移******/
s32 ENC_Get_AnglularPosition(void)
{
s32 temp;
temp = hEncoder_Revolutions_Num*4*ENCODER_PPR+TIM_GetCounter(ENC_TIMER);
return (temp*3600/(REDUCTION_RATIO*4*ENCODER_PPR));//单位0.1度
// return temp;
}
示例11: dhtRead
void dhtRead(u8 * rh, u8 * temp, u8 * checkSum ){
u8 tmp,j,i,tab[5] = {0x00,0x00,0x00,0x00,0x00};
dhtGpioOutInit();
GPIO_ResetBits(GPIOD,GPIO_Pin_7);
dhtDelay(18000);
GPIO_SetBits(GPIOD,GPIO_Pin_7);
dhtDelay(40);
dhtGpioInInit();
while(!GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_7));
while(GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_7));
for (i = 0; i < 5; ++i) {
for (j = 0; j < 8; ++j) {
while(!GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_7));
TIM_SetCounter(TIM3,0);
while(GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_7));
tmp = TIM_GetCounter(TIM3);
if(tmp<30){// trwanie sygna³u <30us-> 0; ok. 70us -> 1;
tab[i]=tab[i]<<1;
}
else{
tab[i] = tab[i]<<1;
tab[i] += 1;
}
}
}
*rh = tab[0];
*temp = tab[2];
*checkSum = tab[4];
}
示例12: TIM2_IRQHandler
/*
*berif: Timer interrupt request function
*param: None
*reval: None
*/
void TIM2_IRQHandler(void) //5ms
{
/* Clear the interrupt pending flag */
if(TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
{
TIM_Cmd(TIM4, DISABLE);
TIM_Cmd(TIM3, DISABLE);
SpeedL = 30000 - TIM_GetCounter(TIM4);
SpeedR = 30000 - TIM_GetCounter(TIM3);
TIM_SetCounter(TIM4, 30000);
TIM_SetCounter(TIM3, 30000);
TIM_Cmd(TIM4, ENABLE);
TIM_Cmd(TIM3, ENABLE);
TIM_ClearFlag(TIM2, TIM_FLAG_Update);
}
}
示例13: TIM_GetCounter
uint32_t Timer_Time::current_time(){
//uint32_t current_time1;
//uint32_t atual_time = TIM_GetCounter(TIM6);
//TIM_SetCounter(TIM6, (uint32_t) 0);
//time_elapsed1 = atual_time - this->last_time;
//this->last_time = atual_time;
return TIM_GetCounter(TIM6);
};
示例14: comm_tim_update_capture
/**
* Update our last capture time
*
*/
void comm_tim_update_capture(void)
{
comm_tim_data.last_capture_time = TIM_GetCounter(TIM2);
TIM_SetCompare1(TIM2,
comm_tim_data.last_capture_time + comm_tim_data.freq);
OFF(DP_EXT_SCL);
}
示例15: delay_core
void delay_core(){
TIM_SetCounter(TIM2,1);
TIM_Cmd(TIM2,ENABLE);
while(TIM_GetCounter(TIM2));
TIM_Cmd(TIM2,DISABLE);
}