MSP430F1611 SPI Interface w/ADC

Hi,

I want to know how I can interface the SPI with an external ADC. Has anyone done this before?

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!

Reply to
AmyLe
Loading thread data ...

Hi,

I want to know how I can interface the SPI with an external ADC. Has anyone done this before?

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!

Reply to
AmyLe

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!

Reply to
AmyLe

First, you need to select an ADC. No additional work can proceed until you've selected it.

JJS

Reply to
John Speth

Hey,

Oh yeah, I'm using the ADC78H90

formatting link
ADC78H90.html). But in general, where should I start?

Reply to
AmyLe

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.
Reply to
CBFalconer

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
 Click to see the full signature
Reply to
Tim Wescott

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.
Reply to
Neil

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

Reply to
Mark Borgerson

Hi everyone,

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

Reply to
AmyLe

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.