flote21
Advanced Member level 1
Hello people,
I am trying to run this Real Time Clock module but I am not lucky. I have been using like starting point the xiicps_eeprom_polled_example.c provided by xilinx in the folder "drivers" of the installation path. I did some modifications to adpat this code to the RTC and I have trying to send just an address+data byte to the RTC using the function "XIicPs_MasterSendPolled". However I am only able to see that the Address is sent correctly, however the data byte is not sent. (See the code attached)
Some considerations:
- I want to connect to the RTC through a SDK standalone project.
- The switch is working properly because the oscilloscope pictures attached were taken directly in the I2C pins of the RTC-8564. I soldered two cables direcly on the chip to check if the signals were driven to the chip.
Regards,
Enrique Perez
- - - Updated - - -
problem solved. I was addressing the device in a wrong way....
I am trying to run this Real Time Clock module but I am not lucky. I have been using like starting point the xiicps_eeprom_polled_example.c provided by xilinx in the folder "drivers" of the installation path. I did some modifications to adpat this code to the RTC and I have trying to send just an address+data byte to the RTC using the function "XIicPs_MasterSendPolled". However I am only able to see that the Address is sent correctly, however the data byte is not sent. (See the code attached)
Some considerations:
- I want to connect to the RTC through a SDK standalone project.
- The switch is working properly because the oscilloscope pictures attached were taken directly in the I2C pins of the RTC-8564. I soldered two cables direcly on the chip to check if the signals were driven to the chip.
Regards,
Enrique Perez
Code:
#include "xparameters.h"
#include "sleep.h"
#include "xiicps.h"
#include "xil_printf.h"
#include "xplatform_info.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_DEVICE_ID XPAR_XIICPS_0_DEVICE_ID
/*
* 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.
*/
#define IIC_RTC_ADDR_WR 0xA2;
#define IIC_RTC_ADDR_RD 0xA3
//#define IIC_SCLK_RATE 400000 // 400KHz
#define IIC_SCLK_RATE 100000 // 100KHz
#define IIC_MUX_ADDRESS 0x74
/************************** Function Prototypes ******************************/
void IicPSComStart(void);
void RTCReadData(void);
void MuxInit(void);
/************************** Variable Definitions *****************************/
XIicPs IicInstance; /* The instance of the IIC device. */
u32 Platform;
/************************** Function Definitions *****************************/
int main(void)
{
xil_printf("Start \r\n");
// Launching I2C communication
IicPSComStart();
xil_printf("End\r\n");
return 0;
}
void IicPSComStart(void)
{
XIicPs_Config *ConfigPtr; /* Pointer to configuration data */
//Initialize the IIC driver so that it is ready to use.
ConfigPtr = XIicPs_LookupConfig(IIC_DEVICE_ID);
XIicPs_CfgInitialize(&IicInstance, ConfigPtr, ConfigPtr->BaseAddress);
//Set the IIC serial clock rate.
XIicPs_SetSClk(&IicInstance, IIC_SCLK_RATE);
// Configure the IIC Switch
Platform = XGetPlatform_Info();
if(Platform == XPLAT_ZYNQ)
MuxInit();
RTCReadData();
}
void RTCReadData(void)
{
u8 WriteBuffer;
u8 RtcWrAddr = IIC_RTC_ADDR_WR;
// Send Data
WriteBuffer = 0x06;
XIicPs_MasterSendPolled(&IicInstance, &WriteBuffer, 1, RtcWrAddr);
//Wait until bus is idle to start another transfer.
while (XIicPs_BusIsBusy(&IicInstance));
}
void MuxInit(void)
{
u8 WriteBuffer;
u8 MuxIicAddr = IIC_MUX_ADDRESS;
u8 Buffer = 0;
//Channel select value for RTC.
WriteBuffer = 0x10;
// Send the Data.
XIicPs_MasterSendPolled(&IicInstance, &WriteBuffer,1, MuxIicAddr);
//Wait until bus is idle to start another transfer.
while (XIicPs_BusIsBusy(&IicInstance));
//Receive the Data.
XIicPs_MasterRecvPolled(&IicInstance, &Buffer,1, MuxIicAddr);
//Wait until bus is idle to start another transfer.
while (XIicPs_BusIsBusy(&IicInstance));
//Wait some us
usleep(100);
}
- - - Updated - - -
problem solved. I was addressing the device in a wrong way....
Hello people,
I am trying to run this Real Time Clock module but I am not lucky. I have been using like starting point the xiicps_eeprom_polled_example.c provided by xilinx in the folder "drivers" of the installation path. I did some modifications to adpat this code to the RTC and I have trying to send just an address+data byte to the RTC using the function "XIicPs_MasterSendPolled". However I am only able to see that the Address is sent correctly, however the data byte is not sent. (See the code attached)
Some considerations:
- I want to connect to the RTC through a SDK standalone project.
- The switch is working properly because the oscilloscope pictures attached were taken directly in the I2C pins of the RTC-8564. I soldered two cables direcly on the chip to check if the signals were driven to the chip.
Regards,
Enrique Perez
Code:#include "xparameters.h" #include "sleep.h" #include "xiicps.h" #include "xil_printf.h" #include "xplatform_info.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_DEVICE_ID XPAR_XIICPS_0_DEVICE_ID /* * 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. */ #define IIC_RTC_ADDR_WR 0xA2; #define IIC_RTC_ADDR_RD 0xA3 //#define IIC_SCLK_RATE 400000 // 400KHz #define IIC_SCLK_RATE 100000 // 100KHz #define IIC_MUX_ADDRESS 0x74 /************************** Function Prototypes ******************************/ void IicPSComStart(void); void RTCReadData(void); void MuxInit(void); /************************** Variable Definitions *****************************/ XIicPs IicInstance; /* The instance of the IIC device. */ u32 Platform; /************************** Function Definitions *****************************/ int main(void) { xil_printf("Start \r\n"); // Launching I2C communication IicPSComStart(); xil_printf("End\r\n"); return 0; } void IicPSComStart(void) { XIicPs_Config *ConfigPtr; /* Pointer to configuration data */ //Initialize the IIC driver so that it is ready to use. ConfigPtr = XIicPs_LookupConfig(IIC_DEVICE_ID); XIicPs_CfgInitialize(&IicInstance, ConfigPtr, ConfigPtr->BaseAddress); //Set the IIC serial clock rate. XIicPs_SetSClk(&IicInstance, IIC_SCLK_RATE); // Configure the IIC Switch Platform = XGetPlatform_Info(); if(Platform == XPLAT_ZYNQ) MuxInit(); RTCReadData(); } void RTCReadData(void) { u8 WriteBuffer; u8 RtcWrAddr = IIC_RTC_ADDR_WR; // Send Data WriteBuffer = 0x06; XIicPs_MasterSendPolled(&IicInstance, &WriteBuffer, 1, RtcWrAddr); //Wait until bus is idle to start another transfer. while (XIicPs_BusIsBusy(&IicInstance)); } void MuxInit(void) { u8 WriteBuffer; u8 MuxIicAddr = IIC_MUX_ADDRESS; u8 Buffer = 0; //Channel select value for RTC. WriteBuffer = 0x10; // Send the Data. XIicPs_MasterSendPolled(&IicInstance, &WriteBuffer,1, MuxIicAddr); //Wait until bus is idle to start another transfer. while (XIicPs_BusIsBusy(&IicInstance)); //Receive the Data. XIicPs_MasterRecvPolled(&IicInstance, &Buffer,1, MuxIicAddr); //Wait until bus is idle to start another transfer. while (XIicPs_BusIsBusy(&IicInstance)); //Wait some us usleep(100); }