bootloader that xfers code from I2C into program memory


Closed Thread
Results 1 to 31 of 31

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: bootloader that xfers code from I2C into program memory

    1) Redundant read of same memory location. Just to be sure that there is no error in communication. Same at writing, write 32 bytes, then read them, and compare. Just to on safe side.
    2) Scroll little bit down
    Code:
    'Optional Erase I2C EEPROM
        FOR Adr=0 TO 79999 STEP 128
            MAdr=Adr.WORD0
            MCtrl=$A0 + ((Adr.BYTE2 & %00000011)<<1)
         BootI2CW:
            I2CWRITE Mem_Sda,Mem_Scl,MCtrl,MAdr,[STR EraseStr\128],BootI2CW
            PAUSE 5
    Just easy way to dump 128 zeros in memory.
    3) Not sure what you are asking, but that is code for bootloader in main app. That code will sit there forever. And execute when jump to label.
    Output of first 32 line from random project in MPLAB X program windows(right click output to file)
    Code:
           Line      Address       Opcode           Label                        DisAssy                 
            1    00000         EF30                             GOTO 0x260                               
            2    00002         F001                             NOP                                      
            3    00004         FFFF                             NOP                                      
            4    00006         FFFF                             NOP                                      
            5    00008         0012                             RETURN 0                                 
            6    0000A         FFFF                             NOP                                      
            7    0000C         FFFF                             NOP                                      
            8    0000E         FFFF                             NOP                                      
            9    00010         FFFF                             NOP                                      
           10    00012         FFFF                             NOP                                      
           11    00014         FFFF                             NOP                                      
           12    00016         FFFF                             NOP                                      
           13    00018         0012                             RETURN 0                                 
           14    0001A         010F         HSEROUT             MOVLB 0xF                                
           15    0001C         0004         hseroutloop         CLRWDT                                   
           16    0001E         A89E                             BTFSS PIR1, 4, ACCESS                    
           17    00020         D7FD                             BRA hseroutloop
    Similar thing you will get when compile bootloader, but at different start address. And you need to copy opcode column to to your main program and address must lineup.
    I'm not sure that I answered your question.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: bootloader that xfers code from I2C into program memory

    Got it, thanks.

    Makes sense

    picster

  3. #3
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: bootloader that xfers code from I2C into program memory

    Great!
    Did you try to compile code for 16F with RESET_ORG?

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: bootloader that xfers code from I2C into program memory

    YUP, and it worked fine Had to download MPLABX before continuing...

    I'll be writing a small program for Windows to xfer the code via RS-232 INTO the I2C EEPROM (which the Pic's main program will manage), in order to test it properly. Weekend stuff.

    Will let you know how it works out, but this looks really promising, thanks again!

  5. #5
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: bootloader that xfers code from I2C into program memory

    Take look at microchip AN851. That is VB6 application for bootloader.
    I used that as starting point for my VB .net app.
    Other solution is to export hex file as text, eg from MPLAB X program windows or some programmer software.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: bootloader that xfers code from I2C into program memory

    Will have a look - I use VB6 a fair bit so that should work out well. Thx!

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: bootloader that xfers code from I2C into program memory

    Ok, so far so good with a little test program for calling code that's pre-compiled in upper program memory, so I think I'm on track.

    Item of note for the 16F series (I'm using the 16F1788):

    DEFINE RESET_ORG 36B0h
    *****also needs*****
    DEFINE USE_LINKER 1

    Both lines must be present when generating the "upper memory code" above 800h.
    (otherwise there's a compile error re: library exceeding address 800h - found this little gem here:
    http://www.picbasic.co.uk/forum/show...+cannot+exceed )

    I generated the complied hex, then copied it out of MPLAB, pasted in a text file, did a little search/replace and editing, and pasted the result at the end of the program as ASM as you demonstrated...

    used a goto to jump to it at the beginning of my program, and it worked like a charm.

    Looking at the resulting compiled hex shows the "upper space subroutine" right where it should be.

    I'll let you know how the xfer from i2c goes, but I can't foresee any issues at this rate.

  8. #8
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: bootloader that xfers code from I2C into program memory

    Great!
    I started with led blink, and worked from there.
    Good luck, and keep us posted

Similar Threads

  1. Program Code and Program Memory
    By DenFrod in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th February 2007, 14:51
  2. Use internal program memory like DATA memory
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th December 2006, 18:38
  3. using Flash Program Memory ?
    By muskut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th October 2006, 15:17
  4. PIC16F88, Bootloader & I2C Memory
    By digilord in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th December 2005, 15:36
  5. program memory size
    By volcane in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 25th October 2005, 19:45

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