Ttelmah
Joined: 11 Mar 2010 Posts: 20159
|
|
Posted: Tue Feb 08, 2011 3:42 pm |
|
|
Think for a second.
10mSec 'design', (approx) 2 second 'real'. Ratio perhaps 200:1.
INT_RC clock. Top speed 8MHz, with OSCCON 6:4 set to '111'. Divide by 200 = about 40KHz. Bottom speed of INT_RC = 31KHz with OSCCON 6:4 set to 000. Ratio of this speed, 1/258 from the 8Mhz speed. So should give 2.58 seconds for the timings...
So, looks as if the OSCCON bits are not being properly set.
Manually override them:
| Code: |
#include <18F4550.h>
#FUSES INTRC, NOPROTECT, NOLVP, NOBROWNOUT, NOWDT, NOMCLR, NOPUT, NOFCMEN
#use delay(clock=8000000)
//============================
void main(void) {
setup_oscillator(OSC_8MHZ);
while(1) {
output_high(PIN_D2);
delay_ms(10);
output_low(PIN_D2);
delay_ms(10);
}
}
|
Series of separate things here. CPUDIV fuse, does nothing with the internal clock. This has it's own dividers. CPUDIV, is only used when you are feeding the clock from an external source. Hence removed this.
NOFCMEN, ensures it is not switching to the 'fail safe' clock, because it thinks something is wrong with the primary clock.
Setup_oscillator, overrides the clock selection in the configuration.
Best Wishes |
|