I am attempting to communicate through SPI with a digital Gyro. Here is my current problem. I was able to setup the SPI peripheral in the ATMega1284 with no issues. I am able to successfully send the address command to the gyro… I have verified using my Digital O’Scope that the CS, MOSI and SCK lines work properly. My issue is with the MISO line. If I read the output directly from the DO line on the Gyro (Disconnected from the MISO line), the Gyro sends the correct data. When I connect the MISO line the signal is pulled down. It seems like another device on the SPI chain is pulling the MISO line to ground. The gyro is able to barely pull up the data bits… that is, I can see the signal attenuated about 2/3. Not enough to reach the digital high thershold. Again when disconnected the output pin on the Gyro works correctly when I connect the MISO line, the line is pulled down. Any suggestions? Has anyone seen this? Thank you in advanced for your help.
When you connected your gyro to MISO you are are actually causing a short because the auxiliary processor acts a slave on the SPI bus while the AVR is running, so it drives the MISO line.
Fortunately, you can reconfigure the auxiliary processor to get around this problem. Here’s what I recommend doing:
Put a 220 Ohm resistor between the gyro’s MISO line and the SVP to avoid that short in the future.
Maximize the voltage on the ADC/SSbar line by turning the user potentiometer.
Add the following code to the top of your program. It uses the Pololu AVR C/C++ Library to send an SPI command to the auxiliary processor which tells it to start paying attention to the SSbar (slave select) line. Documentation is here: pololu.com/docs/0J18/13
svp_set_mode(SVP_MODE_RX | SVP_SLAVE_SELECT_ON);
Within a few milliseconds after running this command, the auxiliary processor should stop driving the MISO line and you should be able to communicate with the gyro.
Unfortunately, with this setup you won’t be able to use the user potentiometer and it will be tricky (but still possible) to communicate with the auxiliary processor.
It would probably be easier to use USART0 or USART1 in SPI mode, or to just do bit-banging on any three I/O lines of your choosing.
Yes, it worked. Thanks for your help.