Overlapping addresses of 128k flash memory

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

Overlapping addresses of 128k flash memory

#1 Post by kumar123 » 01 Apr 2024 13:27

Hello,

I'm encountering an issue with my PIC18F67K40 microcontroller. It has 128k bytes of flash memory. After programming the MCU using MikroBootloader GUI and UART, I'm not receiving any output. Here are the steps I'm following:

I program the MCU using bootloader firmware with the help of PICkit3.
Then, I flash a simple "Hello" program onto the MCU using MikroBootloader GUI and UART.
Despite these steps, I'm not getting any output. I suspect there might be an address overlapping problem causing this error.
This below code I have

Code: Select all

#pragma org  0x01C000     //01C000
#define BOOTLOADER_START_ADDR 0x01C000
#define START_PROGRAM_ADDR  0x01C300   //0x1C298


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;   //hi byte
    block[1] = 0xEF;   //opcode
    block[2] = 0xE0;   //lo byte
    block[3] = 0xF0;   //opcode
}

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();
    }
}
data sheet
https://ww1.microchip.com/downloads/en/ ... 01841D.pdf

Reagrds,
Kumar

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

Re: Overlapping addresses of 128k flash memory

#2 Post by kumar123 » 12 Apr 2024 10:59

Hello,
Can someone guide for the above query?

Regards,
Kumar

Post Reply

Return to “mikroC PRO for PIC General”