当前位置:网站首页>After CANopen starts PDO timing transmission, the heartbeat frame time is wrong, PDO is delayed, and CANopen time axis is disordered
After CANopen starts PDO timing transmission, the heartbeat frame time is wrong, PDO is delayed, and CANopen time axis is disordered
2022-04-23 18:22:00 【Things will turn when they reach the extreme 1024】
CANopen In the case of , A simple way to use a lot is to use a 1ms Timer interrupt , Then rewrite... With global variables sertimer and getElapsedTime function , Then add... To the interrupt service function timerForCan
//Set the next alarm //
void setTimer(TIMEVAL value)
{
NextTime=(TimeCNT+value)%TIMER_MAX_COUNT;
}
// Get the elapsed time since the last occured alarm //
TIMEVAL getElapsedTime(void)
{
int ret=0;
ret = TimeCNT> last_time_set ? TimeCNT - last_time_set : TimeCNT + TIMER_MAX_COUNT - last_time_set;
last_time_set = TimeCNT;
return ret;
}
But there is a fatal problem with this approach , The time calculated in this way , When there are only heartbeat frames, there is no problem , Join in PDO Regularly send , Will be chaos , for example 1s Heartbeat frame 300msPDO timing , The phenomenon is 1s Heartbeat frame retention , stay 1s After heartbeat frame 300ms There will be one more heartbeat frame , and PDO Timed transmission does not appear !!!!!!, In this case, it should be changed to last_time_set = TimeCNT; Put it in timerForCan Before !!!!
```c
//Set the next alarm //
void setTimer(TIMEVAL value)
{
NextTime=(TimeCNT+value)%TIMER_MAX_COUNT;
}
// Get the elapsed time since the last occured alarm //
TIMEVAL getElapsedTime(void)
{
int ret=0;
ret = TimeCNT> last_time_set ? TimeCNT - last_time_set : TimeCNT + TIMER_MAX_COUNT - last_time_set;
//last_time_set = TimeCNT; The culprit
return ret;
}
In addition, there will be a 1 Millisecond timer , Every time 1 Call the following function in milliseconds .
void timerForCan(void)
{
TimeCNT++;
if (TimeCNT>=TIMER_MAX_COUNT)
{
TimeCNT=0;
}
if (TimeCNT==NextTime)
{
TimeDispatch();
}
}
//1ms Interrupt service function
void TIM7_IRQHandler(void)
{
if(TIM7->SR&0X0001)// interrupt
{
}
TIM7->SR&=~(1<<0);// Clears the interrupt flag bit
last_time_set = TimeCNT;
timerForCan();
}
版权声明
本文为[Things will turn when they reach the extreme 1024]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210610057187.html
边栏推荐
- 线上怎么确定期货账户安全的?
- Log4j2 cross thread print traceid
- Mode of interprocess communication
- Calculation of fishing net road density
- The difference between deep copy and shallow copy
- Win1远程出现“这可能是由于credssp加密oracle修正”解决办法
- Rust: the output information of println is displayed during the unit test
- WiFi ap6212 driver transplantation and debugging analysis technical notes
- Imx6 debugging LVDS screen technical notes
- CISSP certified daily knowledge points (April 19, 2022)
猜你喜欢
mysql自动启动设置用Systemctl start mysqld启动
SSD硬盘SATA接口和M.2接口区别(详细)总结
Promote QT default control to custom control
【ACM】376. 摆动序列
STM32学习记录0008——GPIO那些事1
Notepad + + replaces tabs with spaces
A few lines of code teach you to crawl lol skin pictures
Dock installation redis
【ACM】509. 斐波那契数(dp五部曲)
Robocode tutorial 5 - enemy class
随机推荐
登录和发布文章功能测试
Crawl the product data of Xiaomi Youpin app
CISSP certified daily knowledge points (April 18, 2022)
logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours
Analysez l'objet promise avec le noyau dur (Connaissez - vous les sept API communes obligatoires et les sept questions clés?)
MySQL auto start settings start with systemctl start mysqld
WiFi ap6212 driver transplantation and debugging analysis technical notes
kettle庖丁解牛第17篇之文本文件输出
From source code to executable file
Realization of consumer gray scale
软件测试总结
CISSP certified daily knowledge points (April 13, 2022)
Rust: a simple example of TCP server and client
JD-FreeFuck 京东薅羊毛控制面板 后台命令执行漏洞
Imx6 debugging LVDS screen technical notes
Gst-launch-1.0 usage notes
硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)
【ACM】376. 摆动序列
STM32 learning record 0008 - GPIO things 1
Stm32mp157 wm8960 audio driver debugging notes