Quick I2C Question

Lt2mc

Member
Hey All, Quick question regarding I2C functionality, that I cannot find a definitive answer any where. Can a 28x2 communicate with serial and I2C components simultaneously? ie serial to OLED, and I2C to a DAC module. For some background, I am working on an LED measurement project, and currently using a daclevel command with a 1024 vref for controlling the LED driver output. Unfortunately the dac command only gives me 32 steps of resolution, which is too coarse for getting any relevant data on my sensors. I have found a lot of "off-board" I2C DAC modules out there that offer a much finer resolution, and they look like they would work with minimal redesign. BTW the PWM function is out of the question due to the type of sensors I am using. :confused:
Thanks Much
 

Buzby

Senior Member
On the 28X2 there is onboard hardware for both I2C and serial, so both can be used without the timing problems caused when using firmware driven coms.

See the hi2c and hser commands. I have used these many times together with no problems.

The 'i2c bus lockup' can still occur, but usually only if you reset the PICAXE at the instant the I2C slave is responding to a request. It has nothing to do with the hser coms.

Cheers,

Buzby
 

hippy

Technical Support
Staff member
The question comes down to what "simultaneously" means. If the question is really asking can they be used "together, in a single program, on one PICAXE" then the answer is almost certainly "yes".

Especially so in this case as both are output devices being controlled. Update the OLED, update the DAC, would be entirely possible, "almost simultaneously".

All that would seem to be needed is to replace the DACSETUP with a HI2CSETUP command and the DACLEVEL with an appropriate HI2COUT command.

There may need to be some additional HI2COUT commands after HI2CSETUP if the DAC needs to be initialised in some way.
 

Lt2mc

Member
Thanks guys for the quick answers in the affirmative. Adding a I2C DAC daughter board to my project should be fairly easy. BTW, You were correct when I stated simultaneous, I did mean together within the same program. The serial comm would be used several times per prog loop, while the DAC will only be checked once per loop, and adjusted maybe once every few hours. I appreciate everyone's help with hacking my way through this project. Have a great New Year.
 
Top