Clock Frequency from Serial Clock (SCK) pin

I am trying to provide a 32kHz clock signal from the master (Spark Core) to the slave device.

I would like to know the clock frequency on the serial clock pin (SCK) when Serial Peripheral Interface (SPI) is enabled.

That pin does not output a continuous clock. It is only active when you are reading or writing SPI data.

@v8dave Thank you.
Is there a pin on the Spark Core that I could use to provide a continuous (32kHz) clock signal to an external device ?

I’ve not tried this before but you could use a timer to setup an IO pin to generate the clock. I’ve done this on Atmel AVR to generate a 38Khz signal for a Infra Red transmitter and I saw that peekay123 has some IR generating code on his github that you might be able to adapt for this.

I would have a look at the spark servo library as well, it generates a 50hz PWM for servo’s…

https://github.com/spark/core-firmware/blob/master/inc/spark_wiring_servo.h

https://github.com/spark/core-firmware/blob/master/src/spark_wiring_servo.cpp

Hi @v8dave, to read SPI data, how can I enable the SCK if data is incoming? Thank you.

normally the SPI device has a no-op code that you send to it, otherwise a code thats not a command or register may work…

as the no-op is clocked in to the device MOSI line the device clocks out its data on the MISO line…

here is a snippet from a library I’m in the process of writing. i looped MOSI and MISO on the core to test :slight_smile:
full library here if you want to try it out https://github.com/Hootie81/Dual-DC-Motor/tree/master/Dual%20DC%20Motor%20v1-0/Library

uint8_t _NOOP = 0x00;
uint8_t _CMD_NOOP = 0x20

_checkCMD = SPI.transfer(_CMD_NOOP);
Serial.print(" CMD: ");
Serial.print(_CMD_NOOP, HEX);
_checkDATA = SPI.transfer(_NOOP);
Serial.print(" Data: ");
Serial.print(_NOOP, HEX);
Serial.print(" CheckCMD: "); //check the return CMD is correct last one should be the CMD sent
Serial.print(_checkCMD, HEX);
Serial.print(" CheckDATA: "); //check the return Data is correct last one should be the Data sent
Serial.print(_checkDATA, HEX);