CMPS03 I2C Interfacing problem with dspic30f4011

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
sonu2die45
Posts: 7
Joined: 04 Aug 2008 20:23

CMPS03 I2C Interfacing problem with dspic30f4011

#1 Post by sonu2die45 » 20 Oct 2008 15:52

Hi,
I had troubles getting my cmps03 work with the dsPIC30F4011.My Configuration is 10Mhz External clock Crystal . HS PLL is Set.The SDA and SCL is pulled up to 5V.Both the pull ups are 5.1K each.I was expecting to read the heading in between 0-255.I inserted the Soft_Uart_Write(''); in order to trace my function.I can see only the T printed. Please help me out with this concern.
//****************************************************//
unsigned char take;
void main() {
ADPCFG = 0xFFFF;
PORTB = 0;
TRISB = 0;


Soft_Uart_Init(&PORTF, 4,5, 19200, 0);


I2C_Init(100000); //Initialise the I2C
while(1)

{
I2C_Start(); // issue I2C start signal
Soft_Uart_Write('T');
I2C_Write(0xC0); // send byte via I2C (command to cmps03)
Soft_Uart_Write(';');
Soft_Uart_Write('E');
I2C_Write(0X01); // send byte (address of compass)
Soft_Uart_Write('S');
I2C_Restart();
Soft_Uart_Write('T');
I2C_Write(0xC1); // send byte via I2C (device address + W)
I2C_Write(0x01); // send byte (data address)
take = I2C_Read(1);
Soft_Uart_Write(take); //Print it on Hyperterminal
I2C_Stop();
}
}//~!
//*******************************************************//

Regards
Vivek

MHI
Posts: 56
Joined: 13 Mar 2010 20:52

Re: CMPS03 I2C Interfacing problem with dspic30f4011

#2 Post by MHI » 21 Apr 2010 18:36

hello all !!
I have the same problem here !!
anyone can help ??

Regards

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”