2024-06-18 02:49 AM - last edited on 2024-06-19 12:58 AM by SofLit
I encountered a problem when trying to send more than 5 bytes of data using the FMC.
// impossible example --
#define SD_DATA (*(volatile unsigned char *)0x60000001)
SD_DATA = 0x01;
SD_DATA = 0x02;
SD_DATA = 0x03;
// possible example -- 1
#define SD_DATA (*(volatile unsigned char *)0x60000001)
SD_DATA = 0x01;
HAL_Delay(1);
SD_DATA = 0x02;
HAL_Delay(1);
SD_DATA = 0x03;
// possible example -- 2
#define SD_DATA1 (*(volatile unsigned char *)0x60000001)
#define SD_DATA2 (*(volatile unsigned char *)0x60000002)
#define SD_DATA3 (*(volatile unsigned char *)0x60000003)
SD_DATA1 = 0x01;
SD_DATA2 = 0x02;
SD_DATA3 = 0x03;
static void MX_FMC_Init(void)
{
FMC_NORSRAM_TimingTypeDef Timing;
/** Perform the NOR1 memory initialization sequence
*/
hnor1.Instance = FMC_NORSRAM_DEVICE;
hnor1.Extended = FMC_NORSRAM_EXTENDED_DEVICE;
/* hnor1.Init */
hnor1.Init.NSBank = FMC_NORSRAM_BANK1;
hnor1.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;
hnor1.Init.MemoryType = FMC_MEMORY_TYPE_NOR;
hnor1.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_8;
hnor1.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE;
hnor1.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;
hnor1.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;
hnor1.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;
hnor1.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;
hnor1.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;
hnor1.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE;
hnor1.Init.WriteBurst = FMC_WRITE_BURST_DISABLE;
hnor1.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY;
hnor1.Init.WriteFifo = FMC_WRITE_FIFO_ENABLE;
hnor1.Init.PageSize = FMC_PAGE_SIZE_NONE;
/* Timing */
Timing.AddressSetupTime = 15;
Timing.AddressHoldTime = 15;
Timing.DataSetupTime = 31;
Timing.BusTurnAroundDuration = 8;
Timing.CLKDivision = 16;
Timing.DataLatency = 17;
Timing.AccessMode = FMC_ACCESS_MODE_A;
/* ExtTiming */
if (HAL_NOR_Init(&hnor1, &Timing, NULL) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
Solved! Go to Solution.
2024-06-20 06:15 AM
> I have noticed that using BANK1 in FMC_Init causes a hard fault at addresses starting from 0x6000.0000.
After remap, you should not use 0x6000'0000 anymore.
JW
2024-06-23 05:49 PM
I used 0x6000.0000 before remapping, but if BANK2 is not used during the initialization process, a hard fault occurs. What could be the problem?
2024-06-24 02:28 AM
At this point, I am already lost in what exactly do you do.
Please give us a short summary, what is your actual hardware, what are the FMC settings, and upon which action does the fault occur.
JW
2024-06-26 06:32 PM
Due to repeated swap errors, I resolved the issue by clearing the cache.