PDA

View Full Version : Discussion OT - PIC config settings


Malc C
Dec 10, 2006, 11:32 AM
Guys,

Its been several months since I played around with PBP, so I'm a tad rusty

I'm trying to get an 18F2550 to flash a few LEDs - nothing spectacular. I'm using PicBASIC pro and even though the code compiles OK, and loads OK the PIC fails to run. I'm sure its to do with the config settings, mainly the timing (I'm using an external xtal with 22pf caps). Here's the PBP code


;************ set up PIC *****************
;PORTA = 0 ' declare port level BEFORE port direction = safe power-on
CMCON = 7 ' Digital inputs
CCP1CON = 0 ' PWM off



TRISA=%11100111 'set PORTA as all input apart from A3 & A4
TRISB=%00000000 'set PORTB as all output

@WDT_ON
@PWRT_ON
@MCLR_OFF
@BOD_ON
@LVP_OFF
@CPD_OFF
@PROTECT_OFF
@ errorlevel -202


The INC file that the software uses is


;************************************************* ***************
;* 18F2550.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 12/31/04 *
;* Version : 2.46 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F2550, r = dec, w = -230, f = inhx32
INCLUDE "P18F2550.INC" ; MPASM Header
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 32


I've tried various settings in the INC but this is the only one I seem to have that don't throw out errors when compiling

Any comments would be welcome, either in this thread or if its too OT for the moderators, then via PM's or e-mail

Cheers

Mark J
Dec 10, 2006, 01:27 PM
Hi Malc,

As im as rusty as you are with PBP, jsut had a thought (probably wrong lol!) but have you tried setting your OSC value to match the crystal your using?

ie for a 20 meg crystal:

DEFINE OSC 20

also in your device defines set this I think to tell it its an external crystal your using

@ DEVICE HS_OSC

as that could possibly cause the chip to not run, or run, but because the timings all over the place, look like its not running henc why nothings lighting up etc.

Malc C
Dec 10, 2006, 02:34 PM
Hi Mark

yeah tried the OSC 4 line and that still didn't work. :(

Might try ripping the ASM part from the RC-Joystick files and see if I can get it to work

Gary Warner
Dec 11, 2006, 04:48 PM
Your listing shows you are using the watch dog timer and have setup the WDT prescaler:

@WDT_ON

......

__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H

.......

Are you clearing the WDT in the program or maybe not clearing it soon enough?

Malc C
Dec 11, 2006, 05:11 PM
Gary,

Thanks for the reply. I have a feeling its hardware related, as I've sinced moved on and tried remming out the config settings in the INC file and setting them in the code (with the help of a guy on the PBP forum) and I'm still haveing issues

Cheers

Gary Warner
Dec 11, 2006, 05:16 PM
So, are you using the WDT in the code and if so, are you clearing the WDT?