I have a project that requires a min of 2 stepper motors to be running at different speeds. Currently I am using the timerOne class to generate a higher pulse frequency, then using software to calculate the number of those base periods required for the appropriately frequency to each motor. Couple days ago I set out to write a class that would allow 3 different frequencies to be generated as individual interrupts. Here is the general understanding of how this should work:
- set up TCCR1A & TCCRA to CTC mode & with appropriate prescalers
- set the OCCR1A, OCCR1B, OCCR1C register to the appropriate compare value
- write interrupt function for ISR(TIMER1_COMPA_vect){}, ISR(TIMER1_COMPB_vect){}, ISR(TIMER1_COMPC_vect){}.
- Set bits 3, 2, 1 in TIMSK1 to turn on interrupts for those ISR's
So I have it at the point where compValA functions 100% right when run on its own, however, B & C will not run without OCCR1A set & then will only run at that frequency. I am starting to wonder if it is even possible to do what I want with this, could anyone confirm that this is possible?
Also, I noticed that the interrupt vectors defined in ioxx.h are all shifted by one as compared the the atmega2560 data sheet...shifting them to match breaks pretty much everything in arduino....so anyone know why these don't match the data sheet?
One thing that I dont yet know about is TCCR1C specifically the forced output compare bits. What do these do, what would one use it for, should I be using it?
thanks for your attention, happy coding!