We're trying to get I2C communication working on our Cora Z7 boards. I tried sending data using the XIicPs_MasterSendPolled() function, but the data never gets clocked out.
I found that after programming the FPGA, the SCL line goes low and stays low, which seems relevant. Any tips on what we might be doing wrong? Or how we can proceed?
The I2C peripheral is in the ARM microcontroller itself, not in the FPGA fabric. The functions for setting up the peripheral and for transmitting data are shown below.
bool I2CInit(void)
{
printf(" I2C Init: ");
XIicPs_Config *Config = XIicPs_LookupConfig(XPAR_XIICPS_0_DEVICE_ID);
if (NULL == Config)
{
printf("I2C Driver failed to get config\r\n");
return false;
}
if (XIicPs_CfgInitialize(&Iic, Config, Config->BaseAddress) != XST_SUCCESS)
{
printf("I2c Driver initialization failed\r\n");
return false;
}
if (XIicPs_SelfTest(&Iic) != XST_SUCCESS)
{
printf("I2C Driver self test failed\r\n");
return false;
}
// Set the I2C serial clock rate.
XIicPs_SetSClk(&Iic, IIC_SCLK_RATE);
printf("OK\r\n");
return true;
}
Question
solonfw
We're trying to get I2C communication working on our Cora Z7 boards. I tried sending data using the XIicPs_MasterSendPolled() function, but the data never gets clocked out.
I found that after programming the FPGA, the SCL line goes low and stays low, which seems relevant. Any tips on what we might be doing wrong? Or how we can proceed?
The I2C peripheral is in the ARM microcontroller itself, not in the FPGA fabric. The functions for setting up the peripheral and for transmitting data are shown below.
bool I2CInit(void)
{
printf(" I2C Init: ");
XIicPs_Config *Config = XIicPs_LookupConfig(XPAR_XIICPS_0_DEVICE_ID);
if (NULL == Config)
{
printf("I2C Driver failed to get config\r\n");
return false;
}
if (XIicPs_CfgInitialize(&Iic, Config, Config->BaseAddress) != XST_SUCCESS)
{
printf("I2c Driver initialization failed\r\n");
return false;
}
if (XIicPs_SelfTest(&Iic) != XST_SUCCESS)
{
printf("I2C Driver self test failed\r\n");
return false;
}
// Set the I2C serial clock rate.
XIicPs_SetSClk(&Iic, IIC_SCLK_RATE);
printf("OK\r\n");
return true;
}
bool I2CSendData(uint8_t *msg, int32_t num_bytes, uint16_t slave_addr)
{
while (XIicPs_BusIsBusy(&Iic))
;
return (XIicPs_MasterSendPolled(&Iic, msg, num_bytes, slave_addr)
== XST_SUCCESS);
}
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.