View previous topic :: View next topic |
Author |
Message |
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Mon Jan 22, 2018 1:19 am Post subject: USI, TWI, I2C confusion |
|
|
I'm well aware I'm probably going to be critisicized for this but I figure after reading a LOT of mixed up stuff from (mostlly) old, some REALLY old (2003-2011) and some (very very few) newer posts I remain confused with regards TWI, USI & I2C and how to configure a maste and slave implementation on a particular AVR.
From my research (please DO correct me where I'm wrong / add more detail / clarity) :
as I understand it; I2C is a 2 wire serial interface created by nxp/Philips. TWI is basically the same idea/protocol but with a different name (for licensing reasons etc) on Atmel AVRs. I also understand that USI is a generic term (universal serial interface) referring to the complete serial interface (comm ports, I2C/TWI and (?) SPI on (more modern ?) AVRs.
Additionally, I believe older / less capable AVRs (ATtiny's etc) do NOT have a 'built-in' / ready-fitted / harfware I2C/TWI interface BUT they are capable of mimicing the interface via software. More modern / up-to-date / capable AVRs (M8 etc) DO have a built-in / ready fitted / hardware I2C/TWI interface (via the USI ?).
Furthermore, I see reference to (and have visited the MCS sales page) for an add-on I2CSlave library. Looks like it's fairly priced too, at around 15Euro.
My confusion arises when I try to get my head around *what* I need for *which* AVR and *which* I2C/TWI mode.
I've already said there are (I believe) two types of TWI/I2C AVRs - those with inbuilt/hardware capability and those without.
Those WITHOUT, that interest me, would include the ATtiny 2313 and those WITH woud include the ATmega8 and the ATMega2561. I use all three AVRs in various GPS and robotics projetcs - generally, though, without I2C.
Currently I would like to :
-1- create my own I2C SLAVE projects.
-2- use ssd1306 OLED (I2C) disp;ays with my AVRs.
I'm slowly moving away from the 2313's due to memory restrictions etc and have selected the ATMega8 for ALL my projects that don't need the additional capabilities of the 2561...
So..., if the above is basically correct and makes sense, to my question(s)...
-1- to create my own I2C SLAVE ATM8 devices (hardware TWI/I2C, I believe) : do I need the I2CSlave library addon ?
-2- to use an ATM8 to send data (master mode) to a TWI/I2C device : is this capabilty inherrent / inbuilt in BascomAVR 2.0.7.9 and + ?
-3- to create my own I2C SLAVE ATtiny2313 devices (hardware TWI/I2C, I believe) : do I need the I2CSlave library addon ?
-4- to use an ATtiny2313 to send data(master mode) to a TWI/I2C device : is this capabilty inherrent / inbuilt in BascomAVR 2.0.7.9 and + ?
Apologies for this being so long... there is simply so much old detail / FUD out there that I simply failed to grasp this topic completely.
Any help / corrections to my 'beliefs' above will not only help me but will, I'm sure, to really useful to others too.
Thanks a million, people. Appreciated.
(BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.8.1 ) _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Jan 22, 2018 2:44 pm Post subject: |
|
|
Hi, bonjour,
Quote: | I'm well aware I'm probably going to be critisicized for this but I figure after reading a LOT of mixed up stuff from (mostlly) old, some REALLY old (2003-2011) and some (very very few) newer posts I remain confused with regards TWI, USI & I2C and how to configure a master and slave implementation on a particular AVR. |
there are no stupid questions, there are only foolish people
about TWI/I2C , your are right but with Bascom you can create your own I2C soft port.
About the library from Mcselec , It is a method to create your own I2C slave or master, but you can use also the serial port - USI (Tx-rx) to transfer data between 2 (or more) µcontrolers
TX-RX is available on nearly all µcontrolers with enough ram using soft port with Bascom statement
see serial sample and help about UART
From years, I use ATtiny 45/85 (8 pins), ATmega 88-328 and 2560 (Arduino shield) and mega 644-1264
Arduino shield are very easy to use with Bascom (no need of programmer) but I had build my own dev. board.
M8, T2313 are old µC. When you visit the https://www.microchip.com/design-centers/8-bit/microchip-avr-mcus they are disapeared
-2- use ssd1306 OLED (I2C) disp;ays with my AVRs.
see : https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=13611
So..., if the above is basically correct and makes sense, to my question(s)...
-1- to create my own I2C SLAVE ATM8 devices (hardware TWI/I2C, I believe) : do I need the I2CSlave library addon ?
Yes !
-2- to use an ATM8 to send data (master mode) to a TWI/I2C device : is this capabilty inherrent / inbuilt in BascomAVR 2.0.7.9 and + ?
Yes !
-3- to create my own I2C SLAVE ATtiny2313 devices (hardware TWI/I2C, I believe) : do I need the I2CSlave library addon ?
Yes but I think you are short in flash memory only 2k !
-4- to use an ATtiny2313 to send data(master mode) to a TWI/I2C device : is this capabilty inherrent / inbuilt in BascomAVR 2.0.7.9 and + ?
Yes but I think you are short in flash memory only 2k !
if you need French speaking help you can send me a message jp030405atyahoo.fr
JP
|
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Mon Jan 22, 2018 3:07 pm Post subject: |
|
|
Salut JP,
Merci beaucoup pour vos reponses !
Si, je vous comprends bien, il faut d'avoir le 'I2C addon' (de MCS) pour faire les choses I2C avec le ATMega8. Je vais aller l'acheter maintenant.
Merci encore ! _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Jan 22, 2018 4:47 pm Post subject: |
|
|
Please use English in this forum, could you imagine EDC wrinting in Polish ? |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Jan 22, 2018 4:54 pm Post subject: |
|
|
Quote: | il faut d'avoir le 'I2C addon' (de MCS) pour faire les choses I2C avec le ATMega8 |
No, to use a master as ssd1306 OLED, DS3231... you don't need the addon, but to create a master you need it.
Also be careful to save your addon, you must copy it in the directory where Basic -bascom is located with each update.
jp[/url] |
|
Back to top |
|
|
Wattsy
Joined: 21 Nov 2005 Posts: 102 Location: Finistere (on the beach)
|
Posted: Tue Jan 23, 2018 3:36 pm Post subject: |
|
|
Thanks JP.
Noted - English only.
Thanks again. _________________ and there it was... gone !
Bascom Full Version 2.0.8.1
STK300 IDE |
|
Back to top |
|
|
AlanGHosler
Joined: 25 Jan 2011 Posts: 109
|
Posted: Sat Jan 27, 2018 3:48 am Post subject: I2C MSC slave library |
|
|
If you are interested, I have posted codes under "Post your working BASCOM AVR code here" that show how I used the MSC library to communicate between a ATmega1284 (as the master) and a ATtiny861A (as the slave). However, the codes are long so you may not want to start your learning process there but if you have difficulty the codes might be useful. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|