设为首页 加入收藏

TOP

STM32F7xx外设驱动4-timer(寄存器)
2023-07-23 13:31:25 】 浏览:71
Tags:STM32F7xx 4-timer
//源文件

void TimerPhyConfig()
{
   RCC->APB1ENR |= (1<<1);    //使能Timer3
	
	 TIM3->ARR = arr;
	 TIM3->PSC = psc;
	 TIM3->DIER = (1<<0);    //Update interrupt enabled
	 TIM3->CR1 |= (1<<0);    //Counter enabled
	 TIM3->CR1 &= ~(1<<4);   //Counter used as upcounter

	 HAL_NVIC_EnableIRQ(TIM3_IRQn);
}

void TIM3_IRQHandler(void)
{
	if(TIM3->SR&0X0001)//溢出中断
	{
		 LD1_TURN;
		 LD2_TURN;
		 LD3_TURN;
	}
	TIM3->SR&=~(1<<0);//清除中断标志位
}


//头文件
/*****************************timer************************************/
#define SET500MS

#ifdef  SET500MS
	#define 	arr   (5000-1)
	#define  	psc   (10800-1)
#endif
#ifdef  SET1000MS
	#define 	arr   (5000-1)
	#define  	psc   (10800-1)
#endif

void TimerPhyConfig();
/**********************************************************************/

  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇树莓派2b无屏装centos 下一篇AIR32F103(五) FreeRTOSv202112核..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目