Hi I am trying to use SPI to interface with a sensor chip, but I cant get a clock signal out of my arduino micro's sck pin on the icsp header or the sck pin on the booard! Help!
-Omar
Hi I am trying to use SPI to interface with a sensor chip, but I cant get a clock signal out of my arduino micro's sck pin on the icsp header or the sck pin on the booard! Help!
-Omar
My guess is that you must use a digital i/o pin to simulate a clock signal.
Going to arduino.cc and looking at an example that uses
#include <SPI.h>
and supports my guess in that Digital Pin 13 is used for SCK.
On the Arduino Nano pin 13 and sck are the same. I looked at the schematic. But on my Micro that is not the case. I checked to see whether I am getting a clock from the crystal oscillator and I am, but I am still not able to get a clock out of either sck pin.
Well, think about this; Only when the Master of the SPI is talking or listening will there be a CLK on DP13. In other words, the program has to be running. In particular, SPI.begin(); must have been executed.
Reference Documentation for SPI is here: http://arduino.cc/en/Reference/SPI
Jeremy Blum covers SPI output on this video: http://www.youtube.com/watch?v=1nO2SSExEnQ
and SPI Input on this video: http://www.jeremyblum.com/2010/08/27/reacxion-build-progress/
1. Wow. Your "nano" was made by whom? What Atmel chip is on your "nano" board? This is info you should have provided in you very first posting.
2. If I had known that Raivis Rengelis had already answered this same question. I would not have bothered to answer here.
3. Multiple postings of the same question - is abuse of your priviledges on element14 , IMO. Don't do it, Omar.
Don't feel bad Billabbott, reading you is always helpful and instructive.
Sorry I wont do it again. I am using an Arduino Micro. It is the Arduino Nano that has its sck pin and digital pin 13 tied together. And I have not seen the response by Ravis Rangelis.
While boucing my brain off the html backboard at arduino.cc, it occurred to me that it appears you remain firmly impaled on the horns of your dillema. Not wishing you to remain so impaled; I once again perused the contents of http://arduino.cc/en/Reference/SPI to discover an interesting fact or two about the Slave Select pin on ATMEL's ATMega family as implemented by the Arduino SPI library.
Quote: "Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative." And according to the table located above that statement, it is revealed that pin 10 on the UNO and Duemilenove is the pin at issue. However, on the Mega1280 and Mega2560, pin 53 is the potential trouble spot.
ONLY one of the two examples given for SPI usage properly inform the arduino experimenter of the NEED to connect pin 10 as an output to the Chip Select or Chip Enable of the sensor IC. In the case of the AD5206 Digital Potentiometer example, the connection is properly documented. Whereas the Barometric Pressure Sensor example quietly deploys pin 7 of the arduino to do the work of selecting the chip. BUT, the quote given above in this post states that the SPI library demands pin 10 be an output regardless if another output pin is actually doing the job of enabling a sensor IC of some kind. {The webmaster@arduino.cc has been requested to modify documentation for Baro-Pressure example so users can avoid this pitfall.}
This phrase "rendering the library inoperative" clearly means that the SCLK will be turned OFF and the pin will change to an input pin listening for a SCLK from the SPI Master IC. That would be arduino in SPI Slave mode, which the Library does not support.
Bottom line: If pinmode(10,Input); is executed before? or after? SPI.begin(); then there will be no SCLK on pin 13.
While boucing my brain off the html backboard at arduino.cc, it occurred to me that it appears you remain firmly impaled on the horns of your dillema. Not wishing you to remain so impaled; I once again perused the contents of http://arduino.cc/en/Reference/SPI to discover an interesting fact or two about the Slave Select pin on ATMEL's ATMega family as implemented by the Arduino SPI library.
Quote: "Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative." And according to the table located above that statement, it is revealed that pin 10 on the UNO and Duemilenove is the pin at issue. However, on the Mega1280 and Mega2560, pin 53 is the potential trouble spot.
ONLY one of the two examples given for SPI usage properly inform the arduino experimenter of the NEED to connect pin 10 as an output to the Chip Select or Chip Enable of the sensor IC. In the case of the AD5206 Digital Potentiometer example, the connection is properly documented. Whereas the Barometric Pressure Sensor example quietly deploys pin 7 of the arduino to do the work of selecting the chip. BUT, the quote given above in this post states that the SPI library demands pin 10 be an output regardless if another output pin is actually doing the job of enabling a sensor IC of some kind. {The webmaster@arduino.cc has been requested to modify documentation for Baro-Pressure example so users can avoid this pitfall.}
This phrase "rendering the library inoperative" clearly means that the SCLK will be turned OFF and the pin will change to an input pin listening for a SCLK from the SPI Master IC. That would be arduino in SPI Slave mode, which the Library does not support.
Bottom line: If pinmode(10,Input); is executed before? or after? SPI.begin(); then there will be no SCLK on pin 13.
Okay I see. I also conacted Arduino, and they replied to me saying that SCK is only active when theArduino board is sending sending and recieving data. SPI.Begin intializes the clock to the devault 4Mhz but one only sees clock signal when data is being transfered. This is the reason why I was not getting any clock signla before. Thank you for the help, it is much appreciated and again sorry for anything I've done wrong as I am new to this community.
Glad to have you as part of the community. Helping new people learn the ropes is part of the process. I am glad to know that the Arduino expert agreed with what I said in my second post. Your inquiry made me dig around and discover a flaw in their example. So, overall, excellent progress was made.
Challenge: Draw your circuit up in Fritzing 0.7.11 and post a .jpg and .fzz files here.