I need to pulse the clock pin, then pulse the latch pin. This is to initialize the AD9851 DDS. The next step is to write all zeros in the tuning word of the AD9851. Subsequent writes using the SPI interface work just fine.
By including the SPI.h file, I am wondering if the SCK pin (53) of the Arduino MEGA R3 board can be controlled before the SPI.beginTransaction.
Thanks for the tip. I'm using a mixed signal oscilloscope to monitor SCK, MOSI and Latch pins, and notice the clock pulses nicely when transmitting data, and the latch pin does, in fact, pulse, but the clock pin will not pulse using digitalWrite(53, {HIGH, LOW}).
SCK idles low, as does MOSI and the Latch. Wish I could upload a pic of the scope screen. After sending the 5 zeros, I pulse the latch pin, then transmit a tuning word of 00896024 for a frequency of 9,003,400 Hz, LSB first, and it works great. Just got to pulse the clock and latch pins first. One method to do this in hardware is to use an OR gate with the SCK as one input, and a digital output pin as the other input to create the pulse.
According to the official Arduino documentation, what you are trying to do should work. The hardware settings are applied during SPI.beginTransaction(), and released after a call to .endTransaction(). The library is then supposed to release the bus for use by other functions or libraries.
Please verify the ability to pulse that pin with a simpler example program, and if that control is lost if you merely #include the library.
Finally, keep in mind that the SPI bus is not very well defined, and some devices do not behave well when connected to it. There are a number of problematic sensors and displays that "take over" the bus and prevent other SPI devices from functioning when connected in parallel.
Oops, sorry to waste cycles, but looking again at the pinout for SPI on the Arduino Mega R3, the clock pin is 52, not 53, as is seen in the above code. Changed the pin to 52, and it works.
Thank you for looking!