usitwislave icon indicating copy to clipboard operation
usitwislave copied to clipboard

Using usitwislave on ATmega328 (arduino uno)

Open maali-mnasri opened this issue 12 years ago • 4 comments

Hi, I wonder if this library "usitwislave" can be used on ATmega328p (arduino uno) or at least is there a chance to make it run on ATmega if I adapt the registers to my device ?

maali-mnasri avatar Apr 23 '14 16:04 maali-mnasri

I wonder if this library "usitwislave" can be used on ATmega328p (arduino uno) or at least is there a chance to make it run on ATmega if I adapt the registers to my device ?

You don't need this library on an ATmega328p, this microcontroller has a "complete" hardware supported twi/i2c, it's no "USI" implementation. You can find USI mainly on "ATtiny" devices.

eriksl avatar Apr 23 '14 16:04 eriksl

For a special case I need to use a software I2C (slave) library and not the I2C hardware module of the ATmega. USI is not implemented on ATmega328p but isn't it similar to USART ? Don't you think it (usiTwiSlave) may function on ATmega if I change the register names to the USART registers? Thank you.

maali-mnasri avatar Apr 23 '14 22:04 maali-mnasri

On 24-04-14 00:27, ilaam wrote:

For a special case I need to use an I2C slave software library and not the I2C hardware module of the ATmega. USI is not implemented on ATmega328p but isn't it similar to USART ? Don't you think it may function on ATmega if I change the register names to the USART registers? Thank you.

I see your point but the library is really tailored for USI, including timings. I guess you'll have to search e.g. for i2c using bitbanging (which I am sure do exist). I know the USART on the ATmega328p can be used as secondary SPI device, but that's really something different. It's a nice challenge ;-)

I guess you need the TWI pins for something else ;-)

eriksl avatar Apr 24 '14 11:04 eriksl

Yes exactly TWI pins are already used. Thank you for your reply :+1: Now that you told me it's challenging to try to adapt usiTwiSlave to USART, I'll try again to find some bitbanging i2c lib because I already searched and all I could find were i2c master libraries not slave ones .

maali-mnasri avatar Apr 24 '14 12:04 maali-mnasri