MCLoader & XPort


Closed Thread
Results 1 to 40 of 45

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default A simple loader

    This might help, rename it to .bas

    /me
    Attached Files Attached Files
    Last edited by Jumper; - 24th August 2006 at 11:37.

  2. #2
    Join Date
    Aug 2006
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Jumper,

    A few basic questions about your file:

    1) "DEFINE LOADER_USED 1 'Sets loader at address defined in Library file"
    Does this refer to a modified library file as explained earlier in this thread?

    2) "RB6 var PORTB.6; RB7 var PORTB.7"
    I assume these are just 'flag' bits to tell you which mode the chip is in?

    3)"IF temp=$FFFF then STOP"
    What happens after the 'STOP'?

    4) "@GOTO 0x0040"
    Why 0x0040?'

    5) "'Erase before writing and write full blocks 64 bytes"
    Do you suggest writing the erase and program code in assembly, or can it be done in PBP?

    Joe

  3. #3
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Like this

    1: YES, just like that, put in the address where you want to loader to be in the LIB file.

    2: Rb6 and Rb7 are connected (same for both): RB6 ---> 470 ohm ---> LED ----> GND or any other pin can do the same.

    So when they are high the led is turned on, just for fun. (and to see what is happening)

    3: STOP makes the PIC to STOP dead as I don't want it to jump to an "empty" address and then run thru the entire empty program memory and end up in the loader again. If you want to you can go back to INIT to loop inside wait for the byte.

    4: Because your application software should start 64 bytes into the program memory. This is done by DEFINE RESET_ORG 64 in your application software. This is so we don't have to erase block 0 and therefore can never end up in a position where we can no longer access the loader. DEC 64 = HEX 0040 and the @GOTO must be a hex number.

    If you dont want to do this you can set the LOADER_USED line back to the default in the LIB file and then your code will end up starting from address 8 as it probably do today by DEFINE LOADER_USED 1. But then you need to store the data you want to keep from block 0 before erasing it and then write this data back together with the new data. This will take more than 28 intructions so you will lose less space if we start from adr 64.



    5: ERASECODE address will erase the entire block that the address variable is a part of.
    WRITECODE will write a BYTE or WORD variable to a position in the memory but you have to write 32 WORDS or 64 BYTES for it to be transferred to the memory.

    So get the data from somewhere (an array is usually good) and write it with a for-next loop. I don't think WRITECODE will accept an array as a valid argument so you better load it in a temorary variable and use the temorary variable in the WRITECODE command.

    Check the manual about these commands. There is no need for any assembler at all in this project, just use pbp!

    I am not really sure how assembler commands will work with this setup, you might end up in the wrong RAM bank or something. I have not tried it and I dont' plan to either. As long we stay with PBP commands it should be safe.


    /me
    Last edited by Jumper; - 24th August 2006 at 14:50.

  4. #4
    Join Date
    Aug 2006
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Thanks Jumper, this should be an interesting project. I'll work on it as I get time, and I'll let you know how things are progressing.

    Thanks again!

    Joe

  5. #5
    Join Date
    Aug 2006
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Jumper,

    Just had a look at the .lib file. It seems to that, instead of permanently redefining an existing DEFINE (which would have the effect of making existing projects incompatible), I could just create some new DEFINEs to do this job. Is there any problem with that?

    Joe

  6. #6
    Join Date
    Aug 2006
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    This thread, which I find very interesting, has really gotten off-topic from the title. Does anyone know how to split this off into another thread, maybe titled something like "Implementing a Bootloader in PBP?

    Joe

  7. #7
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default It seems to work

    ifdef MAKE_LOADER
    LIST
    ORG 60160 ; type the adress for loader here
    NOLIST
    endif


    I added this Define in the LIB file and changed in my code to :

    DEFINE MAKE_LOADER 1

    and it works just fine. Now we don't have to hijack any other defines. So now we have a new DEFINE in PBP.

    If someone brilliant can find a way to send the address variable from PBP it would be great. I would like it to look similar to the:

    DEFINE RESET_ORG 64 where you include the value to be compiled.

    Like:

    DEFINE MAKE_LOADER 60160

    then there would be no need to change in the LIB file if you wanted an other address for the loader. Is that possible????

    /me

  8. #8
    Join Date
    Aug 2006
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Jumper,

    I made the .lib modification and modified your code to read back 16 memory locations starting at 60106. Data coming back from the read is all FF's, so it looks like there's no program located there.

    Comments?

    Joe

    ================================================== ======

    DEFINE MAKE_LOADER 1 'Code will begin at 60160


    DEFINE HSER_RXSTA 90h
    define HSER_TXSTA 24h
    DEFINE HSER_BAUD 9600
    define OSC 8
    OSCCON = $FF
    TRISB=%00111111
    TRISC=%10111111


    RB6 var PORTB.6
    RB7 var PORTB.7

    TX Var PORTC.6
    RX Var PORTC.7
    '************************************************* ********************************************
    I VAR BYTE
    x var byte
    Flash var word
    Temp var word

    '************************************************* ********************************************

    Goto INIT


    '************************************************
    jump_back:
    'Flash=64
    'READCODE flash, temp 'Read the value at Flash adr
    'IF temp=$FFFF then STOP 'If it is $FFFF we have no application code in the PIC so STOP
    '@ GOTO 0x0040 'Start application
    '*************************************************

    'Here we decide if we should enter the Loader or not receiving a byte.

    INIT: Pause 200 'wait for things to settle
    Rb6=1 'indicate we are waiting for a character
    HSERin [x] 'if nothing after 5 sek go to jump_back
    if x="L" then
    PAUSE 100
    Goto Loader
    ENDIF 'If it is what we want to get then enter the laoder
    goto Jump_Back 'everything else jump_back

    '************************************************* ****************

    Loader:
    FOR I = 0 TO 15
    READCODE (60610 + I),X
    hserout [$0D, $0A, ":", HEX(X)," "]
    NEXT I
    RB7=1 'Indicate we have entered the Loader
    RB6=0
    pause 200

    'Here we can recieve new data and write it to the FLASH
    'Erase before writing and write full blocks 64 bytes
    '

    goto Jump_Back 'When finished goto
    END
    '************************************************* ********

Similar Threads

  1. xport code, have example, confused though
    By kenpo in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 30th March 2009, 19:59
  2. Bootloader and Instant Interrupts Atn:_DT_
    By Josuetas in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th May 2007, 01:59
  3. McLoader and 18F2580
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th February 2007, 06:20
  4. xport + connecting 2 networks
    By rf_xport in forum General
    Replies: 0
    Last Post: - 12th July 2006, 06:26
  5. Has anyone used the Lantronics Xport
    By octavio bru in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 14th September 2004, 11:51

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