“线程:测试”中讨论的其它部件,
根据数据表。 要写入您发送的注册表:
香港时间19时5分
因此,我将我的 TX 缓冲区设置为0x6180,以写入地址为0x03h 的时钟(根据数据表)
IE:0110 0001 1000 0000
制造 N 0不应真正影响此处的任何内容。 当我进行24位的 MCSPI 数据传输时,我会得到一致的0x3fc7f8 (或其他类似结果)返回。
下面是我用来发送这些消息的代码:
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); ...
也许这是 MCSPI 工作方式方面的一个错误,但我已正确设置了所有内容(据我所知):
4引脚模式,TX 和 Rx,D1上的输入,D1上的 TX 启用,d0上的 TX 禁用,传输模式阻止,CS 极性(低),频率25MHz,数据帧大小(24)
有谁能帮助我了解如何发送和接收我希望看到的数据?