Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Bootloader code is not working for pic18f67k40 in mikroC pro for pic

kumarr123

Junior Member level 1
Joined
Oct 18, 2023
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
155
Hi,
I had tried to compile the bootloader code from the mikroE example code for pic18f67k40 microcontroller in mikroC pro for pic. The below code I have tried-
Code:
#include <built_in.h>
#pragma orgall 0x1C000
#define BOOTLOADER_START_ADDR 0x1C000
#define START_PROGRAM_ADDR 0x01FFFF
static char block[64];
void Start_Program() org START_PROGRAM_ADDR{}
unsigned short UART_Write_Loop(char send, char receive){
  unsigned int rslt = 0;
  while(1){
    Delay_5ms();
    UART1_Write(send);
    Delay_5ms();

    rslt++;
    if (rslt == 0x0200)
      return 0;
    if (UART1_Read() == receive)
      return 1;
  }
}
void Write_Begin(){
  FLASH_Write(START_PROGRAM_ADDR, block);
  //--- goto main
  block[0] = 0x60;  //0xF03EEF60
  block[1] = 0xEF;
  block[2] = 0x3E;
  block[3] = 0xF0;
}
void Start_Bootload(){
  char i = 0, xx, yy;
  long j = 0;

  while (1) {
    if (i == 64) {
      //--- If 32 words (64 bytes) recieved then write to flash
      if (!j)
        Write_Begin();
      if (j<BOOTLOADER_START_ADDR){
           FLASH_Write(j, block);
      }

      i = 0;
      j += 0x40;
    }
    //--- Ask for yy
    UART1_Write('y');
    while (!UART1_Data_Ready()) ;
    //--- Read yy
    yy = UART1_Read();
    //--- Ask for xx
    UART1_Write('x');
    while (!UART1_Data_Ready()) ;
    //--- Read xx
    xx = UART1_Read();
    //--- Save xxyy in block[i]
    block[i++] = yy;
    block[i++] = xx;
  }
}
void main() {
    /*LATC  = 0;
    LATB = 0;
    PORTC = 0;
    TRISC = 0;
    PORTB = 0;
    TRISB = 0;*/
    UART1_Init(9600);
    if (UART_Write_Loop('g','r')) {
         Start_Bootload();
    }
    else {
         Start_Program();
    }
}

After compiling this code I am receiving this error-
orgall1.png


any suggestions for this will be appreciated

Regards,
Kumar
 
Hi,
I have copied it from the mikroelectornika support forums.
We - who want to help - need informations we can validate. So just saying "from mikroelecornika forum" is not very helpful. Not helpful for us .. and thus not helpful to solve the problem.

--> Better: give the exact link to the source/site where the code is located.
So we can see the whole story about the code, the context.
Then we are able to check various things around this code. Whether it needs special compiler settings, or others also had trouble.

Klaus
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top