I'm working on a controller for an RC / Autonomous rover using a WiFire board I pulled out and dusted off. Most of the code will do okay with the speed I've got and polling so I'm just using the milliseconds timer to control execution and coding for time sharing. One bit I really wanted to have take place very reliably though is reading the serial data from the R/C receiver device. It's coming in every few milliseconds and I want to keep it updated and the serial buffer cleared no matter what else is going on.
I was looking at the timers and thinking setting up a timer interrupt would be a nice way to do this. However the code that I have found will compile just fine for the DP32 and WF32 boards but WiFire is missing any of the #defines of for the timers, registers, IRQs and such.
It seems like MZ has 4 more timers than MX so I'm a little surprised there seems to be nothing defined to use any of them?!? I think I do recall there being an attachCoreTimerService() function call that looped in your own function to the same interrupt that ran millis() but it seems like my last attempt to use that ended in tears when it worked fine until things were *really complicated* and I tried to also use I2C and SPI and then suddenly I was getting lockups. I'd prefer to setup something that was a little more out of the way. The code to extract the serial data is not real trivial so I'm a bit nervous about loading down the core timer with that.
Am I missing something basic here, or would it be up to me to setup the registers, interrupts, and such soup-to-nuts to use timers 2-9? Are any of them used in the background for PWM or other needs?
Question
photomankc
I'm working on a controller for an RC / Autonomous rover using a WiFire board I pulled out and dusted off. Most of the code will do okay with the speed I've got and polling so I'm just using the milliseconds timer to control execution and coding for time sharing. One bit I really wanted to have take place very reliably though is reading the serial data from the R/C receiver device. It's coming in every few milliseconds and I want to keep it updated and the serial buffer cleared no matter what else is going on.
I was looking at the timers and thinking setting up a timer interrupt would be a nice way to do this. However the code that I have found will compile just fine for the DP32 and WF32 boards but WiFire is missing any of the #defines of for the timers, registers, IRQs and such.
https://chipkit.net/interrupts-made-easy-with-chipkit/
https://www.instructables.com/Timer-Interrupts-on-the-DP32/
It seems like MZ has 4 more timers than MX so I'm a little surprised there seems to be nothing defined to use any of them?!? I think I do recall there being an attachCoreTimerService() function call that looped in your own function to the same interrupt that ran millis() but it seems like my last attempt to use that ended in tears when it worked fine until things were *really complicated* and I tried to also use I2C and SPI and then suddenly I was getting lockups. I'd prefer to setup something that was a little more out of the way. The code to extract the serial data is not real trivial so I'm a bit nervous about loading down the core timer with that.
Am I missing something basic here, or would it be up to me to setup the registers, interrupts, and such soup-to-nuts to use timers 2-9? Are any of them used in the background for PWM or other needs?
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.