I am writing code for the PIC 18f2550 target. Forgot to mension. On Mon, Feb 16, 2015 at 10:16:20PM +0100, Nordin Tomas wrote: > Hi > > I have a function that look like this: > > void set_ccp1_rc2(unsigned int match_cnt) > { > T1CONbits.TMR1ON = 0; // Stop timer. > TMR1 = 0; //Clear timer. > CCPR1 = match_cnt; > CCP1CON = 0b00001001; // From here pin will be set. Cleared on match. > T1CONbits.TMR1ON = 1; // Roll the timer. > } > > It translates after compile to this: > > S_timing__set_ccp1_rc2 code > _set_ccp1_rc2: > ; .line 87; SRC/timing.c void set_ccp1_rc2(unsigned int > match_cnt) > MOVFF FSR2L, POSTDEC1 > MOVFF FSR1L, FSR2L > MOVFF r0x00, POSTDEC1 > MOVFF r0x01, POSTDEC1 > MOVLW 0x02 > MOVFF PLUSW2, r0x00 > MOVLW 0x03 > MOVFF PLUSW2, r0x01 > ; .line 89; SRC/timing.c T1CONbits.TMR1ON = 0; // Stop timer. > BCF _T1CONbits, 0 > ; .line 90; SRC/timing.c TMR1 = 0; //Clear timer. > CLRF _TMR1 > ; .line 91; SRC/timing.c CCPR1 = match_cnt; > MOVF r0x00, W > MOVWF _CCPR1 > ; .line 92; SRC/timing.c CCP1CON = 0b00001001; // From here pin > will be set. Cleared on match. > MOVLW 0x09 > MOVWF _CCP1CON > ; .line 93; SRC/timing.c T1CONbits.TMR1ON = 1; // Roll the timer. > BSF _T1CONbits, 0 > MOVFF PREINC1, r0x01 > MOVFF PREINC1, r0x00 > MOVFF PREINC1, FSR2L > RETURN > > There is a problem with the running code on the device. It occurs to me > that only one byte is written to the _CCPR1 register (MOVWF _CCPR1). > Also I am confused to see direct writes to 16-bit equates in the > assembly code, is that possible? > > Should the above translation work as intended or is there something > funky? > > / > > Tomas
------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user