初始化GD32F407的EXMC,外部扩展SRAM芯片是CY62136EV30
,扩展SRAM的地址是0x60000000 - 0x6FFFFFFF
u8 BSPEXMCInit(void)
{
sram_timing_init_struct.asyn_access_mode = 0; /*!< asynchronous access mode */
sram_timing_init_struct.syn_data_latency = 2; /*!< configure the data latency */
sram_timing_init_struct.syn_clk_division = 2; /*!< configure the clock divide ratio */
sram_timing_init_struct.bus_latency = 15; /*!< configure the bus latency */
sram_timing_init_struct.asyn_data_setuptime = 1; /*!< configure the data setup time, asynchronous access mode valid */
sram_timing_init_struct.asyn_address_holdtime = 2; /*!< configure the address hold time, asynchronous access mode valid */
sram_timing_init_struct.asyn_address_setuptime = 2; /*!< configure the address setup time, asynchronous access mode valid */
sram_init_struct.norsram_region = EXMC_BANK0_NORSRAM_REGION2; /*!< select the region of EXMC NOR/SRAM bank */
sram_init_struct.write_mode = 0; /*!< the write mode, synchronous mode or asynchronous mode */
sram_init_struct.extended_mode = 0; /*!< enable or disable the extended mode */
sram_init_struct.asyn_wait = 0; /*!< enable or disable the asynchronous wait function */
sram_init_struct.nwait_signal = 0; /*!< enable or disable the NWAIT signal while in synchronous bust mode */
sram_init_struct.memory_write = 0x1000; /*!< enable or disable the write operation */
sram_init_struct.nwait_config = 0; /*!< NWAIT signal configuration */
sram_init_struct.wrap_burst_mode = 0; /*!< enable or disable the wrap burst mode */
sram_init_struct.nwait_polarity = 0; /*!< specifies the polarity of NWAIT signal from memory */
sram_init_struct.burst_mode = 0; /*!< enable or disable the burst mode */
sram_init_struct.databus_width = 0; /*!< specifies the databus width of external memory */
sram_init_struct.memory_type = 0; /*!< specifies the type of external memory */
sram_init_struct.address_data_mux = 0; /*!< specifies whether the data bus and address bus are multiplexed */
exmc_norsram_init(&sram_init_struct);
}
u8 BSPSRAM_WriteBuffer_8bits(u32 sram_device, u8* pbuffer, u32 writeaddr, u32 numbytes)
{
u32 temp_addr = 0;
/*模块未使能不进行初始化*/
if(1 != gBSPFunCfg.Bits.EXMCEn)
{
return(FALSE);
}
temp_addr = SRAM_DEVICE0_ADDR;/*0x60000000*/
/* While there is data to write */
for(; numbytes != 0; numbytes--)
{
/* Transfer data to the memory */
*(__IO u8 *) (temp_addr + writeaddr) = *pbuffer++;
/* Increment the address*/
writeaddr += 1;
}
return(TRUE);
}
u8 BSPSRAM_ReadBuffer_8bits(u32 sram_device, u8* pbuffer, u32 readaddr, u32 numbytes)
{
u32 temp_addr = 0;
temp_addr = SRAM_DEVICE0_ADDR;/*0x60000000*/
/* while there is data to read */
for(; numbytes != 0; numbytes--)
{
/* read a byte from the memory */
*pbuffer++ = *(__IO u8*) (temp_addr + readaddr);
/* increment the address */
readaddr += 1;
}
return(TRUE);
}
目前读写外部SRAM回导致程序死掉,请教一下各位大佬,我的问题出现在哪里,或有没有相关的EXMC与SRAM的例程,分析一下经验。
另:在使用外部SRAM的同时,工程中.icf文件还需增加对扩展RAM的配置,能否告知一下,谢谢?
|