Go Down

Topic: Communicating with IC's without a library (Read 856 times) previous topic - next topic



So I have had this question for ages and I've tried to tackle it step by step.  Although I've realized I don't know what the first step is (aside from analyze the datasheet as if it were the last document in its language). 

i'll start fairly simple.  Say I have the TLC5940, which there is an arduino library for.  What would I have to do in order to get that library to work with the ATtiny85. 

Or say I have an IC that doesn't have a library, but I want to use it with an Atmega328p chip.  What would I do there?

Anybody have a good guide?
Accelerate to 88 miles per hour.


You answered the question in your first paragraph.

The datasheet is the only document that can help you.

That will tell you what protocol (if any) to use to communicate with the device, or what voltage levels, etc it gives out.  You can then use the tools at your disposal (things like SPI, I²C, analog reading, etc) to communicate with it in the right way.


But how do you know what kind of data to send to it?

HIGH, LOW, 10110010, 3E, 0x000004.
Accelerate to 88 miles per hour.


Print out the data sheet, print out a working Arduino library for that device, and walk through the code, cross referencing the data sheet.  WIth a little time and some effort, the example of the working code will allow you to understand the datasheet and vice versa...  Ultimately doing this once or twice with different chips will allow you to get to the point where you can read a datasheet and then write the needed code for it.

Some form of logic analyzer or oscilloscope can be very helpful.  If you don't already have one, you can pick up something like the Bus pirate for about the price of an Arduino that can give you many of the abilities of a logic analyzer (among other functions) that can help (but is not necessary) achieve the needed understanding.

http://www.sparkfun.com/products/9544 One source for the Bus Pirate


Jun 17, 2012, 08:56 pm Last Edit: Jun 17, 2012, 08:58 pm by pekkaa Reason: 1
Code: [Select]
But how do you know what kind of data to send to it?

HIGH, LOW, 10110010, 3E, 0x000004.

If you send data to an external IC,  you send HIGHs and LOWs to it, that is, you set the pins to 0V and 5V (different ICs may require different voltage levels) in certain order for certain periods of time. Things like 10110010, 3E, 0x000004 are higher level abstractions of the data and the datasheet explains how the data maps to HIGHs and LOWs.


A library is just the collected data of how to communicate with a device and put in an easy to use form, you can communicate with an ic without a library , just in a sketch with the right commands
even digitalwrite is an example, if you look at the source you see that just to set a pin high or low there's a little work involved, the command makes it simple almost like a shortcut to all those other commands that are needed


Okay, So I think i'm just gonna buckle down with the library i'm most familiar with, TLC5940, and then compare it to the datasheet and how it works and all that good stuff.  Thanks for the help everybody!
Accelerate to 88 miles per hour.

Go Up