cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Participant
Participant
7,446 Views
Registered: ‎11-09-2014

I2C USELESS WHEN CPU RUN IN AMP MODE

I try a app that set a time for ds1307 using i2c interface.In baremental system ,All things good. but when I run a petalinux on cpu0,the bare mental app is stuck at XIicPs_MasterSendPolled().my petalinux is 2013.10,and ise is 14.7.

 

mycode and my debug infomation is:

 

int system::set_time(system *s,char *obuf,char *Svalue,u32 reserve1)
{
int i;
int Status;
int ret;
XIicPs Iic; /* Instance of the IIC Device */
XIicPs_Config *Config;


char s_year[5];
char s_month[5];
char s_day[5];
char s_hour[5];
char s_minute[5];
char s_second[5];

char year_1;
int year; //2015
char month; //10
char day; //15
char hour; //16
char minute; //54
char second; //30

unsigned char init_second[]=
{
DS1307_REG_SECS,
30,
30
};

unsigned char init_minute[]=
{
DS1307_REG_HOUR,
12,
1
};
unsigned char init_day[]=
{
DS1307_REG_MDAY,
12,
10
};

unsigned char init_year[]=
{
DS1307_REG_YEAR,
15,
10
};
Xil_L2CacheDisable();

printf("the value of APER_CLK_CTRL is %d\r\n",((*(volatile unsigned int *)APER_CLK_CTRL)));
printf("the value of I2C1_RST_CTRL is %d\r\n",((*(volatile unsigned int *)I2C1_RST_CTRL)));
printf("the value of SCL is %d\r\n",((*(volatile unsigned int *)SCL)));
printf("the value of Control_reg0 is %d\r\n",((*(volatile unsigned int *)Control_reg0)));
printf("the value of l2cache is %d\r\n",((*(volatile unsigned int *)l2cache)));

((*(volatile unsigned int *)APER_CLK_CTRL)) |= (1<<19);

((*(volatile unsigned int *)I2C1_RST_CTRL)) |= (1<<1);
delay_s(500);
((*(volatile unsigned int *)I2C1_RST_CTRL)) = 0;
((*(volatile unsigned int *)Time_out_reg0)) = 100;


printf("the value of APER_CLK_CTRL is %d\r\n",((*(volatile unsigned int *)APER_CLK_CTRL)));
printf("the value of I2C1_RST_CTRL is %d\r\n",((*(volatile unsigned int *)I2C1_RST_CTRL)));
printf("the value of SCL is %d\r\n",((*(volatile unsigned int *)SCL)));
printf("the value of Control_reg0 is %d\r\n",((*(volatile unsigned int *)Control_reg0)));
printf("the value of Control_reg0 is %d\r\n",((*(volatile unsigned int *)Time_out_reg0)));

printf("%s\r\n",Svalue);
Config = XIicPs_LookupConfig(XPAR_PS7_I2C_1_DEVICE_ID);
if (NULL == Config) {
return XST_FAILURE;
}

Status = XIicPs_CfgInitialize(&Iic, Config, Config->BaseAddress);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}

memcpy(s_year,Svalue,4);
memcpy(s_month,Svalue+4,2);
memcpy(s_day,Svalue+6,2);
memcpy(s_hour,Svalue+8,2);
memcpy(s_minute,Svalue+10,2);
memcpy(s_second,Svalue+12,2);

year=atoi(s_year);
month=atoi(s_month);
day=atoi(s_day);
hour=atoi(s_hour);
minute=atoi(s_minute);
second=atoi(s_second);
year_1=(char)(year-2000);


init_second[1]=second;
init_second[2]=minute;

init_minute[1]=hour;

init_day[1]=day;
init_day[2]=month;

init_year[1]=year_1;
printf("test1\r\n");
for(i=1;i<3;i++)
{
DectoBCD(init_second[i],init_second+i,1);
DectoBCD(init_minute[i],init_minute+i,1);
DectoBCD(init_day[i],init_day+i,1);
DectoBCD(init_year[i],init_year+i,1);
}
if(XIicPs_SelfTest(&Iic)==XST_FAILURE)
return ret_fm_failed(obuf);
XIicPs_SetOptions(&Iic,XIICPS_7_BIT_ADDR_OPTION);
XIicPs_SetSClk(&Iic,20000);
printf("test2\r\n");
printf("the value of Control_reg0 is %d\r\n",((*(volatile unsigned int *)Control_reg0)));
printf("the value of XIICPS_SR is %d\r\n",((*(volatile unsigned int *)(Control_reg0+XIICPS_SR_OFFSET))));

XIicPs_MasterSendPolled(&Iic,init_second,3,0x68);
XIicPs_MasterSendPolled(&Iic,init_minute,3,0x68);
XIicPs_MasterSendPolled(&Iic,init_day,3,0x68);
XIicPs_MasterSendPolled(&Iic,init_year,3,0x68);

printf("OK!!!\r\n");

}

 

the result of register is :

 

the value of APER_CLK_CTRL is 3671104
the value of I2C1_RST_CTRL is 0
the value of SCL is 0
the value of Control_reg0 is 17934
the value of l2cache is 0
the value of APER_CLK_CTRL is 3671104
the value of I2C1_RST_CTRL is 0
the value of SCL is 0
the value of Control_reg0 is 0
the value of Control_reg0 is 100
20141013103025
test1
test2
the value of Control_reg0 is 65284
the value of XIICPS_SR is 0

 

0 Kudos
2 Replies
Highlighted
Xilinx Employee
Xilinx Employee
7,433 Views
Registered: ‎09-10-2008

Hi,

 

I don't know that this is your issue but you should checkout this page to be sure.

 

http://www.wiki.xilinx.com/Device+Tree+Tipshttp://www.wiki.xilinx.com/Device+Tree+Tips

 

Thanks

John

0 Kudos
Highlighted
Participant
Participant
7,384 Views
Registered: ‎11-09-2014

I want to read rtc through i2c running on cpu1.so i don't use linux driver.

0 Kudos