I'm having an almost impossible problem, fully reproducible with two separate pic18f2685.
The problem is experienced with this simple code:
code char at __CONFIG1H conf1 = _OSC_IRCIO7_1H;
code char at __CONFIG3H conf2 = _MCLRE_ON_3H & _PBADEN_OFF_3H;
code char at __CONFIG2H conf3 = _WDT_OFF_2H; // DIsable WDT
OSCCON = 0x70;
I'm selecting the internal oscillator with clock output on RC7. The "OSCCON" thing sets the internal oscillator to 8MHz operation. I'm monitoring the clock output IO pin with an oscilloscope.
Compiling the file with (note the --no-crt):
$ sdcc main.c -mpic16 -p18f2685 --optimize-cmp --optimize-df --no-crt
... the clock out is immediately set to 8MHz, and is kept there.
On the other hand when compiling without the "--no-crt" option, the clock starts at 1MHz, then you can see it switching to 8MHz (proving that the main function is entered), but then it switches to about 833Hz !! (hertz, no typo!).
I've looked at the generated assembly code, and apparently this is impossible to happen. I'm lost here..
I can provide the generated assembly code for both cases (with and without --no-crt).
Log in to post a comment.