Not getting output after flashing firmware using mikrobootloader gui

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

Not getting output after flashing firmware using mikrobootloader gui

#1 Post by kumar123 » 30 Mar 2024 07:57

Hi,
I have MCU pic18f67k40 device.
1) I flash this mcu with the bootloader code. using pickit3 which is called programmer. Initially, I successfully flashed the MCU with the bootloader code utilizing a PICKIT3 programmer. The provided code snippet demonstrates the bootloader functionality, indicating a defined memory organization and essential functions such as UART communication and flash writing procedures.
This is the mikrobootloader code

Code: Select all

#pragma org 0x01C000 //0x01C000
#define BOOTLOADER_START_ADDR 0x01C000 //0x01C000
#define START_PROGRAM_ADDR 0x01C300 //0x01C300

static char block[64];

void Start_Program() org START_PROGRAM_ADDR {}

unsigned short UART_Write_Loop(char send, char receive) {
    unsigned int rslt = 0;
    //unsigned int start_time = TickGet();  , unsigned int timeout_ms
    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);
    block[0] = 0x00;
    block[1] = 0xEF;
    block[2] = 0xE0;
    block[3] = 0xF0;
}

void Start_Bootload() {
    char i = 0, xx, yy;
    long j = 0;

    while (1) {
        if (i == 64) {
            if (!j)
                Write_Begin();
            if (j < BOOTLOADER_START_ADDR) {
                FLASH_Write(j, block);
            }
            i = 0;
            j += 0x40;
        }

        UART1_Write('y');
        while (!UART1_Data_Ready());
        yy = UART1_Read();

        UART1_Write('x');
        while (!UART1_Data_Ready());
        xx = UART1_Read();

        block[i++] = yy;
        block[i++] = xx;
    }
}

void main() org BOOTLOADER_START_ADDR {
    TRISC6_bit = 0;   // Tx pin set as output
    TRISC7_bit = 1;   // Rx pin set as input
    UART1_Init(9600);
    Delay_ms(10);
    if (UART_Write_Loop('g', 'r')) {
        Start_Bootload();
    } else {
        Start_Program();
    }
}
And this is the application code: simple test code

Code: Select all

void main()  {

     TRISC6_bit = 0;   // Tx pin set as output
     TRISC7_bit = 1;   // Rx pin set as input

     UART1_Init(9600); // Initialize the UART with a baud rate of 9600
     Delay_ms(4);

     while(1){
        UART1_Write('A');
        Delay_ms(1000);
     }
}
2) After flashing the MCU with the provided code, I received the 'g' character, indicating readiness for new application code such as LED blinking. However, upon programming the MCU with the Mikrobootloader GUI via UART, I did not receive any output on the Putty terminal.

3) Furthermore, when I attempted to reconnect after not receiving any data following the MCU programming with the Mikrobootloader GUI and UART, I found that it is no longer connecting through the same method.
this uC have 128K programmable flash memory,
Maybe I am not sure the addresses I am using in my above code is correct for the boot-loader code or not.
If anyone knows how to select these address #define BOOTLOADER_START_ADDR 0x01C000 //0x01C000, #define START_PROGRAM_ADDR 0x01C300 //0x01C300
please let me know

Regards,
Kumar

Post Reply

Return to “mikroC PRO for PIC General”