Modifying bootloader code

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
Bushman
Posts: 27
Joined: 11 Apr 2006 16:55
Location: Canada

Modifying bootloader code

#1 Post by Bushman » 27 Aug 2010 18:00

I have been experimenting with a bootloader code found in:
X:\Program Files\Mikroelektronika\mikroC PRO for PIC\Examples\Other\Bootloader\P18\032K
and the boot loader works just perfect, after I programed the code with the programmer I was able to bootload my program successfully.

But I need to add several lines to the boot loader code and ufortunately I was not able to compile the code I get this error message: “109 361 Bad function absolute address 'Susart_Write_Loop[32156]' boot18_32K.c”

In the code below you can see my several lines added, they control a switch which routes PIC's USART to MAX232 chip in my device so I could reprogram it at any time I need. I have no idea how to calculate new addresses for the functions, I there a way to fix this problem ?

Thank you.
I use PIC18F452 (not 4520), EasyPIC3, Mikro C Pro 3.8

Code: Select all


//-------------- Boootloader main for 32K PIC18's
void main() org 32112 {

// My code begin
       TRISB = 0;
       TRISD = 0;
       PORTB.F3 = 1; //
       PORTD.F0 = 0; // 2OE - A5
       PORTD.F1 = 0; // 1OE - E2
       PORTD.F2 = 1; // S1  - E1
       PORTD.F3 = 0; // S0  - E0
// my code end

    // 16Mhz --> 103           look for asynchronous high speed table
    //  8Mhz -->  51
    //  4Mhz -->  25
    //            |
    //            |
    //            |
    //           \ /
    //            |

    Susart_Init(51);                    // Init USART at 9600
    if (Susart_Write_Loop('g','r')) {   // Send 'g' for ~5 sec, if 'r'
      Start_Bootload();                 //   received start bootload
    }
    else {
      Start_Program();                  //   else start program
    }

}
 

Bushman
Posts: 27
Joined: 11 Apr 2006 16:55
Location: Canada

Re: Modifying bootloader code

#2 Post by Bushman » 28 Aug 2010 07:28

I was able to fix this problem, I squeezed my function in between the other two, there was some room between them, and now the bootloader executes my code, you guys might find it useful as well.

this code was added in boot18_32K.c

Code: Select all

void myCode() org 32684
{
  TRISB = 0;
  TRISD = 0;
  PORTB.F3 = 1;
  PORTD.F0 = 0; // 2OE D0
  PORTD.F1 = 0; // 1OE D1
  PORTD.F2 = 1; // S1  D2
  PORTD.F3 = 0; // S0  D3
}

Post Reply

Return to “mikroC PRO for PIC General”