18F8722 sample code


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171

    Default 18F8722 sample code

    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

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    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

  3. #3
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    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?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Thumbs down

    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.

  5. #5
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Yep, read:
    http://www.picbasic.co.uk/forum/show...=preset+config
    It's got all the good info in it for doing up the config fuses.

  7. #7
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    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

  8. #8
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    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

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    OSCS isn't valid on an '8722. It's been superceded by the osccon<scs1:scs0>.

Similar Threads

  1. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. MN1307 sample code problem
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th November 2008, 20:41
  5. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts