本帖最后由 waiky85 于 2015-12-3 10:32 编辑
使用了NUC472芯片,通过配置EBI读写铁电FM22L16,数据位8位。发现读不到数据也写不了数据,读出来的却是地址的低八位(如:读取地址0x00000010数据,读取结果就是第八位0x10)。第一次使用EBI接口,不知道哪里出了问题,麻烦各位大神帮帮忙。以下是主要程序:
CLK_EnableModuleClock(EBI_MODULE);
/* Configure EBI multi-function pins */
SYS->GPA_MFPH |= SYS_GPA_MFPH_PA8MFP_EBI_A18;
SYS->GPA_MFPL |= SYS_GPA_MFPL_PA7MFP_EBI_A17 | SYS_GPA_MFPL_PA6MFP_EBI_A16 |
SYS_GPA_MFPL_PA5MFP_EBI_A15 | SYS_GPA_MFPL_PA4MFP_EBI_A14 |
SYS_GPA_MFPL_PA3MFP_EBI_A13 | SYS_GPA_MFPL_PA2MFP_EBI_A12;
SYS->GPD_MFPL |= SYS_GPD_MFPL_PD7MFP_EBI_A11 | SYS_GPD_MFPL_PD6MFP_EBI_A10 |
SYS_GPD_MFPL_PD5MFP_EBI_A9 | SYS_GPD_MFPL_PD4MFP_EBI_A8;
SYS->GPB_MFPL |= SYS_GPB_MFPL_PB5MFP_EBI_AD7 | SYS_GPB_MFPL_PB4MFP_EBI_AD6 |
SYS_GPB_MFPL_PB3MFP_EBI_AD5 | SYS_GPB_MFPL_PB2MFP_EBI_AD4;
SYS->GPA_MFPH |= SYS_GPA_MFPH_PA14MFP_EBI_AD3| SYS_GPA_MFPH_PA13MFP_EBI_AD2|
SYS_GPA_MFPH_PA12MFP_EBI_AD1| SYS_GPA_MFPH_PA11MFP_EBI_AD0;
SYS->GPE_MFPL |= SYS_GPE_MFPL_PE6MFP_EBI_nWR | SYS_GPE_MFPL_PE7MFP_EBI_nRD;
SYS->GPE_MFPH |= SYS_GPE_MFPH_PE8MFP_EBI_ALE;
SYS->GPE_MFPH |= SYS_GPE_MFPH_PE11MFP_EBI_nCS0 | SYS_GPE_MFPH_PE12MFP_EBI_nCS1;
void EBI_Init(void)
{
const uint32_t u32Timing = 0x73F;
/* Open EBI interface */
EBI_Open(EBI_BANK0, EBI_BUSWIDTH_8BIT, EBI_TIMING_FAST, EBI_SEPARATEMODE_DISABLE, EBI_CS_ACTIVE_LOW);
EBI_Open(EBI_BANK1, EBI_BUSWIDTH_8BIT, EBI_TIMING_FAST, EBI_SEPARATEMODE_DISABLE, EBI_CS_ACTIVE_LOW);
/* Configure EBI timing */
// EBI_SetBusTiming(EBI_BANK0, 0x21C, EBI_MCLKDIV_2);
// EBI_SetBusTiming(EBI_BANK1, 0x21C, EBI_MCLKDIV_2);
}
//程序调用该函数来测试读写Fram
void Test_Fram(void)
{
uint16_t i ;
uint32_t u32idx;
uint32_t u32Size;
uint32_t *pu32ptr, *pu32tmp;
LongUnon r32data;
u32Size = 256;
pu32ptr = (uint32_t *)EBI0_BASE_ADDR;
pu32tmp = (uint32_t *)EBI0_BASE_ADDR+u32Size+4;
for(u32idx = 0; u32idx < u32Size; u32idx+=4)
{
// *pu32tmp = 0;
// *pu32ptr++ = (uint32_t)(0xFFFF+0x5678);
EBI0_WRITE_DATA32(u32idx, (uint32_t)(u32idx*0xFFFF+0x5678));
}
}
for(u32idx = 0; u32idx < u32Size; u32idx+=4)
{
r32data.i = EBI0_READ_DATA32(u32idx);
RS485_SendDataByte(r32data.longbuf[0]);
RS485_SendDataByte(r32data.longbuf[1]);
RS485_SendDataByte(r32data.longbuf[2]);
RS485_SendDataByte(r32data.longbuf[3]);
}
|