Migrating code from 16F627 to 16F628A: Getting errors

Discussion in 'Embedded Systems and Microcontrollers' started by cometravi, Apr 18, 2013.

  1. cometravi

    Thread Starter New Member

    Apr 18, 2013
    2
    0
    Hi,
    This is about a stepper motor controller that is used to control two axes of a telescope. The OEM controller died and an old circuit which uses the 16F627 was available, which I built. However I couldnt get my hands on the 16F627 and instead got the 16F628A. Most of the sub control functions dont work but the stepper moves.

    Here is the link to the circuit design and txt source code. The files are RAhalfdriveN and DecDrive.

    http://homepage.ntlworld.com/telescope/Projects/PICcontroller.htm

    The source code may need to be reassembled was my guess. So i tried that but am getting errors. I am using MPLAB IDE 8.90. I copied the txt file content onto MPLAB, saved as an .asm file, selected device as 16F628A, changed627 to 628A in the source code txt file i.e. list p=16f628a and #include <p16f627.inc>

    Just got into this programming bit very recently and my knowledge is very limited here so could use all the pointers and help I can get.

    Thanks for helping.

    -------------------
    ----------------------------------------------------------------------
    Release build of project `R:\Other Hobbies\Code\RAHDRIVEN.disposable_mcp' started.
    Language tool versions: MPASMWIN.exe v5.49, mplink.exe v4.47, mplib.exe v4.47
    Fri Apr 19 08:11:09 2013
    ----------------------------------------------------------------------
    Clean: Deleting intermediary and output files.
    Clean: Done.
    Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F628A "RAHDRIVEN.asm" /l"RAHDRIVEN.lst" /e"RAHDRIVEN.err"
    Message[310] R:\OTHER HOBBIES\CODE\RAHDRIVEN.ASM 67 : Superseding current maximum RAM and RAM map.
    Error[149] R:\OTHER HOBBIES\CODE\RAHDRIVEN.ASM 136 : Directive only allowed when generating an object file
    Error[149] R:\OTHER HOBBIES\CODE\RAHDRIVEN.ASM 141 : Directive only allowed when generating an object file
    Error[118] R:\OTHER HOBBIES\CODE\RAHDRIVEN.ASM 148 : Overwriting previous address contents (0000)
    Error[118] R:\OTHER HOBBIES\CODE\RAHDRIVEN.ASM 148 : Overwriting previous address contents (0000)
    Message[302] R:\OTHER HOBBIES\CODE\RAHDRIVEN.ASM 159 : Register in operand not in bank 0. Ensure that bank bits are correct.
    Message[302] R:\OTHER HOBBIES\CODE\RAHDRIVEN.ASM 163 : Register in operand not in bank 0. Ensure that bank bits are correct.
    Message[302] R:\OTHER HOBBIES\CODE\RAHDRIVEN.ASM 166 : Register in operand not in bank 0. Ensure that bank bits are correct.
    Halting build on first failure as requested.
    ----------------------------------------------------------------------
    Release build of project `R:\Other Hobbies\Code\RAHDRIVEN.disposable_mcp' failed.
    Language tool versions: MPASMWIN.exe v5.49, mplink.exe v4.47, mplib.exe v4.47
    Fri Apr 19 08:11:10 2013
    ----------------------------------------------------------------------
    BUILD FAILED
    -------------------------------------

    (Code is already available from the author on the weblink mentioned above so hoping its not an issue attaching it here)

    Really hoping someone can help out here...
     
  2. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,645
    759
    Have you checked if there is any document about migrating from 16F627 to 628A?

    Check the pins used in the 627 and see if their equivalents in the 628A are involved in any different peripheric module.

    Pins, by default are set as analog inputs and could require their explicit setting as digital ones. Maybe you have the wrong ones.

    Are interrupts used? If so, check where the IRS should be located.

    Memory organization, I bet is different. Check also that.

    THe 627 predates the 628A. You could suspect that maybe one or two peripherics were added thus more chances of differences.

    The 16F family makes you to deal intimately with banks of RAM. Make sure that the registers involved are in the same bank in both micros.

    Even if ID numbers are close, treat any micro as a different one. When you move to a new micro, a very careful check of everything, albeit lenghty and eventually tedious could save you hours / days of chasing ghosts.

    But to go ahead with the above you should be able to understand the code. Can you?

    Buena suerte
     
    Last edited: Apr 19, 2013
  3. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    There's a lot in there that is already in the .inc file and a little of it interferes with the 16F628A
    Remove all lines containing BADRAM and MAXRAM

    There's a part of the code that is for relocatable instead of absolute compiling. That doesn't really matter so just compile the same way you did before, but replace everything from "RESET_VECTOR" to "MAIN CODE" inclusive with:
    ORG 0X000
    goto start

    I think everything should be OK after that.
     
  4. cometravi

    Thread Starter New Member

    Apr 18, 2013
    2
    0
    Thanks Agustin & Mark.

    Do I understand code...not as intimately as I would like. So short answer is no. Any help is welcome.

    Mark will try your method and post results...
     
  5. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Forgot to mention, you will still get the message[302] lines on the report, they are nothing to worry about.
     
  6. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,022
    The attached modified source builds with no errors/warnings.

    The code was originally written as RELOCATABLE and several of the constructs used are incompatible with absolute mode so I would leave it that way, although changing to ABSOLUTE would be an option as Mark shows you. (I personally prefer ABSOLUTE mode). But, for minimum code changes, change Project->Build Options->MPASM Suite to RELOCATABLE.

    I peppered the code with MESSG directives to identify what I changed. It wasn't much, mainly updates to use the newer MPLABs. These show up in the build window or search the source for MESSG. Read them and delete them.

    EDIT: Hopefully this used the default linker scripts (probable). Otherwise, you'll have to make sure that the RAM etc is properly located. It should be but you never know when working with other people's code. If it isn't, hey.. Welcome to programming!

    Agustín Tomás:
    That's good advice.
    You can still get the 627's on Microchip Direct if you don't want to mess with an upgrade.

    Have fun!
     
    Last edited: Apr 19, 2013
  7. Bjornk

    New Member

    Jan 28, 2013
    12
    0
Loading...