• 0

WiFire: Are there no defines / functions for using the timers?


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?


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 1

Hi @photomankc,

I don't think I'll be of very much help here in your situation, but I don't believe anything was specifically added to the Digilent Core or otherwise to make the timers more accessible.

However, while not directly for the Wi-FIRE board, we do have an example of using multiple timers and DMA on a PIC32MZ (a PIC32MZ2048EFG124 which has a few more pins) for the OpenScope MZ. You can view the firmware for it on our GitHub here: https://github.com/Digilent/openscope-mz. I will note though that all of that material, as noted in it's MIT License, that the software is provided as is.


Link to post
Share on other sites
  • 0

Thanks.... That's helpful!   The PIC32 timers are a bit complicated but as long as I won't be stepping on other services I might try my hand at some headers to manipulate the registers needed on a separate board from this project.  


I chucked in the Core Timer Service callback in mine and kept it nothing more than a pin toggle.  I'll try to leave that in and test everything out with just a polling loop schedule doing the work for now.  If I get it all working including the other buses that are needed, then I'll see if I can move the RC serial into the core service.  If not I'll see if I can get one of the timers working for me.  Thanks for the pointer to that project!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now