INTOSCIO is correct here - it uses the internal oscillator without outputting the clock to GP4. That said, you could temporarily use that mode to verify that the clock is running at the frequency you expect.@lemario You have to use INTOSC, not INTOSCIO which has a different meaning.
Also, make sure you connected the anode to GP2 and the cathode to GND.
@JohnInTX I, sometimes, neglect the ANSEL register and still get a proper output.
LE: @lemario Have you ever considered using Proteus? It's a virtual simulation machine which enables you to use various components.
The LED should be connected as stefan said.
You might get away with ignoring ANSEL in a few cases but not in this one. Bit-oriented IO won't work on an analog port.
If you set OSCCON to 31khz with the current project settings, the delays computed by MikroC won't be correct. In this case, a 1 sec delay will take about 129 sec to execute because MikroC thinks the clock is running at 4MHz and will make the delays have more counts to compensate.
MikroC's sim will step through the code in a debug window. You also can import the .COF file into MPLAB/X.
@lemario Post a schematic - it doesn't have to be fancy. Use the Upload a File button. Also, I think you have to have 10 posts (maybe more) before you are allowed to edit. Its an anti-spam thing.
How are you using PICkit2 with MikroC? If you are importing the .HEX file into some other program, make SURE that the configuration bits are included in the .HEX (inspect the CONFIG settings in the programmer's operation window). MikroC doesn't always include CONFIG bits in their .HEX unless you are programming through their interface.
EDIT: revisit your project settings an:
Disable Internal/External switchover, BrownOut and FailSafe Clock monitor for now.
Last edited: