Tool/software: TI C/C++ Compiler
Hi,
Taking help from swrc257 >> software examples we are able to understand the flow of i2c interfacing with cc2541,and made some changes in keyfobdemo example code with i2c interface as follows
//>> In KeyFobApp_Init Function
// Enable I2C on CC2541.
I2CWC &= ~0x80;
// Enable the I2C module with 33 kHz clock rate.
// The STArt bit signals a master.
I2CCFG = (I2CCFG & ~I2CCFG_CR) | I2CCFG_CR_DIV_960 | I2CCFG_ENS1 | I2CCFG_STA;
//Enable Global Interrupt
EA = 1;
//>> In performPeriodicTask Function
// Clear I2C (P2) CPU interrupt flag. //Added Idris
P2IF = 0;
// Enable interrupt from I2C by setting [IEN2.P2IE = 1].
IEN2 |= IEN2_P2IE;
//>> In I2C_ISR Function
// Clear I2C CPU interrupt flag.
P2IF = 0;
//To transmit If a Start or Restart condition has been transmitted ...
if ((I2CSTAT == 0x08 || I2CSTAT == 0x10))
{
// Send Slave address and R/W access.
I2CDATA = (SLAVE_ADDRESS << 1) | WRITE_TO_SLAVE;
// End Start condition.
I2CCFG &= ~I2CCFG_STA;
}
// Send I2C byte
I2CDATA = value; //assigned value=0x01
// If Slave address or Data byte has been transmitted and acknowledged ...
if (I2CSTAT == 0x18 || I2CSTAT == 0x28)
{
// Generate Stop condition.
I2CCFG |= I2CCFG_STO;
// Disable interrupt from I2C by setting [IEN2.I2CIE = 0].
IEN2 &= ~IEN2_P2IE;
}
// I2CCFG.SI flag must be cleared by software at the end of the ISR.
I2CCFG &= ~I2CCFG_SI;
But we are unable to see the clock cycle on oscilloscope.
Are we missing something??