AnsweredAssumed Answered

Problem with FMC_NOR Sample Program.

Question asked by Rohit Mishra on Sep 4, 2017

I am working on STM32F756-EVAL2 Board, and wanted to use NOR Flash Memory to Store some configuration data. But i am facing some problem. I am not able to write any thing into NOR memory.(But able to perform read Operation).

 

I also checked with the sample program of FMC_NOR provided for the evaluation board. 

The program provided below Writes a buffer to Nor Flash and then reads it , compares with the written data. Till here the program works fine.

 

Now in the same example when i perform only read operation to read previously stored data, it is read as blank. 

What could be the issue...... 

 

int main(void)
{
/* Enable the CPU Cache */
CPU_CACHE_Enable();


HAL_Init();

SystemClock_Config();

/* Configure LED1 and LED3 */
BSP_LED_Init(LED1);
BSP_LED_Init(LED3);

 

/*##-1- Configure the NOR device ##########################################*/
/* NOR device configuration */

hnor.Instance = FMC_NORSRAM_DEVICE;
hnor.Extended = FMC_NORSRAM_EXTENDED_DEVICE;

NOR_Timing.AddressSetupTime = 4;
NOR_Timing.AddressHoldTime = 3;
NOR_Timing.DataSetupTime = 8;
NOR_Timing.BusTurnAroundDuration = 1;
NOR_Timing.CLKDivision = 2;
NOR_Timing.DataLatency = 2;
NOR_Timing.AccessMode = FMC_ACCESS_MODE_A;

hnor.Init.NSBank = FMC_NORSRAM_BANK1;
hnor.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;
hnor.Init.MemoryType = FMC_MEMORY_TYPE_NOR;
hnor.Init.MemoryDataWidth = NOR_MEMORY_WIDTH;
hnor.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE;
hnor.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;
hnor.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;
hnor.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;
hnor.Init.WaitSignal = FMC_WAIT_SIGNAL_ENABLE;
hnor.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;
hnor.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_ENABLE;
hnor.Init.WriteBurst = FMC_WRITE_BURST_DISABLE;
hnor.Init.ContinuousClock = NOR_CONTINUOUS_CLOCK;

/* Initialize the NOR controller */
if(HAL_NOR_Init(&hnor, &NOR_Timing, &NOR_Timing) != HAL_OK)
{
   /* Initialization Error */
   Error_Handler();
}

 

// /*##-2- NOR memory read/write access ######################################*/
// /* Fill the buffer to write */
// Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xD20F);
//
// /* Write data to the NOR memory */
// for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++)
// {
// /* Write data to NOR */
// HAL_NOR_Program(&hnor, (uint32_t *)(NOR_BANK_ADDR + WRITE_READ_ADDR + 2*uwIndex), &aTxBuffer[uwIndex]);
//
// /* Read NOR device status */
// if(HAL_NOR_GetStatus(&hnor, NOR_BANK_ADDR, PROGRAM_TIMEOUT) != HAL_NOR_STATUS_SUCCESS)
// {
// return HAL_NOR_STATUS_ERROR;
// }
// }

 

/* Read back data from the NOR memory */
if(HAL_NOR_ReadBuffer(&hnor, NOR_BANK_ADDR + WRITE_READ_ADDR, &aRxBuffer[0], BUFFER_SIZE) != HAL_OK)
{
return HAL_ERROR;
}

/*##-3- Checking data integrity ############################################*/
uwWriteReadStatus = Buffercmp(aTxBuffer, aRxBuffer, BUFFER_SIZE);

if (uwWriteReadStatus != PASSED)
{
/* KO */
/* Toggle LED3 */
while(1)
{
BSP_LED_Toggle(LED3);
}
}
else
{
/* OK */
/* Turn on LED1 */
BSP_LED_On(LED1);
}

   /* Infinite loop */
   while (1)
   {
   }
}

Outcomes