公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

Tip / 登入 to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DanielGG
Level 2
Level 2
10 replies posted 5 replies posted 10 questions asked
想用TC275的一个CAN节点往外发不同周期(10ms的、20ms的、50ms的)的报文,如何实现? CAN模块我已经配置好了,可以多多条不同ID的message,但现在是有些报文周期是10ms,有些是20ms,50ms,那我如何实现不同周期的发送呢? 我想了个方法是用系统定时器STM,分别定时10ms、20ms、50ms等然后进中断,在各个中断函数里实现对应时间周期的报文发送? 大家还有什么其他方法吗?因为现在程序还是裸跑,没有上操作系统,不能时间片。
0 点赞
10 回复数
sjhdaflafjk
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted
就弄个10ms中断啊,然后设个cnt变量, 每次cnt累加, cnt %2 == 0, 就发20ms的message, cnt %5 ==0 就发50ms的
0 点赞
xiaobuy
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted
一个计时器,其他计数
0 点赞
Alexboo
Level 4
Level 4
100 replies posted 50 replies posted 25 replies posted
Counter = (Counter + 1) % 100; //0 ~ 99 if((Counter%50) == 0) TxMessage50ms; // 0, 50 if((Counter%20) == 2) TxMessage20ms; // 2, 22, 42, 62,82 if((Counter%10) == 1) TxMessage10ms; // 1, 11, 21, 31, 41, 51, 61, 71, 81, 91
0 点赞
BABY1
Level 5
Level 5
5 solutions authored First solution authored First like received
弄三个中断还会存在中断优先级问题,还是一个好
0 点赞
ZERO_GO
Level 6
Level 6
5 sign-ins Welcome!
二楼的方法,楼主可以测试一下。
0 点赞
跑道
Level 4
Level 4
100 replies posted 50 replies posted 25 replies posted
加个定时计数器就好了。
0 点赞
阳东
Level 5
Level 5
10 comments on blog 5 comments on blog First comment on blog
学习了
0 点赞
liliWinner
Level 6
Level 6
500 replies posted 250 replies posted 100 replies posted
mark
0 点赞
liliWinner
Level 6
Level 6
500 replies posted 250 replies posted 100 replies posted
mark
0 点赞
User22064
Level 5
Level 5
10 sign-ins First like given 5 sign-ins
学习了
0 点赞