18F1220 newbie


Closed Thread
Results 1 to 17 of 17

Thread: 18F1220 newbie

  1. #1
    Join Date
    Nov 2011
    Posts
    18

    Default 18F1220 newbie

    Hi All, I am trying to convert a 16F88 program to run on a 18F1220. For starters I tried the attached blink LED program but can't get it to work.
    I'm using Pickit2, Microcode Studio and MPASM ver. 5.20.
    Please look at my code and tell me what I'm doing wrong. I've spent more than 6 hours searching through the data sheet and PBP manual
    but to no avail.
    Ta
    Hebe
    '--------------------------------------------------------------------------
    'Blinking LED
    '######## SETUP ################################################## ##############

    porta=0ortb=0 'set ports to 0 then do trises
    trisb= %00001100 'portb.2&3 inputs. The rest are outputs
    trisa= %00111100 'porta.2-5 inputs. The rest are outputs
    WDTCON = 0 ;WDT off
    ADCON0 = %00000000 ;ADC off
    ADCON1 = %01111111 ;All pins digital
    LVDCON = %00000000 ;LVD off
    CCP1CON = %00000000 ;CCP/PWM off
    OSCCON = %01110000 ;RUN mode,8MHZ,INT OSC
    RCON = %00000000 ;Prioritys off
    EECON1 = %00000100 ;Access flash
    INTCON2 = %10000000 ;Disable PORTB pullups
    INTCON3 = %00000000 ;INT1&2 disabled
    PIE1 = %00000000 ;Disable A/D,EUSART,CCP,TMR2,TMR1 overflow ints
    PIE2 = %00000000 ;Disable OSC Fail,EEPROM,LVD,TMR3 overflow ints
    IPR1 = %00000000 ;A/D,EUSART,CCP,TMR2,TMR1 low priority
    IPR2 = %00000000 ;OSC Fail,EEPROM,LVD,TMR3 ints low priority
    RCON = %00000000 ;Disable priority levels
    T0CON = %00000000 ;TMR0 off
    T1CON = %00000000 ;TMR1 off
    T2CON = %00000000 ;TMR2 off
    T3CON = %00000000 ;TMR3 off
    TXSTA = %00000000 ;Transmit disabled
    RCSTA = %00000000 ;Receive disabled

    @ CONFIG IESO=OFF & FSCM=OFF & INTIO2_OSC_1H
    @ CONFIG PWRT=ON & BOR=OFF & BORV=27
    @ CONFIG WDT=OFF & WDTPS=32K
    @ CONFIG MCLRE=OFF
    @ CONFIG DEBUG=OFF & LVP=OFF & STVR=OFF
    @ CONFIG CP0=OFF & CP1=OFF
    @ CONFIG CPB=OFF & CPD=OFF
    @ CONFIG WRT0=OFF & WRT1=OFF
    @ CONFIG WRTC=OFF & WRTB=OFF & WRTD=OFF
    @ CONFIG EBTR0=OFF & EBTR1=OFF
    @ CONFIG EBTRB=OFF

    define OSC 8 ;8Mhz clock. osccon and define osc must be set
    osccon=%01111000 ;the same for correct program timing + OSTS=1
    'define OSC 4 ;4Mhz clock. osccon and define osc must be set
    'OSCCON=%01101000 ;the same for correct program timing + OSTS=1
    DEFINE NO_CLRWDT 1 ;don’t insert CLRWDTs


    Ry1 var porta.1




    rpt1:
    ry1=1: pause 500: ry1=0: pause 500 ;flash of Ry1+LED
    goto rpt1
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    Without looking much deeper, I would suggest changing your alias to this:

    Ry1 VAR LATA.1
    Louie

  3. #3
    Join Date
    Nov 2011
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    Thank you Louie, I changed to LATA.1 then got a syntax error due to incorrect port use which I fixed. Now I get eleven lines of "error [177].......__CONFIG directives cannot be used with CONFIG directives" . And the LED still does not blink.

    Hebe

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    your version of pbp is ?
    is that the version of mpasm that shipped with pbp ? (looks like the one noah used)

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    the pbp 2.6 inc file for an 18f1220 looks like this
    ;************************************************* ***************
    ;* 18F1220.INC *
    ;* *
    ;* By : Leonard Zerman, Jeff Schmoyer *
    ;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
    ;* All Rights Reserved *
    ;* Date : 06/05/06 *
    ;* Version : 2.47 *
    ;* Notes : *
    ;************************************************* ***************
    NOLIST
    ifdef PM_USED
    LIST
    "Error: PM does not support this device. Use MPASM."
    NOLIST
    else
    LIST
    LIST p = 18F1220, r = dec, w = -311, w = -230, f = inhx32
    INCLUDE "P18F1220.INC" ; MPASM Header
    __CONFIG _CONFIG1H, _XT_OSC_1H
    __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    __CONFIG _CONFIG4L, _LVP_OFF_4L
    NOLIST
    endif
    LIST
    EEPROM_START EQU 0F00000h
    BLOCK_SIZE EQU 8

    i'm guessing your config should look like this , you need to check the config word for each setting
    I you version is older then , I can't help much more

    Code:
    asm
            __CONFIG    _CONFIG1H, _XT_OSC_1H
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L
    endasm
    Last edited by richard; - 24th July 2014 at 09:14. Reason: white space

  6. #6
    Join Date
    Nov 2011
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    Quote Originally Posted by richard View Post
    your version of pbp is ?
    is that the version of mpasm that shipped with pbp ? (looks like the one noah used)
    Hi Richard, I'm using PBP 2.6. Not sure if my MPASM shipped with it.

    Thank you
    Hebe

  7. #7
    Join Date
    Nov 2011
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    Quote Originally Posted by richard View Post
    the pbp 2.6 inc file for an 18f1220 looks like this



    i'm guessing your config should look like this , you need to check the config word for each setting
    I you version is older then , I can't help much more

    Code:
    asm
            __CONFIG    _CONFIG1H, _XT_OSC_1H
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L
    endasm
    Hi Richard, my P18F1220.inc does not look anything like that.
    I tried your config suggestion with slight mod ( see below) but it still does not work. I also tried with a copy of the .inc from MPLABX - also does not work.

    Ta
    Hebe
    -------------------------------------------------------------------
    asm
    __CONFIG _CONFIG1H, _INTIO2_OSC_1H;_XT_OSC_1H
    __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
    __CONFIG _CONFIG4L, _LVP_OFF_4L
    __CONFIG _CONFIG3H, _MCLRE_OFF_3H
    endasm
    ------------------------------------------------------------------------

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    two osc configs will confuse things try , also note the indentation


    Code:
    asm    or it could be #config
        __CONFIG _CONFIG1H, _INTIO2_OSC_1H
        __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
        __CONFIG _CONFIG4L, _LVP_OFF_4L
        __CONFIG _CONFIG3H, _MCLRE_OFF_3H
    endasm   or #endconfig
    its been ages since I used pbp 2.6
    pbp3 is easier
    Last edited by richard; - 24th July 2014 at 12:48. Reason: might be wrong

  9. #9
    Join Date
    Nov 2011
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    Hi, I have now installed MPLABX , PBP3 and MCSX. Now I get [ASM ERROR] 18F1220 NOVA BX.ASM (30) : Symbol not previously defined (_INTIO2_OSC_1H) .
    I've tried a lot of permutations and found that some config statements don't give an error and others give a similar error ( or errors ) as above.
    Any ideas?

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    in your pbp 3 directory you should have a folder called DEVICE_REFERENCE
    have a look in there for a pic18f1220.info file , all the possible config are listed there
    IN A FORMAT like this

    #CONFIG
    CONFIG WDTEN = OFF
    CONFIG PWRTEN = ON
    CONFIG BOREN = OFF

    CONFIG DEBUG = OFF
    CONFIG XINST = OFF
    #ENDCONFIG

  11. #11
    Join Date
    Nov 2011
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    Hi Richard , thank you for your patience.
    I tried all the changes you suggested but could not get it to work. I reverted back to PBP 2.6 and downloaded
    MPLAB 8.9 which contains MPASM v5.5. I now get a bit further with seven lines of errors
    similar to "overwriting previous address contents (0000)" .

    Hebe

  12. #12
    Join Date
    Nov 2011
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    Hi Richard , It's blinking now. I changed the config settings in the .inc file that exists in the
    PBP 2.6 folder and I have no config statements in my source program.
    Thank you very much for guiding me on this problem. Your help has given me confidence to continue migrating to 18F.
    Hebe
    Last edited by Hebemabo; - 25th July 2014 at 00:26.

  13. #13
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    glad you got it going.
    I'm not sure where to find the config statement syntax for each pic device for pbp 2.6 ,someone must know . at least pbp3 has the device reference files for you .

    I'm sure having to edit the inc files is not really the best solution . in all my old pbp2.6 projects it seems I set the fuses manually with the programmer , its not until I moved to pbp3 that I included fuse settings in my programs (maybe that's why)

  14. #14
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    Hi,
    Open the P18F1220.INC file (or the file for whatever device you're working with) in the MPASM directory of the MPLAB installation (ie C:\Program Files\Microchip\MPASM Suite\ for example.) Towards the end you'll find the various CONFIG options and to which CONFIG Word they "belong".

    /Henrik.

  15. #15
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    thanks henrik , I knew somebody would know where to find the info.
    its worth persisting on getting the config syntax right because editing the inc files will get very messy

  16. #16
    Join Date
    Nov 2011
    Posts
    18


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    Thank you Henrik, I have now removed the config statements from the PBP 2.6 18F1220.inc file
    and inserted the required config statements into my program. Works like a dream and no more
    interfering with the .inc file.
    I realise now that my problem was caused by the inclusion of the following lines in the PBP 2.6
    18F1220.inc file:
    "
    __CONFIG _CONFIG1H, _XT_OSC_1H
    __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    __CONFIG _CONFIG4L, _LVP_OFF_4L
    "
    I can't believe that this took thirty hours to resolve. I would most probably
    have abandoned this project if I hadn't received such patient and speedy assistance from
    you and Richard. And an added bonus - I don't have to go to the pains of buying new
    software tools and dealing with their idiosyncrasies.

    Hebe

  17. #17
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517


    Did you find this post helpful? Yes | No

    Default Re: 18F1220 newbie

    Hi,
    Yes, dealing with the CONFIG bits has got to be THE single most discussed issue on this very forum and, I'm guessing, on the various support channels to MELABS - which is probably why they changed it - for the better - when releasing PBP3. That change alone is IMHO worth the cost of an upgrade, not to mention the conditional compile feature but of course YMMV.

    Now that you've commented the CONFIG out of the .inc file you must remember to always include them in your source file when compiling for that particular device. If you don't they will default to their erased state.

    /Henrik.

Similar Threads

  1. 18F1220 A/D Converter
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 31st May 2011, 17:50
  2. 18F1220 fuse help
    By mr.sneezy in forum General
    Replies: 6
    Last Post: - 24th May 2010, 15:54
  3. 18F1220 LCD and Sleep
    By jderson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th July 2008, 19:58
  4. 18F1220 and DT Instant Interrupts
    By jderson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th June 2008, 06:37
  5. Sleep command with 18F1220
    By suded in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 7th April 2005, 12:11

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