Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: SPI clock troubles... ?? on: February 22, 2011, 10:19:16 pm
Another quick question:

From the SPI.begin() help on the arduino website:

Initializes the SPI bus, setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low and SS high."

What if you have a chip that needs SS low to select the chip? Does "pulling SCK low" mean it pulls SCK low no matter what the SPI data mode is set to? Also, does SPI.begin() set MISO to an INPUT? This seems a little unclear to me from the arduino help. I'm still playing around with it trying to get some expected communication between the arduino and the slave, but still no avail. Thanks.

2  Using Arduino / Programming Questions / Re: SPI clock troubles... ?? on: February 22, 2011, 10:08:53 pm
Thanks all for the info. This is our first time using SPI and we are still trying to debug things and get everything talking.

Nick, that is a GREAT logic analyzer output. I was considering doing this as well to try and figure out SPI. Looks like you've already answered all the questions I would have about SPI with your logic analyzer output smiley.

Gray, I wasn't sure if pinMode(...) and Serial.begin(...) were global functions if we called them inside void setup ().

I will try to change a few things in my code in order to take these new insights into consideration and let everyone know how it goes.

3  Using Arduino / Programming Questions / SPI clock troubles... ?? on: February 21, 2011, 11:39:06 pm
Hi. We are working with the Arduino Mini for a school project and cannot seem to get SPI working. We are trying to pull sensor data from a 3 axis accelerometer and can't get it to work. We tried to set up a simple program that simply shows us the output of SCK, but cannot get it to work I have one main question:

Is there a function to call in order to start the SPI clock (SCK)? We have tried to read the SPI clock (pin 13 as per the arduino SPI help) with the arduino mini, but cannot seem to get a clock signal from it; we only get zero's. The arduino reference says that SPI.begin() pulls SCK low, which would make sense since we are getting only zero's. Is there something else we need to do to initialize SCK? Below is the code:

#include <SPI.h>
unsigned int x=0;

void setup () {

void loop () {

  pinMode(7, INPUT);
  pinMode(8, OUTPUT);
  digitalWrite(8, HIGH);
  x = digitalRead(7);
  digitalWrite(8, LOW);

We have SCK (pin 13) hooked directly to pin 7 so that we can read the clock, but like I said, we get nothing but zero's. Any help is appreciated!!
Pages: [1]