View previous topic :: View next topic |
Author |
Message |
EdwardH
Joined: 13 Jan 2009 Posts: 4
|
PIC18F87J60 oscillator problem |
Posted: Tue Jan 13, 2009 9:34 am |
|
|
I'm trying to write a program for the PIC18F87J60 and I started with a simple LED flash, however when I run this on the chip the LED flashes with only a 5.28uS delay not 500ms. There's a 25MHz crystal attached.
Any ideas? I've tried manually setting the OSCTUNE register etc with no success.
Thanks
Edward
Code: | #include <18F87J60.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc
#FUSES NODEBUG //No Debug mode for ICD
#FUSES XINST //Extended set extension and Indexed Addressing mode enabled
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOPROTECT //Code not protected from reading
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES PRIMARY //Primary clock is system clock when scs=00
#FUSES ECCPE //Enhanced CCP PWM outpts multiplexed with RE6 thorugh RE3
#FUSES ETHLED //Ethernet LED enabled
#FUSES RESERVED //Used to set the reserved FUSE bits
#use delay(clock=25MHZ, oscillator=25MHZ)
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_4(T4_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
output_high(PIN_B3);
while (1)
{
output_low(PIN_B2);
delay_ms(500);
output_high(PIN_B2);
delay_ms(500);
}
} |
|
|
|
Ttelmah Guest
|
|
Posted: Tue Jan 13, 2009 9:49 am |
|
|
The CCS compiler does not support XINST. May not be the problem, but code is unlikely to work right with this fuse set.
Best Wishes |
|
|
EdwardH
Joined: 13 Jan 2009 Posts: 4
|
|
Posted: Tue Jan 13, 2009 9:55 am |
|
|
Thanks, that's what it was!
I just used the project wizard to start with and it added the fuse by default. |
|
|
|