16f887 to 18f4685 transition


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 16f887 to 18f4685 transition

    Goto the *.inc file in the PBP directory and comment out the config lines so it looks like this:
    Code:
    ;****************************************************************
    ;*  18F4685.INC                                                 *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2008 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 09/15/08                                        *
    ;*  Version   : 2.60                                            *
    ;*  Notes     :                                                 *
    ;****************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            "Error: PM does not support this device.  Use MPASM."
            NOLIST
        else
            LIST
            LIST p = 18F4685, r = dec, w = -311, w = -230, f = inhx32
            INCLUDE "P18F4685.INC"	; MPASM  Header
         ;   __CONFIG    _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
         ;   __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
         ;   __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
         ;   __CONFIG    _CONFIG4L,  _STVREN_ON_4L & _LVP_OFF_4L & _BBSIZ_1024_4L & _XINST_OFF_4L
            NOLIST
        endif
            LIST
    EEPROM_START	EQU	0F00000h
    BLOCK_SIZE	EQU	64
    Then in your code;
    Code:
    '18F4685 TEST
    
        @ __CONFIG    _CONFIG1H, OSC_IRCIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
        @ __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
        @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
        @ __CONFIG    _CONFIG4L,  _STVREN_ON_4L & _LVP_OFF_4L & _BBSIZ_1024_4L & _XINST_OFF_4L
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default Re: 16f887 to 18f4685 transition

    I'm sorry but that didn't seem to work either, but I have a few questions now. The WDT, was that set to 512 to somehow complement the 8MHz oscillation speed? Also this config line:

    Code:
    _BBSIZ_1024_4L
    Does this let the chip change variable values while it's running or does it allow the chip to add code (a FOR...NEXT loop for example) to itself while in operation?


    By the way, thanks for the time and help thus far

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 16f887 to 18f4685 transition

    BBSIZ is the Boot Block Size.

    Goto
    C:\Program Files\Microchip\MPASM Suite
    and find the file "P18F4685.INC"
    That is where you will find all of the config options, near the end of the file. Do not modify this file.

    So, you are saying that the code does not compile from post #9?
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default Re: 16f887 to 18f4685 transition

    The code does compile 100% no errors, but it runs improperly. I am getting scrambled characters from the HSERIN/HSEROUT commands when the program is on the 18f4685, but when the program is on the 16f887 it works perfectly.

    Here is how I have the 16f887 initialized (I did not use any config settings here)

    Code:
    Define device 16F887
    Define OSC 8
    ANSEL=0 ' A/D disabled for ANS0 to ANS7
    ANSELH=0 ' A/D disabled for ANS8 to ANS13
    CM1CON0 = 0 ' Disable comparators
    CM2CON0 = 0 ' These default to disabled at POR, but just in case
    CM2CON1 = 0
    ADCON1 = 7
    IOCB = 0
    INTCON = 0
    
    DEFINE HSER_RCSTA 90h ' Enable Serial PORT
    DEFINE HSER_TXSTA 24h ' Enable transmit
    DEFINE HSER_SPBRG 129 ' set USART to 9600 baud (when BRGH=1)
    DEFINE HSER_CLROERR 1 ' Enable automatic overrun error
    DEFINE LOADER_USED 1
    and this is how the 18f4685 is initialized

    Code:
    define device 18f4685
    @ __CONFIG    _CONFIG1H, _OSC_IRCIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    @ __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    @ __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    @ __CONFIG    _CONFIG4L,  _STVREN_ON_4L & _LVP_OFF_4L & _BBSIZ_1024_4L & _XINST_OFF_4L
    OSCTUNE = %11000000
    OSCCON = %01110000
    define OSC 8
    CMCON = 0
    ADCON0 = 7
    ADCON1 = 7
    ADRESH = %00000000
    ADRESL = %00000000
    INTCON = 0
    INTCON2 = 0
    INTCON3 = 0
    IPR1 = 0
    PIR1 = 0
    PIE1 = 0
    
    
    DEFINE HSER_RCSTA 90h ' Enable Serial PORT
    DEFINE HSER_TXSTA 24h ' Enable transmit
    DEFINE HSER_SPBRG 129 ' set USART to 9600 baud (when BRGH=1)
    DEFINE HSER_CLROERR 1 ' Enable automatic overrun error
    DEFINE LOADER_USED 1
    The rest of the program has remained unchanged.
    Last edited by emerson; - 21st July 2012 at 20:37.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 16f887 to 18f4685 transition

    Set
    OSCTUNE = %00000000

    And try this
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 51  ' 9600 Baud @ 8MHz, 0.16%
    SPBRGH = 0
    BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Dec 2010
    Posts
    48


    Did you find this post helpful? Yes | No

    Default Re: 16f887 to 18f4685 transition

    these changes make it so the only symbol transmitted the "≡" symbol instead of receiving mixed characters and symbols

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 16f887 to 18f4685 transition

    I think it is time to provide your code and schematic.
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 0

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