PDA

View Full Version : 18F8722 sample code



George
- 19th June 2008, 05:02
I've bought this controller http://www.futurlec.com/PIC18F8722_Controller.shtml and want to start using them as controllers for various projects and am wanting some sample code, I've been using PBP for a while but am only an entry level user. Am currently trying to get my board to do a blink type program but having no joy at all - I get loads of errors. here's my code:

TRISH = 0
porth = 0

Start:
porth.0 = 1
pause 50
porth.0 = 0
pause 500
goto start

I guess I have to load up a ton of configs before hand. But just don't understand them that well and can find datasheets a little confusing at times, some simple code to get me running would be really appreciated.

Thanks
George

skimask
- 19th June 2008, 05:16
At least you're starting off right and trying blinky first
Increase the first pause 50, give your eyes a change to see it.
Put a meter on the OSC pins, see what you get.
Make sure ALL Vdd's are connected together, including AVdd
Make sure ALL Vss's are connected together, including AVss

George
- 19th June 2008, 05:33
Thanks, but I've not even got that far yet, I cant' get it compiling, I'm using MPASM5.20 through MicroCode but i'm getting errors like...

Warning[230] c:\progr~\pbp2.42\18F8722.inc 20 : _Config has been depreciated for PIC18 devices use directive Config
Error[113] c:\progr~\pbp2.42\18F8722.inc 20 : Symbol not previously defined (_OSCS_OFF_1H)
Error[113] c:\progr~\pbp2.42\18F8722.inc 20 : Symbol not previously defined (_XT_OSC_1H)

etc...

One thing I forgot to mention is I didn't have the 18F8722.inc and bas files in my pbp2.42 version, i think DT said I could rename the 18F8720.inc and bas files, I did it in notepad and changed any internal ref to the 8720 to the 8722 and saved it accordingly. I've never used MPASM before so not even sure if that's working correctly.

Do I have to go in and do more mods to my INC file? Here's how it reads currently

NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F8722, r = dec, w = -302, f = inhx32
INCLUDE "P18F8722.INC" ; MPASM Header
__CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H
__CONFIG _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_ON_2L
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG3H, _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 8



Tho it seems the configs are diff from pbp to mpasm so that's why it's having trouble?

skimask
- 19th June 2008, 05:38
The upgrade is only $25 ya know...
Config - do a search on presetting the config registers.
Other than that, just pretend it's an 18F8720, if your programmer will let you.

George
- 19th June 2008, 06:18
Yah, I know the upgrade is only $25, and if needs be I'll end up getting it. I only use PBP from time to time, if it were a full time effort then I'd deff upgrade when new releases come out. However have found if I change lines like:
__CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H

in my INC files to

CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H

As it was sortof telling me in the errors then those particular errors disappear which is good - however these errors are now superceeded by others which is not so good.

Error[176] : CONFIG Directive error: (missing "=" in parameter "_CONFIG1H")

So I suppose I've been making progress but I've now tried to place a = sign in the config1h line copying the inc file from MPASM but no joy - any ideas?

Thanks

skimask
- 19th June 2008, 06:20
Yep, read:
http://www.picbasic.co.uk/forum/showthread.php?t=543&highlight=preset+config
It's got all the good info in it for doing up the config fuses.

George
- 19th June 2008, 07:32
Thanks, I was reading through that. Still can't make anything work tho, the whole missing "=" thing has got me confused. I've tried replacing statements like _OSC_HS_1H with ones like OSC = XT which are found in the INC file of MPASM but still it keeps saying "=" is missing (config directive error)

Anyone have any ideas on how to rewrite these? (just one will do I'm sure I could figure the rest if given an example)


CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H
CONFIG _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_ON_2L
CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
CONFIG _CONFIG3H, _CCP2MX_ON_3H
CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L

George
- 19th June 2008, 11:25
Making progress, I've changed the INC files to read like this:

CONFIG OSC=HS
CONFIG BOREN=ON, PWRT=ON, BORV=0
CONFIG WDT=ON
CONFIG STVREN=ON, LVP=ON, DEBUG=OFF

and much better progress, gotten rid of all my errors when turning into assembly - however one niggling error remains there were a few references to OSCS in the INC files and it wasn't working with them so I removed them, it doesn't seem to be listed in the MPASM inc file so figured it's not valid for this chip. So it creates the asm file now but comes up with the error:

Error[176] c:\contro~.asm 70 :CONFIG Directive Error: (setting "OSCS" not found for the processor 18f8722)

Have looked for references to it in all the other included files but can't find where it's coming from - it's obviously the Oscillator switch enable that was on the chip of the previous version the 18f8720 but I can't find it, is someone able to email me their 18f8722.INC and BAS files to see if they work any better?

Cheers

skimask
- 19th June 2008, 13:42
OSCS isn't valid on an '8722. It's been superceded by the osccon<scs1:scs0>.