Hello,
I am using S12x DP512 controller for our project.
In this I2C 1 has been configured to be used for getting data from Real Time Clock (ST micro electronics RTC ).
I did Initialization and wrote basic read and write code snippets. I was able to see the expected Pulses coming out of SDA line in sync with SCL.
But RTC expects data to be sent at 400kHz. But I am facing issue in getting this frequency.
I am using S12XDP512 evaluation board and following settings for clock
OSC_SEL = CRYSTAL -- 4MHZ
XCLKS#=0 - Connected
So this should ensure 4Mhz on board
And configured PLL to get 16Mhz as below
CLKSEL = 0;
/* PLLCTL: CME=1,PLLON=0,AUTO=1,ACQ=1,FSTWKP=0,PRE=0,PCE=0,SCME=1 */
PLLCTL = 177;
/* SYNR: ??=0,??=0,SYN5=0,SYN4=0,SYN3=0,SYN2=1,SYN1=0,SYN0=1 */
SYNR = 5; /* Set the multiplier register */
/* REFDV: ??=0,??=0,REFDV5=0,REFDV4=0,REFDV3=0,REFDV2=0,REFDV1=1,REFDV0=0 */
REFDV = 2; /* Set the divider register */
/* PLLCTL: CME=1,PLLON=1,AUTO=1,ACQ=1,FSTWKP=0,PRE=0,PCE=0,SCME=1 */
PLLCTL = 241;
while(!CRGFLG_LOCK); /* Wait until the PLL is within the desired tolerance of the target frequency */
/* CLKSEL: PLLSEL=1 */
CLKSEL = 128;
After this in IIC initialization, I am setting value of
IIC1_IBFD = 0x0B; /* According to page 401 of controller spec */
this is to divide 16Mhz cpu clock to 400Khz.
But after doing all this I am getting a not seeing 400kh SCL on oscillator. Also the pulses i am seeing on Scope are saw tooth (for any frequency on SCL).
Can you guys help me in getting this 400Khz frequency for SCL.