Can't get fopen ("i2c0:", NULL) to work

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't get fopen ("i2c0:", NULL) to work

Jump to solution
1,744 Views
MikeMarynowski
Contributor III

Hi,

 

I'm currently trying out the 52259 eval board and MQX 3.3 and the following lines:

 

  
ftouch = fopen ("i2c0:", NULL);   if (ftouch == NULL) {   printf ("Failed to open the I2C driver!\n");   _task_block();}

 

 

always ends up going into the failed block.  I have enabled I2C0 in user_config.h for the BSP.  I also tried the i2c sample project in MQX samples and the same thing happens.

 

Any idea why that might be?

 

Thanks,

 

--Mike

Labels (1)
0 Kudos
1 Solution
666 Views
MikeMarynowski
Contributor III
Nevermind...got it working.

View solution in original post

0 Kudos
6 Replies
667 Views
MikeMarynowski
Contributor III
Nevermind...got it working.
0 Kudos
666 Views
navin_b
Contributor I

Hi,

    I am new to FreeScale and MQX. I am facing similar problem as described by Mike. Can some body please help me?

 

Thanks in advance

Message Edited by navin_b on 2010-02-08 06:44 AM
0 Kudos
666 Views
MikeMarynowski
Contributor III
You have to go through the board configuration and set the desired pins as I2C primary function instead of GPIO function.
0 Kudos
666 Views
navin_b
Contributor I
Thanks for answering but my problem is little different from yours. The example code works fine ( it does open the file successfully) but in my project (the one i create in CW) it does not happen so. Can you please say which file should i modify to change the primary function.
0 Kudos
666 Views
navin_b
Contributor I
I was doing it wrong way. sorry, mistake on my part. I forgot to build libs in config directory.
0 Kudos
666 Views
MikeMarynowski
Contributor III

Also, just tried the I2C sample in MQX 3.2, same thing. 

 

That version passes I2C_DEVICE_MASTER_MODE explicitly as the second parameter to fopen, so that's not the problem.

 

EDIT:

 

I can fopen the SDA0 / SCL0 pins on PORT_AS just fine as GPIO, so I'm not sure why the I2C fopen is failing.

Message Edited by MikeMarynowski on 2009-10-17 01:51 AM
0 Kudos