中级会员
 
- 积分
- 210
- 金钱
- 210
- 注册时间
- 2019-7-2
- 在线时间
- 32 小时
|
1金钱
是这样的,最近在用STM32F105进行串口接收LoRa消息,使用到了SysTick作为串口接收超时标志。
在初始化的时候,经过配置的SysTick能够正常的进入SysTick_Handler(void)中断函数。但是在进入串口接收处理函数之后,就进不去SysTick_Handler(void)函数,导致这边只能判断接收的累计长度足够长才能进行对数据进行处理。
试过了很多的方法,但是一直是没有用的,在此求助大家,谢谢。
附上相关代码:
//SysTick初始化配置
- void SysTick_Configuration(FunctionalState NewState)
- {
- /* SysTick end of count event each 1ms with input clock equal to 9MHz (HCLK/8, default) 系统时钟节拍1ms*/
- SysTick_SetReload(2000); //72/8=9MHZ
- /* Enable SysTick interrupt */
- SysTick_ITConfig(NewState);
- /* Enable the SysTick Counter */
- if(NewState == ENABLE)
- SysTick_CounterCmd(SysTick_Counter_Enable);
- else
- SysTick_CounterCmd(SysTick_Counter_Disable);
-
- }
复制代码
//SysTick中断
- void SysTick_Handler(void)
- {
- if(CAN1_COM.com_timeout > 0)
- CAN1_COM.com_timeout --;
-
- if(RingHF_COM.com_timeout > 0)
- RingHF_COM.com_timeout --;
-
- if(RS485_COM.com_timeout > 0)
- RS485_COM.com_timeout --;
-
- if(CAN2_COM.com_timeout > 0)
- CAN2_COM.com_timeout --;
- }
复制代码
//USART1接收中断
- int RingHF_USART1_IT(void)
- {
- if (USART_GetITStatus(USART1, USART_IT_RXNE)!= RESET)
- {
- unsigned char RingHF_RX;
- /* Clear the USART1 Receive interrupt */
- USART_ClearITPendingBit(USART1, USART_IT_RXNE);
- /* Get the received byte, set the guard time to 0xFF */
- RingHF_RX=USART_ReceiveData(USART1);
- *(RingHF_COM.RevStr+RingHF_COM.comRx_Count) = RingHF_RX;
-
- RingHF_COM.comRx_Count++;
- RingHF_COM.comRxDat_Flag = true;
- RingHF_Receive_Preprocess();
- return 0;
- }
- if (USART_GetITStatus(USART1, USART_IT_TC) != RESET)
- {
- /* Clear the USART1 transmit interrupt */
- USART_ClearITPendingBit(USART1, USART_IT_TC);
- /*transmit finished*/
- if(RingHF_COM.sent_pc_ptr<(RingHF_COM.sent_pc_length))
- {
- /*send a byte*/
- USART_SendData(USART1, RingHF_COM.sent_pc[RingHF_COM.sent_pc_ptr]);
- /*inc the sent length*/
- RingHF_COM.sent_pc_ptr++;
- }
- else
- {
- RingHF_COM.Send_Over_Flag = 0;
- memset(RingHF_COM.sent_pc,0,800);
- USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
- USART_ITConfig(USART1, USART_IT_TC, DISABLE);
- }
- return 0;
- }
- return 0;
- }
复制代码
|
|