I2C master/slave code for ATtiny series 1

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

Since I found Atmels's I2C sample code somewhat confusing I wrote my own code for 

 

a) polled master, including functions to access slave c)

b) interrupt driven slave

c) as b), organized as addressable byte array, similar to EEPROM

 

The code is much more compact and robust against transmission faults than Microchip's original code. I have made extensive tests arbitrarily shorting the signal lines against ground. During these tests both master and slave recovered under all circumstances. Code development was somewhat tricky since the processors did not behave under all circumstances as expected from Microchips's documentation.

 

The code has been tested with two ATtiny processors operatings as master and slave. So far I have not done any tests with "real life" I2C chips. I would be glad to receive comments, enhancements, criticism, especially from interested forum members that could provide tests with I2C periphery.

 

A ZIP file is included, please ask questions if code usage needs additional explanation.

Attachment(s): 

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

not quite sure if this is the right place for this post. maybe in tutorials section is better ?

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

Nicely done, I've grabbed a copy I hope to try out on a t4809 when I have the time.

I might suggest you put a copy on github, then you will only need to post a link to it.

Thanks again for the contribution.

 

Jim

 

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

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

Drei,

 

I downloaded your I2C library and attempted to use it to get an SSD1306 Display working using an Attiny 1614.  I am using Atmel Studio 7.  When I added your I2C.c it failed with it could not find the following "#include <lx-ctrl5.h>".  I commented that out and it compiled.  However, I was not able to get anything to display.  I attempted to make use of the U8G2 library and then another one that was more basic but in both cases nothing displayed (looks like for the second library I used there was a very fast flashing of text).  I am sure that I am doing something minor wrong but do you happen to have an Atmel Studio solution for the attiny 1-series with a SSD1306 (or other oled) that you could provide.  I know this is asking a lot but I have tried every I2C library I could find (even Atmels) but yours as least made the display flash :)

 

Edit:  I managed to get a noisy looking screen (using both U8G2 and generic OLED library) after changing the F_CPU to the correct frequency.  Since I am using Atmel Studio I did not realize that the prescaler was set and I used the standard 8Mhz for the frequency.  Wrong.  The 1614s are 20MHz.  Still not working thou.  I might now go back and try other I2C solutions to see if they work.

 

 

Thanks

P

Last Edited: Thu. Aug 8, 2019 - 04:44 PM