So the compiler appears to be doing something like this;
Which is similar to this;
So what part of John's C code are you finding difficult to convert to assembler?
Rich (BB code):
movlw b'00100000' ; -0100--- postscale 5
movwf temp ; ?
movf temp,W ; ?
iorlw b'00000110' ; -----1-- TMR2 "on"
; ------10 prescale 16
movwf T2CON ;
movlw d'100' ;
bsf STATUS,RP0 ; bank 1
movwf PR2 ;
Rich (BB code):
;
; // setup TMR2 for 1.6 ms PWM period and 8 ms interrupts (4 MHz clock)
;
; T2CON = 0b00100110; // -0100--- TOUTPS<3:0> postscale 5
; // -----1-- TMR2ON "on"
; // ------10 T2CKPS<1:0> prescale 16
; // generate 16 us timer 'ticks'
; PR2 = 100-1; // period = 100 x 16 us 'ticks' (625 Hz)
;
movlw b'00100110' ; -0100--- TOUTPS<3:0> postscale 5
; -----1-- TMR2ON "on"
; ------10 T2CKPS<1:0> prescale 16
movwf T2CON ; generate 16 us timer 'ticks'
bsf STATUS,RP0 ; bank 1
movlw d'100'-1 ;
movwf PR2 ; period = 100 x 16us 'ticks' (625 Hz)