0

I use my function to write a string to the eeprom bank of the stm32l073.
Directly after the function HAL_FLASHEx_DATAEEPROM_Program will be called, the sytem goes into HardFault: Debug Stack
The address i want to write is in the correct space 0x080803b4: MemoryMap
Do you see any problem in that process? I tried also to erase this WORD before write, but same problem with that write function.

    HAL_StatusTypeDef eepromDrv_WriteWORD(uint32_t address, const uint32_t* pData, uint16_t dataLength)
    {
        bool bSuccess = true;
        uint32_t ui32Addr = 0;
        HAL_StatusTypeDef status = HAL_ERROR;
        
        HAL_FLASHEx_DATAEEPROM_DisableFixedTimeProgram(); // Only Erase befor Write, when EEPROM_READ != DATA      
        HAL_FLASHEx_DATAEEPROM_Unlock();
        for (ui32Addr=0;ui32Addr < dataLength; ui32Addr+=4,pData++)
        {
            if ((HAL_FLASHEx_DATAEEPROM_Program( FLASH_TYPEPROGRAMDATA_WORD, address + ui32Addr, *pData)) != HAL_OK)
            {   
              bSuccess = false;
            }
        }
        HAL_FLASHEx_DATAEEPROM_Lock();
        if(true == bSuccess)
        {
            status = HAL_OK;
        }
        return status;
    }
Dr_Smu
  • 3
  • 5
  • Are you sure that `pData` has a valid address? Use your debugger to look at the specific machine instruction that fails to find the line in the source. – the busybee Sep 22 '21 at 09:31
  • @thebusybee i'm working with the cubeIDE from ST. Can you point me where to go exactly to debug by my self? – Dr_Smu Sep 22 '21 at 09:55
  • See page 4 of the Quich Start Guide, there is a button to switch to "instruction stepping". Additionally, you should read the documentation. – the busybee Sep 22 '21 at 10:38
  • Ok got it. I will play around within and try to get used to it for further development. For the actual problem, i found that i got a problem with pData in the "pointer-hell" which confuses me from time to time. changed my function to loop through the array (char pointer) till all elements were written to eeprom. – Dr_Smu Sep 23 '21 at 05:57

0 Answers0