756 views|3 replies

96

Posts

0

Resources
The OP
 

In freeRTOS, when the interrupt receives SPI data, the task needs SPI to send data. How to solve the timing conflict? [Copy link]

As the title says, in freeRTOS, the SPI expansion CAN chip MCP2515 is used. After receiving data, MCP2515 will trigger the IO interrupt of STM32. Ideally, SPI data is received during the interrupt, but SPI is also required to send data in the task. So how to solve this timing conflict?

Currently, polling reception is done in the task, and sending is placed in the same task. However, the time slice of freeRTOS is 1ms, which is too long for data reception. In actual CAN data reception, multiple frames of data may be received in 1ms. What can I do?

Please give me some advice, experts.

Scenario: Data sending is irregular. I put the data to be sent in buff, and then query the buff in the task to send it if there is data.

This post is from stm32/stm8

Latest reply

You can control the irregular sending, but you must send it in idle state.   Details Published on 2024-6-12 16:28
 

211

Posts

0

Resources
2
 

I think it is enough to ensure the reliability of the minimum logical operation unit.

That is, when SPI is sending, the receiving interrupt is turned off and it will not be interrupted by the receiving interrupt;

Just turn off the sending enable when receiving;

And like F407, the entry and exit of ISR is probably within 1US, so don't worry

This post is from stm32/stm8
 
 

6742

Posts

2

Resources
3
 

Receive data in the interrupt, put the data into BUFF, and then generate a semaphore. When the task detects the semaphore, it processes the contents of BUFF.

This post is from stm32/stm8
 
 

5998

Posts

6

Resources
4
 

You can control the irregular sending, but you must send it in idle state.

This post is from stm32/stm8
 
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list