Arduino DUE compare

I have a question: Can the value of RA in the RA compare match of the Arduino DUE microcontroller Atmel SAM3X8E be a variable value like a sine function instead of a fixed value?

No, RA stands for Register A. All it does is hold a 32-bit integer value. To update the value of RA every compare match with RA, then you need to enable interrupts for the time channel and create a handler function. This handler function would then call your sine function and store the returned value in RA every time a compare match with RA event. NOTE: If your code takes longer (clock cycles) to update the value of RA than the period of the timer channel, then you'll end up with undefined behavior.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.