This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] LP-AM243:可变长度 MCPSI?

Guru**** 1821780 points
Other Parts Discussed in Thread: ADS131M06
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1069447/lp-am243-variable-length-mcpsi

部件号:LP-AM243
“线程:ADS131M06”中讨论的其它部件

因此,ADS131m06 ADC 的工作数据长度可变,我正在尝试将它们的准代码应用到 CCS 中。 默认情况下,数据长度设置为24位。

bool adcRegisterWrite(unsigned short addrMask, unsigned short data,
unsigned char adcWordLength){
unsigned char shiftValue; // Stores the amount of bit shift based on
 // ADC word length
if(adcWordLength==16){
shiftValue = 0; // If length is 16, no shift
}else if(adcWordLength==24){
shiftValue = 8; // If length is 24, shift left by 8
}else if(adcWordLength==32){
shiftValue = 16; // If length is 32, shift left by 16
}else{
return false; // If not, invalid length
}
SPI.write((WREG_OPCODE | // Write address and opcode
addrMask) << shiftValue);// Shift to accommodate ADC word length

SPI.write(data << shiftValue);// Write register data
while(SPI.isBusy()); // Wait for data to complete sending
return true;
}

在这之前,他们使用“SPI.wordLengthSet(24)”;之后他们将单词长度设置为32。 是否有 MCSPI 库命令可用于更改类似的单词长度?

您还会如何建议实施可变数据框架? 在该代码中,它多次调用 SPI.write()来接收数据,但 MCSPI 具有此缓冲系统,这可能更方便。 我是否应该有不同的具有不同阵列宽度的 TX/RX 缓冲区来实现这一点,或者我可以指定使用多少个 TX/RX 阵列元素? 也许使用.count 变量。

CCS 代码:

 /* Initiate transfer */
    spiTransaction.channel  = gConfigMcspi0ChCfg[0].chNum;
    spiTransaction.count    = APP_MCSPI_MSGSIZE / (gConfigMcspi0ChCfg[0].dataSize/8);
    spiTransaction.txBuf    = (void *)gMcspiTxBuffer;
    spiTransaction.rxBuf    = (void *)gMcspiRxBuffer;
    spiTransaction.args     = NULL;
    transferOK = MCSPI_transfer(gMcspiHandle[CONFIG_MCSPI0], &spiTransaction);

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,迪伦,

    MCSPI 帧大小是在 example.syscfg“MCSPI 通道配置0”数据帧大小(位)中配置的:

    gConfigMcspi0Chcfg[0].dataSize 将是您的数据帧大小。 spiTransaction.count 将是您要为每个 MCSPI_TRANSFER()读取/写入的数据帧数(每个帧都有数据帧大小)。

    此致,