Quote:
|
Originally Posted by Mark McLeod
You're correct that if pwm01 gets set to a number greater than 255 it will wrap around to zero and you'll suddenly go from full forward to full reverse.
|
In the TxData struct, all PWM values are defined as type 'unsigned char' - or one byte. Assigning a value greater than 255 will cause unpredictable processor operation unless you are VERY lucky.
Most programmers are used to C/C++/C#/C.NET which traps all your errors.... such as overflow. In the processor, it does exactly what you tell it to do. All defining some thing as a uchar does is tell the linker to offset the next thing in memory by 1 byte. Sooooo if you write a number bigger than a byte, you will interfere with the next bit down the line in processor memory. This would in effect change the value of the next variable.
-Q