AD9985A имеет регистры настройки, доступ к которым осуществляется по I2C шине.
С программированием Microblaze столкнулся впервые, впрочем как и с языком C..
Беру пример работы с памятью EEPROM (xiic_eeprom_example.c) Изменяю адрес, смещение.. Получаю зависание на ожидании прерывания.. (не происходит прерывание от устройства xps_iic).
Беру пример работы на низком уровне с шиной
Вызываю функцию EepromReadByte ():
BytesRead = EepromReadByte(EEPROM_TEST_START_ADDRESS, ReadBuffer, PAGE_SIZE);
Код
unsigned EepromReadByte(AddressType Address, u8 *BufferPtr, u16 ByteCount)
{
volatile unsigned ReceivedByteCount;
u16 StatusReg;
/*
* 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,
EEPROM_ADDRESS,
(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, EEPROM_ADDRESS,
BufferPtr, ByteCount, XIIC_STOP);
/*
* Return the number of bytes read from the EEPROM
*/
return ReceivedByteCount;
}
{
volatile unsigned ReceivedByteCount;
u16 StatusReg;
/*
* 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,
EEPROM_ADDRESS,
(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, EEPROM_ADDRESS,
BufferPtr, ByteCount, XIIC_STOP);
/*
* Return the number of bytes read from the EEPROM
*/
return ReceivedByteCount;
}
Получаю опять зависание в цикле do..while, при этом на шине I2C вижу зацикленную посылку данных.
Бьюсь уже несколько дней.., без помощи сложно дается..
Добавлено:
У меня постоянно ReceivedByteCount = 0x00000000..
И еще вопрос о подключении шины I2C к ножкам FPGA. На верхнем уровне в ISE у меня объявлены порты
inout I2C_DATA,
inout I2C_CLK,
Подключаю Microblaze:
Microblaze _10 (
.fpga_0_Generic_IIC_Bus_Sda_pin(I2C_DATA),
.fpga_0_Generic_IIC_Bus_Scl_pin(I2C_CLK),
В ucf порты шины объявлены как LVCMOS33. Подтяжка к + внешняя.
Правильно ли это, а то может у меня аппаратный косяк?