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.
10 years ago.
SPI slave 16bit mode setup nRF51 dk
So I'll try to keep my question short. I've included the .cpp code in this question because it's very little.
When I set up my spi I can read the data i'm sending on my tera term when i have the spi.format set to (8,2) my master is also set to mode 2 as well. But when i set my spi.format to (16,2) and program the nRF i get the the pairs of LED1-LED3 and LED2-LED4 alternately flashing with each other. I can't find what this means anywhere. Also i can't read any data on my tera term at this point as well. My master is configured as a 16 bit spi so this should work.
any help would be appreciated because I've looked everywhere and I can't figure out what is happening. Sorry I'm very new to this and excuse the formatting as well.
///////////
include "mbed.h"
SPISlave spi(P0_25, P0_28, P0_29, P0_24); Serial pc(USBTX, USBRX);
int main() {
spi.format(16,2);
spi.frequency(100000);
pc.baud(9600);
spi.reply(0x00); Prime SPI with first reply
while(1) { if(spi.receive()) {
int v = spi.read(); Read byte from master
spi.reply(v); Make this the next reply
pc.printf("Received Data = 0x%X\n\r",v); } } }
///////////////
Question relating to:
1 Answer
8 years, 6 months ago.
what's the use of the code given below:
spi.reply(0x00); Prime SPI with first reply
because normally spi doesn't require to give out acknowledgement (ACK) to the master , then why do we use it?