I'm trying to use an Arduino UNO to programme a DAC via SPI, using the Arduino SPI library. I was having problems getting my code working so I hooked up a 'scope to the clock and data pins of the SPI bus. I noticed that if I just ran my code once then I got junk out of the SPI bus. In particular, rather than getting a clock pulse for each bit of my bytes, I would get a single, long clock pulse for each byte. I found that if I put my code in a loop so it repeatedly sent data over the SPI port then the Arduino would begin by sending junk however, after a second or so, it seemed to sort itself out and behave nicely.
Naturally, I assumed that this was something to do with my code, so I copied various bits of example code from the web. But always found this same behaviour. I also (for the sake of paranoia) swapped in a fresh Arduino to check for faulty hardware. Is there something I'm missing here? Is this known behaviour for the SPI library?