According to the datasheet. To write to a register you send:
011A AAAA ANNN NNNN
So I put on my TX buffer: 0x6180, to write to CLOCK which has an address of 0x03h (according to the datasheet)
ie: 0110 0001 1000 0000
Making N 0 should not really affect anything here. When I do the MCSPI data transfer of 24 bits, I get in return 0x3fc7f8 (or other similar results) consistently.
Here is the code I used to send these messages:
void adcWriteReg( unsigned short data, unsigned char wordLength, unsigned char size, MCSPI_Transaction spiTransaction) { int32_t status = SystemP_SUCCESS; uint32_t i; int32_t transferOK; unsigned char shiftValue; if(wordLength == 16) { shiftValue = 0; } else if(wordLength == 24) { shiftValue = 8; } else if(wordLength == 32) { shiftValue = 16; } else { } // Setup Buffers gMcspiTxBuffer[0] = (data << shiftValue); gMcspiRxBuffer[0] = 0U; spiTransaction.count = size / (gConfigMcspi0ChCfg[0].dataSize / APP_MCSPI_WORD); transferOK = MCSPI_transfer(gMcspiHandle[CONFIG_MCSPI0], &spiTransaction); if((SystemP_SUCCESS != transferOK) || (MCSPI_TRANSFER_COMPLETED != spiTransaction.status)) { DebugP_assert(FALSE); /* MCSPI transfer failed!! */ } else { /* Print Data */ for(i = 0U; i < size; i++) { DebugP_log("( %x -> %x )\n", gMcspiTxBuffer[i],gMcspiRxBuffer[i]); } } } ... adcWriteReg((WREG | CLOCK_ADDR), 24, 1, spiTransaction); adcWriteReg(CLOCK_CH0_EN | CLOCK_OSR_1024 | CLOCK_PWR_HR, 24, 1, spiTransaction); ...
Perhaps its an error on the side of how MCSPI works, but I have setup everything correctly (to my knowledge):
4 pin mode, tx and rx, input on D1, tx enabled on d1, tx disabled on d0, transfer mode blocking, CS polarity (low), frequency 25MHz, data frame size (24)
Can anyone help me figure out how to send and receive data that I expect to see?