PDA

View Full Version : Trouble using int. osc. On 18f2455



KPDes
- 14th June 2007, 23:59
I m having trouble getting started with the 18f2455. I just upgraded to PBP 2.47 so I could work with USB pics . I have no problem programming other pics but I can only get this one to run with an external oscillator and even then it is sporadic and unreliable.

Here is the code I am trying to use to blink an LED :

define OSC 8
OSCCON=%01110010


loop:

High PORTA.1 'Turn on LED
Pause 500 ' Delay for .5 seconds
Low PORTA.1 'Turn off LED
Pause 500 ' Delay for .5 seconds
Goto loop ' Go back to loop and blink LED forever

End

I am using the melbas programmer and setting the oscillator to: INTHS, HS Used By USB

I have read PBP manual, the oscillator configurations section of the data sheet and tried to find something on this forum. I have also tried a bunch of other settings still no luck.
I have a feeling I am overlooking something simple. If anyone has a suggestion I would appreciate it

Thanks

-kyle

skimask
- 15th June 2007, 01:57
I m having trouble getting started with the 18f2455. I just upgraded to PBP 2.47 so I could work with USB pics . I have no problem programming other pics but I can only get this one to run with an external oscillator and even then it is sporadic and unreliable.
I have a feeling I am overlooking something simple. If anyone has a suggestion I would appreciate it
Thanks
-kyle

Cap across Vdd and Vss (and/or power supply input to the board)
MCLR pullup resistor

KPDes
- 15th June 2007, 02:15
Yea I checked that, power is getting to the pins and MCLR is pulled high

skimask
- 15th June 2007, 02:34
Yea I checked that, power is getting to the pins and MCLR is pulled high

No, I meant do you have a .1uf (or similar) capacitor across the power pins?
And what value resistor do you have pulling MCLR high?

KPDes
- 15th June 2007, 03:21
The pull-up resistor I am using is 6K and I do have a capacitor over the power pins.

I have gotten it to work by accident when it was programmed for an internal oscillator but the crystal and capacitors were still hooked up from when I was trying an external mode. It started working when I touched one of the capacitors off the crystal, I put it on the scope and the timing was right. It was like the extra capacitance kicked it off or something? Only sometimes this works and it doesn’t work when I set it to external mode. It makes me think it is a configuration problem but I’ve tried everything I can think of

mister_e
- 15th June 2007, 03:39
this could be a breadboard problem. In many occasion it's extra capacitance may screw up things. Higher your crystal value is, worst it is. The trick is to keep every pins short (crystal and capacitors) and be able to mount them directly.

Here's a setup for a 4MHz crystal


'
' Pic Configuration
' =================
asm
__CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
; ; ; USB clock source comes from the 96 MHz PLL divided by 2
; ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
; No prescale (4 MHz oscillator input drives PLL directly)


__CONFIG _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
; ; ; Oscillator Switchover mode disabled
; ; Fail-Safe Clock Monitor disabled
; XT oscillator, PLL enabled, XT used by USB

__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm
DEFINE OSC 48

Have a look at the USBDemo thread and code, there you'll find some settings.

http://www.picbasic.co.uk/forum/showthread.php?t=5418

KPDes
- 15th June 2007, 06:20
I am still having trouble.

I noticed the assembler gives the warning message:

Warning[217] c:\pbp18f2550.inc 18 : Hex file format specified on command line

Could this be the problem?

KPDes
- 15th June 2007, 10:35
Problem solved!!

after many hours of mister_e style head banging , I updated the not just the software (like i did before i made a post) but the firmware on my melabs U2 programmer that fixed the problem