Skip to main content
JFELI.13
Associate III
January 31, 2023
Question

Problem writing to flash (STM32F051K6U6)

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");
 
}

This topic has been closed for replies.

3 replies

Javier1
Principal
January 31, 2023

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

hit me up in https://www.linkedin.com/in/javiermuñoz/
MM..1
Super User
January 31, 2023

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

Or use STM32CubeIDE

JFELI.13
JFELI.13Author
Associate III
January 31, 2023

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 ?