|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
我在xps中新建了一个工程,使用microblaze软核,然后添加了自定制的ip核,生成得user logic中有一个软件可寻址的寄存器,我想在软件代码中实现写这个寄存器,将这个寄存器各个位连接到板子外边的8个发光二极管上,实现对应位的亮和灭,但我不知道怎么用软件访问这个寄存器,谁有这方面的经验,请指点一下,我用的是Spartan3an starter kit开发板,我自己写的软件c代码如下:
#include "led_control.h"
#include"xparameters.h"
#include "xio.h"
/************************** Function Definitions ***************************/
#define delay 100000
#define led_control_DEVICE_ID XPAR_LED_CONTROL_0_BASEADDR//base address
int main(void)
{
Xuint32 value=0x00000fff ;
Xuint32 addr= led_control_DEVICE_ID;
unsigned offset=1;
int i;
while(1)
{
{
LED_CONTROL_mWriteSlaveReg0(addr,offset , value);
for (i=0; i<delay; i++);
}
}
}
函数LED_CONTROL_mWriteSlaveReg0(addr,offset , value)是自制ip添加完毕后在工程目录下的driver文件夹中自动生成的,它的原型是
/**
*
* Write/Read 32 bit value to/from LED_CONTROL user logic slave registers.
*
* @param BaseAddress is the base address of the LED_CONTROL device.
* @param RegOffset is the offset from the slave register to write to or read from.
* @param Value is the data written to the register.
*
* @return Data is the data from the user logic slave register.
*
* @note
* C-style signature:
* void LED_CONTROL_mWriteSlaveRegn(Xuint32 BaseAddress, unsigned RegOffset, Xuint32 Value)
* Xuint32 LED_CONTROL_mReadSlaveRegn(Xuint32 BaseAddress, unsigned RegOffset)
*
*/
#define LED_CONTROL_mWriteSlaveReg0(BaseAddress, RegOffset, Value) \
XIo_Out32((BaseAddress) + (LED_CONTROL_SLV_REG0_OFFSET) + (RegOffset), (Xuint32)(Value))
#define LED_CONTROL_mReadSlaveReg0(BaseAddress, RegOffset) \
XIo_In32((BaseAddress) + (LED_CONTROL_SLV_REG0_OFFSET) + (RegOffset)),
下载到板子中二极管没有反应,不知什么原因,请指教
|
|