spi

Posted on
  • Hi,
    how to read acknowledgement of slave in SPI communication?

  • I'm not aware of any ack in (basic) SPI communication - except when you expect the device to which you talk is delivering data while you keep the clock ticking... see some (basic intro here)[http://www.embedded.com/electronics-blog­s/beginner-s-corner/4023908/Introduction­-to-Serial-Peripheral-Interface].

    For reading from a device, you usually send a command - a few bytes - which go with as many clock ticks as bits and then you do a read which is basically producing clock ticks for the number of bytes times 8 and on either rise or fall within the tick cycle you capture the master input line status and compose the statuses to bits. While this all happens, the chip select line has to stay active - usually low because it is -CS.

    Of course it is not your application that has to handle this clocking and status capturing. It is implemented in firmware and micro controller hardware. In the application you just invoke the SPI methods / functions... some they let you optionally pass a parameter for that chip select pin, so you do not even have to handle chip select by yourself. But it always depends on the spec the device expects.

    Take a look at data sheet of some SPI connectable devices wherein some basics and the device specifics are explained. As one article explains, it is a communication 'within a box' which means that the connectivity is very controlled and reliable under practically any circumstances.

  • As @allObjects says, I think this is specific to whatever SPI device you have. Usually, it works as follows:

    var data = SPI.send([command, 0xFF], csPin);
    result = data[1];
    

    So you send a command, then a 'no-op' byte (usually 0xFF or 0x00). Two bytes are returned - the first is useless, but the second will be the result of the SPI command.

  • Thank you very much for the replay.

About

spi

Posted by Avatar for krishna @krishna

Actions