View unanswered posts | View active topics It is currently Wed Apr 23, 2014 8:53 am






Reply to topic  [ 3 posts ] 
Bitbang I2C example 
Author Message
Rookie

Joined: Mon May 14, 2012 3:24 pm
Posts: 43
Post Bitbang I2C example
Two questions:

First, in the Bitbang I2C sample for the Uno is there a particular reason pins digital 2 & 3 were chosen as the data and clock? "Normally" it's analog pins 4 & 5. I noticed there is an issue with the Mega not allowing Analog pins to act as digital pins but that isn't an issue on the Uno's (that I noticed) .

Second, is this code for a particular I2C device? Why two calls to "i2c_tx_string" with arguments 0xCC and 0x33? I would have thought the second call would have been a call to i2c_rx_string instead (but there is no reason to set the buffer to a value).

Code:
task main ()
{
  array buffer;
  while (true) {
     buffer[0] = 0xCC;
     i2c_tx_string(0x38, buffer, 1);
     wait1Msec(200);
     buffer[0] = 0x33;
     i2c_tx_string(0x38, buffer, 1);
     wait1Msec(200);
   }
}


Just askin :D


Mon May 14, 2012 3:52 pm
Profile
Rookie

Joined: Mon May 14, 2012 3:24 pm
Posts: 43
Post Re: Bitbang I2C example
I am sorry I just noticed this on the UNO known issues page: http://www.robotc.net/wiki/ARDUINO_328_Known_Issues

Using Analog Ports as Digital I/O is not currently supported.

That explains why analog ports 4 & 5 are not used as data and clock for I2C. Sorry my bad.


Mon May 14, 2012 4:22 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 598
Post Re: Bitbang I2C example
In a future update, you'll be able to properly configure Analog sensors as digital. Right now ROBOTC goes behind the scenes and constantly polls all of the Analog sensors - we have to put a flag in to not scan a port as analog when it is configured as digital.

Thanks for the feedback!

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Tue May 15, 2012 9:03 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.