PDA

View Full Version : It's been a long time!!!



Cobra_Phil
- 12th January 2015, 05:03
It's been a while since I programmed in PicBasic. I would like to get back into it. But I am struggling with the simplest of task.....blinking an LED. Spent 3 hours trying to figure out what I am missing. Maybe someone can show this old newbie what I am missing.


' PIC18F24K50 Configuration Bit Settings
#config
CONFIG FOSC=INTOSCIO
CONFIG PLLSEL=PLL3X
CONFIG CFGPLLEN=ON
CONFIG CPUDIV=NOCLKDIV
CONFIG LS48MHZ=SYS48X8
CONFIG IESO=OFF
CONFIG FCMEN=ON
CONFIG PCLKEN=ON
CONFIG BOREN=OFF
CONFIG nPWRTEN=OFF
CONFIG nLPBOR=OFF
CONFIG BORV=220
CONFIG WDTPS=32768
CONFIG WDTEN=OFF
CONFIG MCLRE=OFF
CONFIG SDOMX=RC7
CONFIG T3CMX=RC0
CONFIG DEBUG=OFF
CONFIG STVREN=ON
CONFIG ICPRT=OFF
CONFIG XINST=OFF
CONFIG LVP=OFF
#ENDCONFIG

DEFINE OSC 48

OSCTUNE = %10000000 '3X PLL ratio mode selected
OSCCON = %01110000 'Switch to 16MHz HFINTOSC
OSCCON2 = %00010000 'Enable PLL

'*********************** PORT CONFIG ****************************
TRISA = 0 'porta direction 0=OUTPUT 1=INPUT
PORTA = 0 'porta preset
ANSELA = 0
'************************************************* ***************
'******************* MAIN PROGRAM ************************
'************************************************* ***************
while 1
low PORTA.5
PAUSE 500
high PORTA.5
pause 500
WEND
end

7672

richard
- 12th January 2015, 06:07
you have not really provided any clue at all to what you problem is

but looking at the data sheet osc description I doubt that



DEFINE OSC 48


is correct

they way I see it it needs to be


DEFINE OSC 24


the x3 pll is followed by a /2 stage and the 48mhz only goes to the usb module

Demon
- 12th January 2015, 15:49
CONFIG nLPBOR=OFF

Is that "n" a typo? You have 2 like that.

Robert

Cobra_Phil
- 13th January 2015, 02:50
Thanks for the replies.
The problem is, I can't even get an LED to blink. Does not come on at all, much less blink.
Just trying to figure out the basics with this chip.

According to this chart, using the internal OSC with 3x PLL and no clock divider, it should be at 48MHz if I am understanding it correctly.

CONFIG FOSC=INTOSCIO
CONFIG PLLSEL=PLL3X
CONFIG CPUDIV=NOCLKDIV

7677

Also, nPWRTEN, and nLPBOR are valid parameters in the PIC18F24K50.PBPINC file.

richard
- 13th January 2015, 04:20
ok looks like 48mhz clock is more likely to be correct , the table makes no mention of the /4 option as depicted in the osc diagram fig 3.1 ,and a 0 divide option seems more probable

what are you using to pgm the chip , its not holding mclr low or something easy like that . pwr ok ? led works ?

richard
- 13th January 2015, 04:31
OSCCON = %01110010

might by worth a try

Normnet
- 13th January 2015, 08:07
Try reversing the order:
OSCCON must always precede OSCTUNE

Been there done that.

Norm

Normnet
- 16th January 2015, 11:14
Try reversing the order:
OSCCON must always precede OSCTUNE

Been there done that.

Norm
Have you had a chance to try the above?
This issue also came up on another forum. (http://www.protonbasic.co.uk/showthread.php/71967-Checking-Internal-Ocillator-Speed?highlight=OSCCON+OSCTUNE)


Norm

Cobra_Phil
- 17th January 2015, 05:01
I tried swapping the two lines and it did not make a difference. But, I have come to the conclusion I either have a faulty chip/board or the bootloader is not actually sending the program to the chip.