I'm trying, for the first time, to use the SPI library. Please could someone confirm whether SPI.begin and/or SPI.beginTransaction should start the clock pin oscillating?
I have disconnected everything from the Uno apart from my oscilloscope which is connected to pin 13 (have also tried others) but don't see any voltage change on the pin. It is just sitting at 0V.
I've also tried measuring it whilst transferring data (or at least trying to) and similarly see no voltage change.
I would start by going here: Basics of the SPI Communication Protocol to get a basic idea of what you are trying to do. Then go here: SPI Tutorial – Serial Peripheral Interface Bus Protocol Basics this will explain the many modes of the SPI interface. Then find a small sketch that uses the SPI and play with it. By that time you will have a good understanding of it and how to use it. This response is to help you get started in finding the problem, not solve it for you.
Good Luck & Have Fun!
Gil
Thanks but I had already googled those links. I specifically wanted to avoid half a day of experimenting to figure out when the clock is expected to oscillate - is it when .beginTransaction is called or .transfer and whether the clock would also run when all the SPI wires are floating.
Thanks. I get the clock pulses doing that. Still not sure what I was doing wrong but it gets me further along the path knowing that when I do get it right, I do get a 4MHz clock from your code.
Rocket888888:
Thanks. I get the clock pulses doing that. Still not sure what I was doing wrong but it gets me further along the path knowing that when I do get it right, I do get a 4MHz clock from your code.
You should get 125 KHz ckock (default SPI bit transfer speed) from my codes and not 4 MHz. Check that the bit period is: 1/125000 = 8 us.