Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
How do I get rid of the one SPI clock cycle delay between each spi.write command?
I would like to send a continuous 24 bit clock without any clock delay in mbed? It seems to me that it only support 8 and 16 but not 24 bits. Please advise.
Here is my codes.
#include "mbed.h" SPI spi(p5, p6, p7); //mosi, miso, sclk DigitalOut cs_n(p8); DigitalOut led1(LED1); Serial pc(USBTX, USBRX); // tx, rx int main() { // Chip must be deselected cs_n = 1; led1 = 0; // Setup the spi for 8 bit data, high steady state clock, // second edge capture, with a 1MHz clock rate spi.format(16,3); spi.frequency(1000000); wait(1); while (1) { // Select the device by seting chip select low cs_n = 0; int Num1=spi.write (0x00); // send the address location of 0x0010 and expect to read the content to SerialNum int Num2=spi.write (0x00); int Num3=spi.write (0x00); int Num4=spi.write (0x00); cs_n = 1; printf ("Read Value = 0x %2X %2X %2X %2X \n\n", Num1, Num2,Num3,Num4); // re-check the content again. wait_ms(50); } }