Skip to main content
Associate
October 20, 2025
Solved

Does the STM32G030F6P6 microcontroller have 32kb or 64kb?

  • October 20, 2025
  • 2 replies
  • 192 views

-->According to the datasheet and reference manual, I learned that the microcontroller has 64KB of memory, and I tested it and was able to read/write on pages 29, 30, 31. But why does the website say it has 32KB?


Ekran görüntüsü 2025-10-20 122413.png

#define FLASH_SAYFA_SAYISI 3

//#define FLASH_SAYFA_1 0x08006800
//#define FLASH_SAYFA 2 0x08007000
//#define FLASH_SAYFA_3 0x08007800
#define FLASH_SAYFA_1 0x0800E800 //29
#define FLASH_SAYFA_2 0x0800F000 //30
#define FLASH_SAYFA_3 0x0800F800 //31

void Flash_Kayit() {
 SensorKalibre_t *pFlashData;
 uint32_t yeni_sira = 0;
 uint32_t sayfa_adresi = 0;
 uint8_t sayfa_bul = 0;

 uint32_t sayfa_adresleri[FLASH_SAYFA_SAYISI] = { 
 FLASH_SAYFA_1,
 FLASH_SAYFA_2,
 FLASH_SAYFA_3 
 };

 for (int i = 0; i < FLASH_SAYFA_SAYISI; i++) {
 uint32_t* sayfa_baslat = (uint32_t*)sayfa_adresleri[i];

 if (sayfa_baslat[0] == 0xFFFFFFFF) {
 sayfa_adresi = sayfa_adresleri[i];
 sayfa_bul = 1;
 break;
 }
 }

 if (!sayfa_bul) {
 uint32_t eski_sira = 0xFFFFFFFF;

 for (int i = 0; i < FLASH_SAYFA_SAYISI; i++) {
 pFlashData = (SensorKalibre_t*)sayfa_adresleri[i];

 if (pFlashData->veri_kontrol == FLASH_VERI_KONTROL &&
 pFlashData->BOS > pFlashData->DOLU + MIN_ARALIK) {
 if (pFlashData->sira_numarasi < eski_sira) {
 eski_sira = pFlashData->sira_numarasi;
 sayfa_adresi = sayfa_adresleri[i];
 sayfa_bul = 1;
 }
 }
 }

 if (!sayfa_bul) {
 sayfa_adresi = FLASH_SAYFA_1;
 }
 }

 yeni_sira = 0;
 for (int i = 0; i < FLASH_SAYFA_SAYISI; i++) {
 pFlashData = (SensorKalibre_t*)sayfa_adresleri[i];

 if (pFlashData->veri_kontrol == FLASH_VERI_KONTROL &&
 pFlashData->BOS > pFlashData->DOLU + MIN_ARALIK) {
 if (pFlashData->sira_numarasi > yeni_sira) {
 yeni_sira = pFlashData->sira_numarasi;
 }
 }
 }

 SensorKalibre_t kaydedilecekVeriler;
 kaydedilecekVeriler.veri_kontrol = FLASH_VERI_KONTROL;
 kaydedilecekVeriler.sira_numarasi = yeni_sira + 1;
 kaydedilecekVeriler.DOLU = kalibrasyondegeri.DOLU;
 kaydedilecekVeriler.BOS = kalibrasyondegeri.BOS;
 kaydedilecekVeriler.PwmMaxLimit = kalibrasyondegeri.PwmMaxLimit;
 kaydedilecekVeriler.bos_alan = 0;

 uint32_t sayfa_hatasi = 0;
 HAL_FLASH_Unlock();
 __disable_irq();

 FLASH_EraseInitTypeDef sayfayıSil;

 sayfayıSil.TypeErase = FLASH_TYPEERASE_PAGES;
 sayfayıSil.Page = (sayfa_adresi - FLASH_BASE) / FLASH_PAGE_SIZE;
 sayfayıSil.NbPages = 1;

 if (HAL_FLASHEx_Erase(&sayfayıSil, &sayfa_hatasi) != HAL_OK) {
 __enable_irq();
 HAL_FLASH_Lock();
 errorBlinkCount = 10;
 return;
 }

 uint64_t *pData = (uint64_t*)&kaydedilecekVeriler;

 if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, sayfa_adresi, *pData) != HAL_OK) {
 __enable_irq();
 HAL_FLASH_Lock();
 errorBlinkCount = 10;
 return;
 }
 if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, sayfa_adresi + 8, *(pData + 1)) != HAL_OK) {
 __enable_irq();
 HAL_FLASH_Lock();
 errorBlinkCount = 10;
 return;
 }

 __enable_irq();
 HAL_FLASH_Lock();

 kalibrasyondegeri = kaydedilecekVeriler;
}

 


Edited to apply source code formatting - please see How to insert source code for future reference.

Best answer by AScha.3

AScha3_0-1760955656294.png

So the STM32G030F6P6 has 32K flash, working and tested.

But the chip might be the same as STM32G030K8 , so it has 64K always - but not tested for 100% error free.

So you can use > 32K , but be aware, its just luck, if this working , and no guarantee every chip doing it.

You payed for 32K working flash, thats it. Even if they use always the 64K die, to reduce costs.

2 replies

Andrew Neil
Super User
October 20, 2025

Welcome to the forum.

Please see How to write your question to maximize your chances to find a solution for best results.

See also: How to insert source code.

 


@Baris_Simsek wrote:

 why does the website say it has 32KB?


Where, exactly, does it say that?

Please provide a link & screenshot.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
AScha.3
AScha.3Best answer
Super User
October 20, 2025

AScha3_0-1760955656294.png

So the STM32G030F6P6 has 32K flash, working and tested.

But the chip might be the same as STM32G030K8 , so it has 64K always - but not tested for 100% error free.

So you can use > 32K , but be aware, its just luck, if this working , and no guarantee every chip doing it.

You payed for 32K working flash, thats it. Even if they use always the 64K die, to reduce costs.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate
October 20, 2025

I understand, 32KB is enough for me, but I asked out of curiosity. If I need a larger size in the future, I can at least replace the microcontroller. Thank you.