How to get orgall, BOOTLOADER_START_ADDR,START_PROGRAM_ADDR Adress for pic18f67k40 uC

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
kumar123
Posts: 68
Joined: 17 Oct 2023 07:32

How to get orgall, BOOTLOADER_START_ADDR,START_PROGRAM_ADDR Adress for pic18f67k40 uC

#1 Post by kumar123 » 27 Dec 2023 10:44

Hi,
I have a problem with the micro-controller bootoader code. I don't know from where they are taking these address in code to start program.
I am using pic18f67k40 uC.

Code: Select all

#include <built_in.h>
#pragma orgall 0x7CC0
#define BOOTLOADER_START_ADDR 0x7CC0
#define START_PROGRAM_ADDR 0x7FC0
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_Erase_Write_64(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_Erase_Write_64(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();
    }
}
In this code they are using pic18f67k22.

Regards,
Kumar

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: How to get orgall, BOOTLOADER_START_ADDR,START_PROGRAM_ADDR Adress for pic18f67k40 uC

#2 Post by IvanJeremic » 28 Dec 2023 10:27

Hi,

Your ORGALL should be around 1 C000 for your specific MCU.

You can take a look in the Memory Organization segment of the datasheet for your specific MCU for ore information.
https://download.mikroe.com/documents/d ... asheet.pdf

Regards,

Ivan.

kumar123
Posts: 68
Joined: 17 Oct 2023 07:32

Re: How to get orgall, BOOTLOADER_START_ADDR,START_PROGRAM_ADDR Adress for pic18f67k40 uC

#3 Post by kumar123 » 02 Jan 2024 06:36

Hi,
I am not able to find the START_PROGRAM_ADDR in this document for my bootloader code program, that you have shared with me.
I have found ORGALL Address, BOOTLOADER_START_ADDR, that you have mentioned in previous post. I am using pic18f67k40 uC. Could you suggest?

Regards,
Himanshu Kumar

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: How to get orgall, BOOTLOADER_START_ADDR,START_PROGRAM_ADDR Adress for pic18f67k40 uC

#4 Post by IvanJeremic » 15 Jan 2024 12:14

Hi,

I have answered you in the forum from the link below:
viewtopic.php?f=88&t=80448&p=318052#p318052

Lets continue our conversation there.

Regards,

Ivan.

Post Reply

Return to “mikroC PRO for PIC General”