赞
踩
tim.c
- int fputc(int ch,FILE *f)
- {
- while(!(USART1->ISR & 1<<7)){};
- USART1->TDR =ch;
- return ch;
- }
- int i = 0;
- void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
- {
- i++;
- if(i%5==0)//5秒发送一次
- {
- if(htim->Instance == TIM3)
- {
- printf("恭喜发财");
- }
- }
- }
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
main.c
HAL_TIM_Base_Start_IT(&htim3); //添加到启动时,作业启动TIM3定时器
效果:
每秒向串口发送“新年快乐”
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。