OCR1A and OCR1B are 8 bit registers. You can't load value more than 255.
OCR1A and OCR1B are 16bit registers of the 16bit clock timer 1, actually each one of them is two 8 bit registers (OCR1AH-OCR1AL) and (OCR1BH-OCR1BL) but they can be used as 16bit register because codevision has already defined
sfrw OCR1B=0x28; // 16 bit access
and
sfrw OCR1A=0x2a; // 16 bit access
i dont know how to calculate this value. i got this value by hit and trial method. i saw on CRO its width is 50% at 2500 ant 100% at 5000;
Please tell me how to calculate this value? how to set the registers?
the main problem i am facing is how to calculate for the frequency? i am using both OCR1A and OCR1B. if i change the value of TCNT. it change the frequecny but for both outputs. i want to change the frequency separately for both outputs.
You can't change the frequency individually, if you use one timer then you can only get one frequency.
The two compare registers can be loaded with two different values to give two different duty ratios but with the same frequency.
Depending on the PWM mode, if you use top=ICR1 ( instead of a fixed top 0xff/0h1ff/0h3ff ) then you can also change the PWM from the value of ICR1
The frequency and duty ratio depend on the mode and values used
In fast PWM
top=ICR1, the output
PWM frequency=timer clock/(ICR1+1) and the
duty=OCR1A(B)/ICR1
In fast PWM
top=0h00ff, the output
PWM frequency=timer clock/256 and the
duty=OCR1A(B)/256
In fast PWM
top=0h01ff, the output
PWM frequency=timer clock/512 and the
duty=OCR1A(B)/512
In fast PWM
top=0h03ff, the output
PWM frequency=timer clock/1024 and the
duty=OCR1A(B)/1024
In phase correct or phase & freq correct
top=ICR1, the output
PWM frequency=timer clock/(ICR1*2) and the
duty=OCR1A(B)/ICR1
In phase correct or phase & freq correct
top=0h00ff, the output
PWM frequency=timer clock/(255*2) and the
duty=OCR1A(B)/256
In phase correct or phase & freq correct
top=0h01ff, the output
PWM frequency=timer clock/(511*2) and the
duty=OCR1A(B)/512
In phase correct or phase & freq correct
top=0h03ff, the output
PWM frequency=timer clock/(1023*2) and the
duty=OCR1A(B)/1024
Alex