CcydtN / Multi-Touch-Kit-ProMicro

0 stars 0 forks source link

Why "experiment" branch have better performance? #2

Open CcydtN opened 1 year ago

CcydtN commented 1 year ago

The main different between "main" and "experiment" is the timer that generate PWM. What is the different between two timer?

CcydtN commented 8 months ago

Using Timer 0 and Timer 4 can cause different processing speed because they are different hardware timers with different features and characteristics.

Timer 0 is a 8-bit timer on most AVR microcontrollers, including the Arduino Uno. It has a maximum value of 255 and can be used for various timing and counting applications. However, Timer 0 is also used by the Arduino core for various functions, such as the millis() and delay() functions. This can cause conflicts if you try to use Timer 0 for other purposes.

On the other hand, Timer 4 is a 16-bit timer on some AVR microcontrollers, including the Arduino Mega. It has a maximum value of 65535 and can be used for more precise timing and counting applications. Timer 4 is not used by the Arduino core for any functions, so it can be used for other purposes without conflicts.

The processing speed can also be affected by other factors, such as the clock speed of the microcontroller, the prescaler value used for the timer, and the interrupt service routines used for the timer. Therefore, it's important to properly configure and test your code to ensure accurate processing speed and timing.

-- From ChatGpt (https://poe.com/s/XsIUfM0pQ0RzGrQ4KRNl) Not verified yet