用407的FSMC驱动dm9000AE获取ID时为什么获取的是ID所在寄存器的地址,是哪里出问题了,求解
uint32_t dm9k_ReadID(void)
{
uint8_t vid1,vid2,pid1,pid2;
if (s_FSMC_Init_Ok == 0)
{
DM9K_CtrlLinesConfig();
DM9K_FSMCConfig();
s_FSMC_Init_Ok = 1;
}
vid1 = dm9k_ReadReg(DM9000_REG_VID_L) & 0xFF;
vid2 = dm9k_ReadReg(DM9000_REG_VID_H) & 0xFF;
pid1 = dm9k_ReadReg(DM9000_REG_PID_L) & 0xFF;
pid2 = dm9k_ReadReg(DM9000_REG_PID_H) & 0xFF;
return (vid2 << 24) | (vid1 << 16) | (pid2 << 8) | pid1;
}
uint8_t dm9k_ReadReg(uint8_t reg)
{
NET_REG_ADDR = reg;
return NET_REG_DATA;
}static void DM9K_FSMCConfig(void)
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p;
/*-- FSMC Configuration ------------------------------------------------------*/
/*----------------------- SRAM Bank 3 ----------------------------------------*/
/*-- FSMC Configuration ------------------------------------------------------*/
p.FSMC_AddressSetupTime = 6; /* 设置为2会出错; 3正常 */
p.FSMC_AddressHoldTime = 2;
p.FSMC_DataSetupTime = 4; /* 设置为1出错,2正常 */
p.FSMC_BusTurnAroundDuration = 1;
p.FSMC_CLKDivision = 0;
p.FSMC_DataLatency = 0;
p.FSMC_AccessMode = FSMC_AccessMode_A;
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; // FSMC_MemoryType_PSRAM;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
/*!< Enable FSMC Bank1_SRAM3 Bank */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
注意:FSMC速度的设置,不能太快,另外,DM9000的硬件连接得正确。
STM32F103的DM9000例程在哪里啊? 为什么找不到 谢谢了
慢慢对比我们的例程吧。
一周热门 更多>