Hi,
I'm trying to port my code from Tiva series cpu to Hercules RM46, and I'm trying to implement functionality of EEPROMProgram() and EEPROMRead() on RM46L852 using f021, with no luck.
During device initialization, I'm running following code:
Fapi_StatusType oReturnCheck;
oReturnCheck = Fapi_initializeFlashBanks(128); /* Example code is assuming operating
frequency of 128 MHz - which is true */
if((oReturnCheck == Fapi_Status_Success) &&
(FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY != Fapi_Status_FsmBusy)){
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank7);
} else {
while(1);
}
This executes ok.
later I execute::
Fapi_doMarginReadByByte(F021_EEPROM_MAP_BEGIN + 64, (uint32_t *)&pb_token, 128+64+4, Fapi_NormalRead);
this attempts to copy block from flash to ram, starting at pb_token address. This should restore variables I saved previously. Cannot verify if this works as I haven't been able to save anything on flash.
Then, FREERTOS processes are created and scheduler is sarted.
In order to write into flash, I call from one process:
EEPROMProgram(&pb_token, 64,128+48);
Once I do that, relevant process will be stuck (rest of FreeRTOS processes continue to run) and debug variable f021_debug is equal to 1. This means, that the process is stuck on Fapi_setActiveFlashBank(Fapi_FlashBank7);
Why is that, how to debug it?
Thanks,
Andrus Kangro
relevant code from freertos process:
----
#include "f021/f021.h"
volatile int32_t f021_debug = 0;
void Fapi_SectorErase( unsigned int Bank, uint32_t * Sector_Start_Address, unsigned int Freq_In_MHz)
{
//Fapi_initializeAPI((Fapi_FmcRegistersType *)0xfff87000,Freq_In_MHz);
f021_debug = 1;
Fapi_setActiveFlashBank(Fapi_FlashBank7);
f021_debug = 2;
Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, Sector_Start_Address);
f021_debug = 3;
while( Fapi_checkFsmForReady() == Fapi_Status_FsmBusy );
}
void EEPROMProgram(uint8_t * source, uint32_t dest, uint32_t bytes){
//erase sector 0
Fapi_SectorErase( Fapi_FlashBank7, F021_EEPROM_MAP_BEGIN, 128);
//program sector 0
Fapi_BlockProgram( Fapi_FlashBank7, (uint32_t *)(F021_EEPROM_MAP_BEGIN+dest), (unsigned int)(source), bytes, 128);
}