|
本人要在2440下读写fpga中的4个寄存器。fpga的片选为cs4。
首先设置好时序(PROGRAMMABLE ACCESS CYCLE)
在将0x20000000映射到虚拟内存,此时寄存器对应2440的物理地址应该是0x20000000,0x20000002,0x20000004,0x20000006
可是读写都不对,估计是时序设置有问题,是不是还有哪里要配置一下呢?
这里是设置时序
p_mscregs = VirtualAlloc(0, MSCREGS_SIZE, MEM_RESERVE, PAGE_NOACCESS);
if (!p_mscregs){return FALSE;}
if (!VirtualCopy(p_mscregs, (LPVOID)(MSCREGS_PHYSADDR/256), MSCREGS_SIZE,PAGE_READWRITE | PAGE_NOCACHE | PAGE_PHYSICAL)) {return FALSE;}
*(volatile unsigned int *)((unsigned int)p_mscregs + MSC4_OFFSET) &= 0xFFFF0000;
*(volatile unsigned int *)((unsigned int)p_mscregs + MSC4_OFFSET) |= CS4_SETUP; //0x00007FF0
这里是做cs4的物理地址到虚拟地址的转换
p_fpgaregs = VirtualAlloc(0, MSCREGS_SIZE, MEM_RESERVE, PAGE_READWRITE);
if (!p_fpgaregs) {return FALSE;}
if (!VirtualCopy(p_fpgaregs, (LPVOID)(Fpga_Base_Addr >> 8), MSCREGS_SIZE,PAGE_READWRITE | PAGE_NOCACHE | PAGE_PHYSICAL)){return FALSE;}
|
|