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 )
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.
>
------------------------------------
______________________________
controlSUITE software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!

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