Dear all,
I'm configuring PWM with pokesfr, since I need to route around timers and use different pins than the defaults for picaxe firmware. 8 MSBs of duty cycle are stored in CCPRxL register and the remaining 2 LSBs are kept in bits 5:4 of CCPxCON register. Since the bits around 5:4 in CCPRxL (7:6;3:0) are meaningful, it is quite a bit of a hassle to read and mask the rest of the bits on every change. That is to say, it eats aways milliseconds of my tight PID loops.
I have been browsing the Internet and staring at textbooks for a while now, but I'm yet to understand what would happen if I would just forget about the 2 LSBs. Pen and paper style, what is the math? How much resolution do I loose? Max decimal number one can 'make' with two binary bits is 3. Does this mean I get duty cycle 'step' of 3? Like 0,3,6,9...81,86... etc? I understand my new range would be 0...255, but that does not divide with 3, so the above must be wrong somehow .
Can anyone help, please?
Merry holidays,
Edmunds
I'm configuring PWM with pokesfr, since I need to route around timers and use different pins than the defaults for picaxe firmware. 8 MSBs of duty cycle are stored in CCPRxL register and the remaining 2 LSBs are kept in bits 5:4 of CCPxCON register. Since the bits around 5:4 in CCPRxL (7:6;3:0) are meaningful, it is quite a bit of a hassle to read and mask the rest of the bits on every change. That is to say, it eats aways milliseconds of my tight PID loops.
I have been browsing the Internet and staring at textbooks for a while now, but I'm yet to understand what would happen if I would just forget about the 2 LSBs. Pen and paper style, what is the math? How much resolution do I loose? Max decimal number one can 'make' with two binary bits is 3. Does this mean I get duty cycle 'step' of 3? Like 0,3,6,9...81,86... etc? I understand my new range would be 0...255, but that does not divide with 3, so the above must be wrong somehow .
Can anyone help, please?
Merry holidays,
Edmunds