Sign in

username:

password:



Not a member?

Search avrclub



Search tips

Subscribe to avrclub



avrclub by Keywords

AT90S2313 | AT90S8515 | ATMega | ATmega128 | ECL | FETS | IAR | Keyboard | LCD | STK50 | TMOS | UART


Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | AVRclub | [AVR club] Newbie Q: TWI/I2C


Advertise Here

Atmel AVR Microcontroller discussion group.

[AVR club] Newbie Q: TWI/I2C - meiya777 - Jul 14 15:12:09 2009

Hi all,
Am new here, new in AVR field, and using CodeVision AVR.

I want to learn about the TWI for my work. I search a lot but still get confused, my current project is:

1. there is a main module with mega128 (mostly deal with buttons and lcd)

2. there is sub-module with mega8 connect to proximity sensor (int0) and dac (only for calculating and adjusting the speed of the machine, and the speed is shown on lcd controlled by main module)

3. there is sub-module with mega8 connect to proximity sensor (int0), contrast sensor (adc), and relay (to read the contrast sensor whenever int0 is triggered, and switch on/off the relay whenever is needed. The value of contrast sensor is shown on lcd controlled by main module)

I need guidance (not only source code) how to communicate main module with 2 sub-modules using TWI, and they have to be able to transfer data with each other.

Thanks in advanced.

------------------------------------



(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )


[AVR club] Re: Newbie Q: TWI/I2C - "s.h...@btinternet.com" - Jul 14 16:29:27 2009

Hi,

Atmel have a good application note AN315 which explains how the TWI module works, it's a good place to start. You are not making things easy for yourself as you will need to configure each device as a master and a slave if the communication is 2 way, you will need to set the addresses also. Have a look see what you think.

Just as a way out idea, you might want to put a i2c eeprom on the board, then the sub modules can write to specific memory pages within the eeprom and the main module can then read the data from the eeprom, that way each module is configured as a master and the eeprom is the slave, the eeprom is then the comms scratch pad, mamaging access can be easy as a pin connected to all devices can be used as a CE line so that al the devices know when is is being used or use an address match, just an idea.

Regards

--- In a...@yahoogroups.com, "meiya777" wrote:
>
> Hi all,
> Am new here, new in AVR field, and using CodeVision AVR.
>
> I want to learn about the TWI for my work. I search a lot but still get confused, my current project is:
>
> 1. there is a main module with mega128 (mostly deal with buttons and lcd)
>
> 2. there is sub-module with mega8 connect to proximity sensor (int0) and dac (only for calculating and adjusting the speed of the machine, and the speed is shown on lcd controlled by main module)
>
> 3. there is sub-module with mega8 connect to proximity sensor (int0), contrast sensor (adc), and relay (to read the contrast sensor whenever int0 is triggered, and switch on/off the relay whenever is needed. The value of contrast sensor is shown on lcd controlled by main module)
>
> I need guidance (not only source code) how to communicate main module with 2 sub-modules using TWI, and they have to be able to transfer data with each other.
>
> Thanks in advanced.
>

------------------------------------



(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )