9 years, 10 months ago.

SPI and SPI.Slave

Hello, I would like to send and receive data via SPI association with the same microcontroller: SPI Master and SPI Slave. I connected the two clocks together. But with the SPI Slave connection I receive no value! I do not understand why! Yet at the terminal miso I have a value that happens. Thank you for your reply

Is it possible to use the same SPI to send and receive ?

Here is my program:

  1. include "mbed.h"
  2. include <SPISlave.h>

SPI dac(p11, p12, p13); mosi, miso, sclk SPISlave adc(p5, p6, p7, p8); mosi, miso, sclk, ssel DigitalOut cs1(p21), csadc(p8); int val = 0, val2 = 0;

int main() { cs1 = 1; csadc = 1; dac.format(16,1); dac.frequency(1000000);

while (1) {

printf("Enter decimal value :"); scanf("%d", &val); printf("dac= %d\r\n",val); cs1 = 0; csadc = 0; dac.write(val); if(adc.receive()) { val2 = adc.read(); printf("adc= %d\r\n",val2); } cs1=1; csadc = 1; } }

Be the first to answer this question.