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 for Pic18F45k22

Status
Not open for further replies.

anboli

Full Member level 2
Joined
Mar 9, 2012
Messages
144
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Activity points
2,512
Hi everybody,
Im very new to this bootloader concept. Please suggest how to write the bootloader program for 18f45k22? and how to use it? I studied basic things about the bootloader and its working. but im struggling to get the proper way to write it. Please suggest.

Thanks to all.
 

Hello,

Check on MIkroElektronika
they have a bootloader using USB <-> FTDI <-> UART1
look at Ready for PIC18F45K22

**broken link removed** and use it (with Mikro C Pro) and very usefull.. power the board and load application trough Mikroe HID Serial Bootloader

or on Microchip site ?


to load a bootloader into an empty PIC, you need a classic programmateur like PIckit2 or 3, via ICSP connection
 

Hello,

Check on MIkroElektronika
they have a bootloader using USB <-> FTDI <-> UART1
look at Ready for PIC18F45K22

**broken link removed** and use it (with Mikro C Pro) and very usefull.. power the board and load application trough Mikroe HID Serial Bootloader

or on Microchip site ?


to load a bootloader into an empty PIC, you need a classic programmateur like PIckit2 or 3, via ICSP connection

thanks for reply,

Im using CCS Compiler for my Code. And i need a bootloader sample program for my controller. If i get this i can study out the program and its functions. Program in CCS is most appreciable.. Please give me any idea..
 

Check out the Microchip site as well as I think they have several bootloader code examples, including for the PIC18F family of devices.
However I suggest that you add the bootloader to your project as the very last step before you push your product into the field.
In general bootloaders do not allow you to debug your program. This really means that you need to go through all of the app debugging stage using the ICSP programmer (as pointed out above, you will need one of those anyway).
Once the code is fine, then you need to make sure that you have left enough space for the bootloader code and adjust things so that you do. You will also need to determine how you want to switch between the program and the bootloader both when the device powers up and while it is running(if that is required).
Bootloaders are wonderful when your device is begin used in production but they can be a major pain if you try to implement them too soon.
Susan
 

This is the bootloader program where i downloaded from the Web.

Code:
/*
 * Project name:
     Boot_Test (using mikroC Bootloader on PIC18's)
 * Copyright:
     (c) Mikroelektronika, 2008.
 * Revision History:
     20111017:
       - initial release
 * Description:
     This is a serial port Bootloader implementation. All required bootloader
     routines are placed in the boot18_32K file, the only thing that is
     user-configurable is the baudrate of the UART communication, which is set
     in the main() through appropriate call to Uart_Init(brg_reg).
     Once started in PIC, the bootloader waits for a while (approx. 5 seconds)
     to establish UART communication with the MikroBootloader application on the
     PC. If it fails to do so, the bootloader starts the programme already
     loaded in the MCU (initially it is just a NOP). If the communication is
     established, the bootloader receives the hex file from the PC and places it
     where requred (the MikroBootloader application reads out the hex file and
     takes care of the location where hex is to be placed). When hex download
     has finished, the user is notified by the MikroBootloader to reset the MCU,
     and MCU enters the described bootload sequence again.
 * Test configuration:
     MCU:             PIC18F45K22
                      http://ww1.microchip.com/downloads/en/DeviceDoc/41412D.pdf
     Dev.Board:       EasyPIC7
                      http://www.mikroe.com/easypic/
     Oscillator:      HS-PLL, 32.00000 MHz
     Ext. Modules:    None.
     SW:              mikroC PRO for PIC
                      http://www.mikroe.com/mikroc/pic/
 * NOTES:
     - It's recommended not to alter the start address of the main().
       Otherwise, less space in ROM will be available for the application being bootloaded.
     - RX and TX UART switches SW1.1, SW2.1 on EasyPIC7 should be turned On (board specific).
 */

#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() org BOOTLOADER_START_ADDR{
  ANSELC = 0;                         // Configure PORTC pins as digital
  UART1_Init(115200);                 // Init USART at 115200
  if (UART_Write_Loop('g','r')) {     // Send 'g' for ~5 sec, if 'r'
    Start_Bootload();                 //   received start bootload
  }
  else {
    Start_Program();                  //   else start program
  }
}

..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top