EmbeddedRelated.com
Forums
Memfault Beyond the Launch

MSP430F1611 SPI Interface w/ADC

Started by AmyLe September 14, 2007
Hi,

I want to know how I can interface the SPI with an external ADC.  Has
anyone done this before? Also, I prefer using polling instead of
interrups.



Here is my INIT SPI function:

=============================INIT_SPI=================================

void Init_SPI(void)
{
  P3SEL |= 0x3F;		      // Select P3.0,1,2,3,4,5
  P3DIR |= 0x0B;                    // Select P3.1,3 as output
directions
  P3OUT &= ~0x01;
  ME1 |= USPIE0;                    // ENABLE USART0 SPI
  UCTL0 |= CHAR + SYNC + MM;        //  8-bit data, SPI mode
  UTCTL0 |=  CKPH + CKPL + SSEL1;  //  Inv.delay, ACLK
  UBR00 = 0x2A;                     // Baud Rate = 115200
  UBR10 = 0x0;
  UMCTL0 = 0x0;                     // Clear Modulation
  UCTL0 &= ~SWRST;                  // Initialize USART state machine

  //_BIS_SR(LPM3_bits + GIE);         // Enter LPM0 w/interrupt

} //end Init_SPI

====================================================================

I'm using IAR.  Thank you so much for your help!

"AmyLe" <amyle.01@gmail.com> wrote in message 
news:1189789319.398691.36650@k79g2000hse.googlegroups.com...
> I want to know how I can interface the SPI with an external ADC. Has > anyone done this before? Also, I prefer using polling instead of > interrups.
First, you need to select an ADC. No additional work can proceed until you've selected it. JJS
Hey,

Oh yeah, I'm using the ADC78H90 (http://www.national.com/pf/DC/
ADC78H90.html).  But in general, where should I start?

AmyLe wrote:
> > Oh yeah, I'm using the ADC78H90 (http://www.national.com/pf/DC/ > ADC78H90.html). But in general, where should I start?
Start what? Believe it or not, that is why normal Usenet users quote the pertinant parts of the previous messages. Usenet is a 'best efforts' delivery mechanism, and there is no guarantee that your reader has ever, or ever will in the future, read any other messages. Thus it is essential that the quotes make each message complete in itself. -- Chuck F (cbfalconer at maineline dot net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net> -- Posted via a free Usenet account from http://www.teranews.com
On Fri, 14 Sep 2007 20:57:52 +0000, AmyLe wrote:

> Hey, > > Oh yeah, I'm using the ADC78H90 (http://www.national.com/pf/DC/ > ADC78H90.html). But in general, where should I start?
I general, you should start with three things: the ADC data sheet, the processor data sheet, and a brain. By preference the brain should belong to you, but if you must use one that doesn't then you should consider brain training aids, like offers of beer. Aside from these three necessary things, an oscilloscope is handy, to let the brain make sure that the code is doing what it should. Have the brain read both of the data sheets, particularly the sections that pertain to the SPI interface. Have the brain write whatever code is necessary to make the processor emit the necessary bit stream for the ADC, and read in the bit stream from the ADC. While you're at it, have the brain look at the schematic of the board. This may not work at first -- you may have to flog the brain for a while to get it to write code that works. Hence the preference for using your own brains -- other people tend to get upset when you flog their brains. This is also where the 'scope comes in handy -- usually having a 'scope handy during the initial trials will significantly reduce the amount of time you have to flog the brain. Good luck, and don't forget the beer. -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
AmyLe wrote:
> Hey, > > Oh yeah, I'm using the ADC78H90 (http://www.national.com/pf/DC/ > ADC78H90.html). But in general, where should I start? >
1) figure the correct SPI. The data may transfer on the rising or falling edge of the clock. Check the MPU data sheet and the A2D data sheet timing diagrams. 2) Check the clock rate. the A2D has a maximum clock rate and sometimes a minimum rate.
In article <mt2dnVtxyYjognbbnZ2dnUVZ_hudnZ2d@web-ster.com>, 
tim@seemywebsite.com says...
> On Fri, 14 Sep 2007 20:57:52 +0000, AmyLe wrote: > > > Hey, > > > > Oh yeah, I'm using the ADC78H90 (http://www.national.com/pf/DC/ > > ADC78H90.html). But in general, where should I start? > > I general, you should start with three things: the ADC data sheet, the > processor data sheet, and a brain. By preference the brain should belong > to you, but if you must use one that doesn't then you should consider > brain training aids, like offers of beer. > > Aside from these three necessary things, an oscilloscope is handy, to let > the brain make sure that the code is doing what it should. > > Have the brain read both of the data sheets, particularly the sections > that pertain to the SPI interface. Have the brain write whatever code is > necessary to make the processor emit the necessary bit stream for the ADC, > and read in the bit stream from the ADC. While you're at it, have the > brain look at the schematic of the board. > > This may not work at first -- you may have to flog the brain for a while > to get it to write code that works. Hence the preference for using your > own brains -- other people tend to get upset when you flog their brains. > This is also where the 'scope comes in handy -- usually having a 'scope > handy during the initial trials will significantly reduce the amount of > time you have to flog the brain. > > Good luck, and don't forget the beer. >
Simplified versin: Make sure that you can see a clock on SCLK when you call the ADC conversion routine. No Clock to ADC == No data! You can do this stuff without fancy logic analyzers. You can do it without a COMPLETE understanding of the chip. You CANNOT do it without an oscilloscope! Mark Borgerson
Hi everyone,

Thank you for your responses, I have a better understanding of the
interface now.  Thanks a lot!


Memfault Beyond the Launch