PDA

View Full Version : 18F2450 internal osc



kduck63
- 6th February 2011, 19:22
I am trying to run a 18F2450 using the internal oscillator inlieu of a external osc, but i can't even get a led to blink. Here is the test code I am trying to get working before i write the real program.


define loader_used 1

@ __CONFIG _CONFIG1H, _FOSC_INTOSCIO_EC_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H
@ __CONFIG _MCLRE_OFF_3H

osccon = 00000010

trisb = %1100000
led var portb.3

main:
led = 1
PAUSE 1000
led = 0
pause 1000
GOTO MAIN
end

ScaleRobotics
- 6th February 2011, 19:43
Try this, and see if it works for you. There might be something else wrong, but for sure, you will need these.

define loader_used 1

@ __CONFIG _CONFIG1H, _FOSC_INTOSCIO_EC_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H
@ __CONFIG _CONFIG3H, _MCLRE_OFF_3H
@ __CONFIG _CONFIG4L, _XINST_OFF_4L & _LVP_OFF_4L
If that doesn't work, you could try adding in some of the default ones:


__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H,_PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _BBSIZ_BB1K_4L & _XINST_OFF_4L

FinchPJ
- 7th February 2011, 05:33
Two thoughts:
1) I have found fuses are set by the loader fuse configuration, so no effect of changing them later
2) OSCCON = 00000010 is not the same as OSCCON = %00000010, rather = %00001010 ie. decimal 10
Peter
PS TRISB assignment is 7 bit was that intentional?

kduck63
- 7th February 2011, 13:32
Thanks for the suggestions.

I cleaned up the sloppy parts of the code and worked with the config fuses a bit, but i still had no luck. i finally gave in and added a external oscillator; i will revisit this when i have more time.