OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 1811|回复: 2

关于STM32 SysTick滴答时钟的问题

[复制链接]

6

主题

15

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
210
金钱
210
注册时间
2019-7-2
在线时间
32 小时
发表于 2019-7-23 16:19:20 | 显示全部楼层 |阅读模式
1金钱
是这样的,最近在用STM32F105进行串口接收LoRa消息,使用到了SysTick作为串口接收超时标志。
在初始化的时候,经过配置的SysTick能够正常的进入SysTick_Handler(void)中断函数。但是在进入串口接收处理函数之后,就进不去SysTick_Handler(void)函数,导致这边只能判断接收的累计长度足够长才能进行对数据进行处理。
试过了很多的方法,但是一直是没有用的,在此求助大家,谢谢。
附上相关代码:

//SysTick初始化配置
  1. void SysTick_Configuration(FunctionalState NewState)
  2. {
  3.     /* SysTick end of count event each 1ms with input clock equal to 9MHz (HCLK/8, default) 系统时钟节拍1ms*/
  4.           SysTick_SetReload(2000);                   //72/8=9MHZ
  5.           /* Enable SysTick interrupt */
  6.           SysTick_ITConfig(NewState);
  7.           /* Enable the SysTick Counter */
  8.                 if(NewState == ENABLE)
  9.                         SysTick_CounterCmd(SysTick_Counter_Enable);        
  10.                 else
  11.                         SysTick_CounterCmd(SysTick_Counter_Disable);        
  12.         
  13. }
复制代码


//SysTick中断
  1. void SysTick_Handler(void)
  2. {
  3.         if(CAN1_COM.com_timeout > 0)
  4.                 CAN1_COM.com_timeout --;
  5.         
  6.         if(RingHF_COM.com_timeout > 0)
  7.                 RingHF_COM.com_timeout --;
  8.         
  9.         if(RS485_COM.com_timeout > 0)
  10.                 RS485_COM.com_timeout --;
  11.         
  12.         if(CAN2_COM.com_timeout > 0)
  13.     CAN2_COM.com_timeout --;               
  14. }
复制代码


//USART1接收中断
  1. int RingHF_USART1_IT(void)
  2. {
  3.         if (USART_GetITStatus(USART1, USART_IT_RXNE)!= RESET)
  4.         {
  5.                 unsigned char RingHF_RX;
  6.                 /* Clear the USART1 Receive interrupt */
  7.                 USART_ClearITPendingBit(USART1, USART_IT_RXNE);
  8.                 /* Get the received byte, set the guard time to 0xFF */
  9.                 RingHF_RX=USART_ReceiveData(USART1);
  10.                 *(RingHF_COM.RevStr+RingHF_COM.comRx_Count) = RingHF_RX;
  11.                
  12.                  RingHF_COM.comRx_Count++;
  13.                  RingHF_COM.comRxDat_Flag = true;        
  14.                  RingHF_Receive_Preprocess();
  15.                 return 0;
  16.         }
  17.         if (USART_GetITStatus(USART1, USART_IT_TC) != RESET)
  18.         {
  19.                 /* Clear the USART1 transmit interrupt */
  20.                 USART_ClearITPendingBit(USART1, USART_IT_TC);
  21.                 /*transmit finished*/
  22.                 if(RingHF_COM.sent_pc_ptr<(RingHF_COM.sent_pc_length))
  23.                 {
  24.                         /*send a byte*/
  25.                         USART_SendData(USART1, RingHF_COM.sent_pc[RingHF_COM.sent_pc_ptr]);
  26.                         /*inc the sent length*/
  27.                         RingHF_COM.sent_pc_ptr++;
  28.                 }
  29.                 else
  30.                 {
  31.                         RingHF_COM.Send_Over_Flag = 0;                                
  32.                         memset(RingHF_COM.sent_pc,0,800);
  33.                         USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
  34.                         USART_ITConfig(USART1, USART_IT_TC, DISABLE);
  35.                 }
  36.                 return 0;
  37.         }
  38.                 return 0;
  39. }
复制代码






最佳答案

查看完整内容[请看2#楼]

抢占优先级0,响应也是0的
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

6

主题

15

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
210
金钱
210
注册时间
2019-7-2
在线时间
32 小时
 楼主| 发表于 2019-7-23 16:19:21 | 显示全部楼层
抢占优先级0,响应也是0的
回复

使用道具 举报

2

主题

41

帖子

0

精华

初级会员

Rank: 2

积分
188
金钱
188
注册时间
2019-7-17
在线时间
48 小时
发表于 2019-7-23 19:50:11 | 显示全部楼层
谁的中断优先级高 ?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-7 15:55

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表