You have /SS set as an input. It either needs to be tied high, or, made an output. Read the data sheet w/regard to multi-master operation. ----------- Larry Barello www.barello.net | -----Original Message----- | From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf | Of Robert Ussery | | Hi, all... | I'm having some trouble with an SPI interface on the Mega32, which I'm | using to communicate with a TI TLV2543 ADC. I'm programming the micro in | C using avr-gcc. | | Here's my problem... using the SPI transmit code more or less straight | from the Mega32 datasheet: | SPDR = (channel<<4)|(ADCSetup); | while(!(SPSR & (1<<SPIF))); | my code keeps getting stuck in an infinite loop at that while() | statement, but only on the 30th iteration or so (the micro loops through | the ADC code indefinitely). The first 29ish times through the code, | everything works perfectly. Am I missing something with how to handle | the SPIF flag? I RTFM'd and all that, and it says that SPIF is set and | reset automatically based on the SPI state and when SPDR is read. | | I've included all of my code at the end of this email, but here are some | of the more relevant parts: | SPI setup: | // Set MOSI and SCK output, all others input | DDRB = (1<<PB5)|(1<<PB7); | // Enable SPI, Master, set clock rate fck/128 | SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0); | | The ADC code is contained in the function ADCRead(), as shown in the | code below. | | Am I making some classic n00b mistake here? Any advice or pointers are | welcome.
Message
RE: [AVR-Chat] SPI Interface freezeup on Mega32
2006-03-25 by Larry Barello
Attachments
- No local attachments were found for this message.