Neil, just to test add external crystal and turn off internal also turn off brawn= out=20 reset. see what happens.=20 AA ________________________________ From: PICdude To: piclist@MIT.EDU Sent: Mon, June 6, 2011 8:52:55 AM Subject: [PIC] C issue Decided to (finally) tinker with C programming this weekend, and using =20 the default install of Hi-Tech C (Lite) that came with MPLAB 8.66. I created a basic piece of code to turn on some LED's (multiplexed =20 discrete and 7-segment) on an existing board I have, and it takes a =20 LONG time to start up -- in the order of several minutes, if at all. =20 One a couple occasions it worked right away. So I'm guessing the =20 oscillator is not starting up properly...? I also tried setting the config bits from the Config Bits menu rather =20 than the code and it worked (code ran immediately on programming) the =20 first time, but I can't reproduce that any more. Also tried explicitly turning on Vdd and releasing from reset, but no =20 difference. And the board works perfectly with assembly code. What am I missing here? For reference, this is the code I'm using (16F883)= .... #include __CONFIG(1, FOSC_INTRC_NOCLKOUT & DEBUG_OFF & WDTE_OFF & LVP_OFF & =20 BOR_ON & CP_OFF & CPD_OFF & FCMEN_ON & IESO_ON & MCLRE_OFF & PWRTE_ON); __CONFIG(2, BOR4V_BOR40V & WRT_OFF); #define FOSC 8000000L /* 8 Mhz internal clock */ void main(void) { INTCON =3D 0; OSCCON =3D 0x71; /* 8 Mhz internal clock */ TRISA =3D 0b00001011; TRISB =3D 0b11100000; TRISC =3D 0b00000000; /* PORTC is all outputs */ ANSEL =3D 0b00000011; /* RA0,1 are analog inputs */ ANSELH =3D 0; ADCON1 =3D 0b00010000; /* Left justified, External Vref+ */ OPTION_REG =3D 0; /* Port-B pullups active */ WPUB =3D 0b01100000; VRCON =3D 0; /* Turn off */ T1CON =3D 0; CM1CON0 =3D 0; CM2CON0 =3D 0; CM2CON0 =3D 0x02; /* Turn off comparators */ PORTA =3D 0b11111111; /* Turn on all columns */ PORTB =3D 0b11111111; /* Turn on all rows */ PORTC =3D 0b10101010; /* Turn on all rows */ /* TODO -- testing... just stop here for now */ for (;;) { } } Cheers, -Neil. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .