Software implementation of TWI Slave

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone,

Does anyone can provide me a library for Software implementation of TWI Slave? I'm currently using XMEGA A1U. I have checked Peter Fluery and and Pascal Stang, none of their work include such a library.

Last Edited: Tue. Oct 24, 2017 - 05:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you clarify, are you looking for slave software using the h/w TWI module, or a pure software implementation of I2C protocol using any pair of port pins?

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry ki0bk, I'm not sure I get you question. I'm new in i2c communication. But currently I'm using an xmega to play a role of slave in the I2C communication. However, I ran out of all my I2C hardware interfaces. And I am looking to use some other pins as SCL and SDA.

So I should be looking for a pure software implementation of i2c protocol using a pair of port pins.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any software-only serial receiver needs a lot of system resources. They need to sit polling pins to capture all transitions.

 

What do you mean by 'ran out'? TWI can support multiple devices on a bus.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Each bus has two MPU sensors already. All the buses on the xmega are occupied and I'm looking to output the data through I2C to another device.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wenyu wrote:

Each bus has two MPU sensors already. All the buses on the xmega are occupied and I'm looking to output the data through I2C to another device.

 

Ah, so you've run out of address space? Each sensor can only have two addresses?

 

You might want to consider an 'I2C multiplexer'.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, each sensor can only have two addresses. I should take a look into "i2c Multiplexer". Thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wenyu wrote:
 I'm new in i2c communication. 

So this does sounds rather an ambitious first project, then?

 

Go to the NXP site to learn about I2C - they are the inventors of I2C.

 

The I2C Specification: https://www.nxp.com/docs/en/user-guide/UM10204.pdf

 

Brian Fairchild wrote:
You might want to consider an 'I2C multiplexer'.

Again, see NXP for details & products.

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Again, see NXP for details & products.

 

Or eBay, lots of them on eBay.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yea it is an ambitious project. I have been working on this for couple months.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just anyone who might be interested, I am using peter fleury's software library to define my chip as master to spare one of my hardware bus to set up the chip as a slave.