I2C problem with MPLABX (XC16)

Status
Not open for further replies.

Zara Zara

Junior Member level 1
Joined
Apr 6, 2015
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
104
Hello everyone .

I tried to use dspic30f3012 with i2c on ccs program and all's right.

Now I'm trying to use the dspic with i2c on Mplabx.
I used the mplabx with xc16 and this is the code :
Code:
#include<i2c.h>
void main(void )
{
unsigned int config2, config1;
unsigned char *wrptr;
unsigned char tx_data[] = {'M','I','C','R','O',’C’,'H','I','P','\0'};
wrptr = tx_data;
/* Baud rate is set for 100 kHz */
config2 = 0x11;
/* Configure I2C for 7 bit address mode */
config1 = (I2C_ON & I2C_IDLE_CON & I2C_CLK_HLD &
I2C_IPMI_DIS & I2C_7BIT_ADD &
I2C_SLW_DIS & I2C_SM_DIS &
I2C_GCALL_DIS & I2C_STR_DIS &
I2C_NACK & I2C_ACK_DIS & I2C_RCV_DIS &
I2C_STOP_DIS & I2C_RESTART_DIS &
I2C_START_DIS);
OpenI2C(config1,config2);
LOOP:
IdleI2C();
StartI2C();
/* Wait till Start sequence is completed */
while(I2CCONbits.SEN);
/* Clear interrupt flag */
IFS0bits.MI2CIF = 0;
/* Write Slave address and set master for transmission */
MasterWriteI2C(0xE);
/* Wait till address is transmitted */
while(I2CSTATbits.TBF); // 8 clock cycles
//while(!IFS0bits.MI2CIF); // Wait for 9th clock cycle
//IFS0bits.MI2CIF = 0; // Clear interrupt flag
//while(I2CSTATbits.ACKSTAT);
/* Transmit string of data */
MasterputsI2C(wrptr);
StopI2C();
/* Wait till stop sequence is completed */
while(I2CCONbits.PEN);
//CloseI2C();
goto LOOP;
}
without closing or interrupt or ack from i2c , I don't need ack I want only to see the output on oscilloscope. but nothing !

Please help!
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…