16 bit ADC with SPI

31 Jan 2011

Hello,

I've been using the mbed for a while now, and used it with succes in a domotica system (with four Mbeds)to control network cam, RFID card reader, electronic doorlock and lighting. (This was a groupeffort, where my part was the camera control + external PIR's)

Now i started a new project. I'm trying to hook up a external 16 bit ADC with the mbed using SPI. (adc = ADS8320 from TI)

I never used SPI, but i got an example running (gives back whoami). Can somebody give me some hints about how and where to start.

31 Jan 2011

Hi Marcel

The best way I have found is to write a librray for the specific part you are deal with. The library itself should deal with all the hardware bits and bobs of the device and export a number of API methods so you main program doesn't need to know the hardware sections, just needs to deal with teh devices functionality.

As an example, start a new project, say just call "example" and then import the following library:-

Import libraryMAX3100

MAX3100, an external serial device to add additional serial ports via SPI

You aren't going to try and compile this, you don't have a MAX3100. But look at the project and see how to organise a "device library". The MAX3100 is an SPI to UART device so that example shows how to encapsulate an SPI device into a library which should give you a good starting point.

Remember though, make sure you have read the device datasheet carefully before trying to implement too much code! You need to know the devices functionaly before starting your library proper.

31 Jan 2011

Thx for the reply,

I will look into it. If i got it working i'll let it know.