asi123
Newbie level 6
So, this is what I did.
I took the code from xilinx examples for Low_Driver_IIC and change it a bit.
/***************************** Include Files *********************************/
#include "xparameters.h"
#include "xiic.h"
#include "xil_io.h"
/************************** Constant Definitions *****************************/
/*
* The following constants map to the XPAR parameters created in the
* xparameters.h file. They are defined here such that a user can easily
* change all the needed parameters in one place.
*/
#define IIC_BASE_ADDRESS XPAR_IIC_0_BASEADDR
/*
* The following constant defines the address of the IIC Slave device on the
* IIC bus. Note that since the address is only 7 bits, this constant is the
* address divided by 2.
* The 7 bit IIC Slave address of the IIC EEPROM on the ML300/ML310/ML403/ML410/
* ML501/ML505/ML507/ML510 boards is 0x50. The 7 bit IIC Slave address of the
* IIC EEPROM on the ML605/SP601/SP605 boards is 0x54.
* Please refer the User Guide's of the respective boards for further
* information about the IIC slave address of IIC EEPROM's.
*/
#define EEPROM_ADDRESS 0x50 /* 0xA0 as an 8 bit number */
/*
* The page size determines how much data should be written at a time.
* The ML300 board supports a page size of 32 and 16
* The write function should be called with this as a maximum byte count.
*/
#define PAGE_SIZE 128
/*
* The Starting address in the IIC EEPROM on which this test is performed
*/
#define EEPROM_TEST_START_ADDRESS 0
/**************************** Type Definitions *******************************/
/*
* The AddressType for ML300/ML310/ML510 boards should be u16 as the address
* pointer in the on board EEPROM is 2 bytes.
* The AddressType for ML403/ML501/ML505/ML507/ML605/SP601/SP605 boards should
* be u8 as the address pointer in the on board EEPROM is 1 bytes.
*/
typedef u8 AddressType;
/************************** Variable Definitions **************************/
u8 ReadBuffer[PAGE_SIZE]; /* Read buffer for reading a page */
u8 EepromIicAddr; /* Variable for storing Eeprom IIC address */
/*****************************************************************************/
/**
* Main function to call the low level EEPROM example.
*
* @param None.
*
* @return XST_SUCCESS if successful, XST_FAILURE if unsuccessful.
*
* @note None.
*
******************************************************************************/
int main(void)
{
volatile unsigned ReceivedByteCount;
u16 StatusReg;
AddressType Address;
int Index;
Address = EEPROM_TEST_START_ADDRESS;
EepromIicAddr = EEPROM_ADDRESS;
for (Index = 0; Index < PAGE_SIZE; Index++) {
ReadBuffer[Index] = 0;
}
/*
* Set the address register to the specified address by writing
* the address to the device, this must be tried until it succeeds
* because a previous write to the device could be pending and it
* will not ack until that write is complete.
*/
do {
StatusReg = XIic_ReadReg(IIC_BASE_ADDRESS, XIIC_SR_REG_OFFSET);
if(!(StatusReg & XIIC_SR_BUS_BUSY_MASK)) {
ReceivedByteCount = XIic_Send(IIC_BASE_ADDRESS,
EepromIicAddr,
(u8 *)&Address,
sizeof(Address),
XIIC_STOP);
}
} while (ReceivedByteCount != sizeof(Address));
/*
* Read the number of bytes at the specified address from the EEPROM.
*/
ReceivedByteCount = XIic_Recv(IIC_BASE_ADDRESS, EepromIicAddr,
ReadBuffer, PAGE_SIZE, XIIC_STOP);
/*
* Return the number of bytes read from the EEPROM.
*/
return ReceivedByteCount;
}
And this is what I'm getting in the buffer at the end
ImageShack® - Online Photo and Video Hosting
Obviously not the SPD :smileysad:
Any idea guys?
Thanks a lot.
Assaf.
I took the code from xilinx examples for Low_Driver_IIC and change it a bit.
/***************************** Include Files *********************************/
#include "xparameters.h"
#include "xiic.h"
#include "xil_io.h"
/************************** Constant Definitions *****************************/
/*
* The following constants map to the XPAR parameters created in the
* xparameters.h file. They are defined here such that a user can easily
* change all the needed parameters in one place.
*/
#define IIC_BASE_ADDRESS XPAR_IIC_0_BASEADDR
/*
* The following constant defines the address of the IIC Slave device on the
* IIC bus. Note that since the address is only 7 bits, this constant is the
* address divided by 2.
* The 7 bit IIC Slave address of the IIC EEPROM on the ML300/ML310/ML403/ML410/
* ML501/ML505/ML507/ML510 boards is 0x50. The 7 bit IIC Slave address of the
* IIC EEPROM on the ML605/SP601/SP605 boards is 0x54.
* Please refer the User Guide's of the respective boards for further
* information about the IIC slave address of IIC EEPROM's.
*/
#define EEPROM_ADDRESS 0x50 /* 0xA0 as an 8 bit number */
/*
* The page size determines how much data should be written at a time.
* The ML300 board supports a page size of 32 and 16
* The write function should be called with this as a maximum byte count.
*/
#define PAGE_SIZE 128
/*
* The Starting address in the IIC EEPROM on which this test is performed
*/
#define EEPROM_TEST_START_ADDRESS 0
/**************************** Type Definitions *******************************/
/*
* The AddressType for ML300/ML310/ML510 boards should be u16 as the address
* pointer in the on board EEPROM is 2 bytes.
* The AddressType for ML403/ML501/ML505/ML507/ML605/SP601/SP605 boards should
* be u8 as the address pointer in the on board EEPROM is 1 bytes.
*/
typedef u8 AddressType;
/************************** Variable Definitions **************************/
u8 ReadBuffer[PAGE_SIZE]; /* Read buffer for reading a page */
u8 EepromIicAddr; /* Variable for storing Eeprom IIC address */
/*****************************************************************************/
/**
* Main function to call the low level EEPROM example.
*
* @param None.
*
* @return XST_SUCCESS if successful, XST_FAILURE if unsuccessful.
*
* @note None.
*
******************************************************************************/
int main(void)
{
volatile unsigned ReceivedByteCount;
u16 StatusReg;
AddressType Address;
int Index;
Address = EEPROM_TEST_START_ADDRESS;
EepromIicAddr = EEPROM_ADDRESS;
for (Index = 0; Index < PAGE_SIZE; Index++) {
ReadBuffer[Index] = 0;
}
/*
* Set the address register to the specified address by writing
* the address to the device, this must be tried until it succeeds
* because a previous write to the device could be pending and it
* will not ack until that write is complete.
*/
do {
StatusReg = XIic_ReadReg(IIC_BASE_ADDRESS, XIIC_SR_REG_OFFSET);
if(!(StatusReg & XIIC_SR_BUS_BUSY_MASK)) {
ReceivedByteCount = XIic_Send(IIC_BASE_ADDRESS,
EepromIicAddr,
(u8 *)&Address,
sizeof(Address),
XIIC_STOP);
}
} while (ReceivedByteCount != sizeof(Address));
/*
* Read the number of bytes at the specified address from the EEPROM.
*/
ReceivedByteCount = XIic_Recv(IIC_BASE_ADDRESS, EepromIicAddr,
ReadBuffer, PAGE_SIZE, XIIC_STOP);
/*
* Return the number of bytes read from the EEPROM.
*/
return ReceivedByteCount;
}
And this is what I'm getting in the buffer at the end
ImageShack® - Online Photo and Video Hosting
Obviously not the SPD :smileysad:
Any idea guys?
Thanks a lot.
Assaf.