cancel
Showing results for 
Search instead for 
Did you mean: 

Problem writing to flash (STM32F051K6U6)

JFELI.13
Associate III

Hi

I'm using MikroC and try to play with Flash

My problem: even if area seem ok between "bootloader" and "program", I can see program area is not complete and is writed in bootloader area.

If you can help me ... thanks !

#pragma orgall 0xC0  /?
 
#define BOOTLOADER_START_ADDR  0xC0
 
#define START_PROGRAM_ADDR     0x1900  
 
#define FLASH_SIZE_STM32F051K6U6 16000 
 
#define FLASH_BACKUP_ADRESS ((FLASH_SIZE_STM32F051K6U6-START_PROGRAM_ADDR)/2)+0x1800
 
 
void main() org 0xC0 (bootloader) 
 
{
 
 char x1=0;
 
 SetIOs();
 
 Led_Red
 
 UART1_Init(9600);
 
 Delay_100ms();
 
 
 if(x1)FLASH_MOVE(START_PROGRAM_ADDR,FLASH_BACKUP_ADRESS,FAUX); /
 
 if (0) //UART1_Write_Loop('g','r'))
 
 {
 
     Start_Bootload(); // "r" recu -> start bootload
 
 }
 
 else
 
 {
 
     Start_Program();
 
 }
 
}
 
 
void program org 0x1900 (after boot control)
 
{
 
    uart1_write_Text("ESSAI");
 
}

3 REPLIES 3
Javier1
Principal

what is microC, isnt that supposed to be for PICs?

we dont need to firmware by ourselves, lets talk
MM..1
Chief III

Programming STM32 this way isnt good start. Ask on MicroC for ARM forums.

Or use STM32CubeIDE

JFELI.13
Associate III

MikroC exist for Pic & ARM (and some others)

I could use STM32Cube except it would need I modify many many files (I use MikroC from years) and I suppose it would take a long time to do so.

But could you explain me how to force routing positioning of the addressing in a compilation ?