This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52 sending an octet

Hello,

I have been trying to use the nRF52 preview DK board as a master device with another chip as its slave device. Now I know that to read or write the function used is spi_send_recv which is provided in the example code for spi master. The chip requires specific registers to be written to so that it can be initialized.The problem is that I only want to send one byte but it appears that the minimum being sent to the MOSI pin is 2 bytes. Currently when I want to write to a specific register in the chip I use this function:

void as3911WriteRegister(uint8_t reg, uint8_t val){

uint8_t write_buffer[2];

SEGGER_RTT_WriteString(0, "Entered Write Register\n");

write_buffer[0] = reg | AS3911_WRITE_MODE;

write_buffer[1] = val;

spi_send_recv(write_buffer, NULL, 2);

}

Which sends 2 bytes as expected and as wanted, however there is another method where I only wish to send one byte which is:

void as3911ExecuteCommand(uint8_t cmd){

SEGGER_RTT_WriteString(0, "Entered Execute Command\n");

cmd |= AS3911_CMD_MODE;

spi_send_recv(&cmd, NULL, 1);

}

But after this method executes I still get 16 bits at MOSI, the first 8 are the cmd which is all thats wanted but the next 8 are the overrun characters 0xCC. I only need the first 8 and then the SS signal should turn high (so that the direct command begins execution on the chip) but that is not the case at the moment.

Why does this happen and how do I go about sending only an octet when needed?

Thank you in advance

Parents Reply Children
No Data
Related