Hello all
I have a question about the Spi interface.
When I run simple code I got double clock in my oscilloscope.
I want to know how I can get single clock or how I can adjust delay time between two clocks.
Here is the code.
Thank you,
Alex
- include "mbed.h"
Serial pc(USBTX, USBRX);
SPI spi(NC, p6, p7); using only clock 7 and miso 6
long EncoderValue;
int Encoder;
Ticker ReadEncoder;
void Read(){
pc.printf("Start\n");
spi.format(13,2); Setup the spi for 13 bit data, mode 2
spi.frequency(4000000); Create 4Mhz clock pc.printf("Start\n");
int upper = spi.write(0x00);
int lower = spi.write(0x00);
lower = lower >> 6;
upper = (upper << 6)+lower;
pc.printf("%d \r", upper);
}
int main()
{
pc.printf("Hello World!\n");
ReadEncoder.attach_us(&Read, 100000); call flip every 100 milli-seconds
while(1) {
}
}
Hello all I have a question about the Spi interface. When I run simple code I got double clock in my oscilloscope. I want to know how I can get single clock or how I can adjust delay time between two clocks. Here is the code. Thank you, Alex
long EncoderValue; int Encoder;
Ticker ReadEncoder; void Read(){
pc.printf("Start\n"); spi.format(13,2); Setup the spi for 13 bit data, mode 2 spi.frequency(4000000); Create 4Mhz clock pc.printf("Start\n");
int upper = spi.write(0x00); int lower = spi.write(0x00); lower = lower >> 6; upper = (upper << 6)+lower;
pc.printf("%d \r", upper); }
int main() { pc.printf("Hello World!\n"); ReadEncoder.attach_us(&Read, 100000); call flip every 100 milli-seconds
while(1) { } }