主题中讨论的其他器件:ADS8881、
工具/软件:Code Composer Studio
大家好、我想通过 SP 读取具有 CC2650的18位 ADC ADS8881。
我卡在 SPI 代码中、ADC 为18位、CC2650只能读取16位帧。 如何读取两个器件?
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.
您好、因为响应问题
我使用此代码、但我看不到 rxbuf 上的更改
*==== empty.c ======
//
//* XDCtools 头文件*/
#include
#include
/* BIOS 头文件*/
#include
#include
#include
/* TI-RTOS 头文件*/
#include
#include
#include
/*电路板头文件*/
#include "Board.h"
#define DELAY_ms (I) Task_sleep ((((i)* 1000)/ Clock_tickPeriod)
#define TASKSTACKSIZE 516
Task_StructectK0Struct];
Char FlashStack[TASKSTACKSIZE];
static SPI_Handle spiHandle = NULL;
static SPI_Params spiams task0Struct;
SPI_BoardTransaction Transaction Transaction;
static PIN_Handle
= NULL;static Pin Statical_Handle = NULL;static FlashState_Pin = static Pin State_Pin 配置= NULL;static Pin State.
BOARD_SPI_FLASH_CS | PIN_GPIO_OUTP_EN | PIN_GPIO_HIGH | PIN_PushPull | PIN_DRVSTR_MIN、//扩展闪存芯片选择
PIN_TERMINATE
};
void taskFxn (UArg0、UArgarg1)
{
System_printf ("启动 SPI 任务\n");
SPI_Params_init (&spiParams);
spiParams.dataSize = 9;
spiParams.transferMode = SPI_MODE_BLOCKING;
spiParams.mode = SPI_MASTER;
spiParams.bitrate = 100000;
spiHandle = SPI_open (Board_SPI0、&spiParams);
while (1){
//delay_ns (2);
//const uint8_t wbuf[]={0x90、0xFF、0xFF、0x00};
uint16_t rbuf[2];
int ret = 0;
SPI_Transaction masterTransaction;
masterTransaction.count = 9;
masterTransaction.txBuf = 0x000000001;
masterTransaction.arg =空;
masterTransaction.rxBuf =空;
RET = SPI_transfer (spiHandle、&masterTransaction)? 0:-1;
system_printf ("返回的%d\n", ret);
//delay_ns (600);
masterTransaction.count = 9;
masterTransaction.txBuf =空;
masterTransaction.arg =空;
masterTransaction.rxBuf = rbuf;
RET = SPI_transfer (spiHandle、&masterTransaction)? 0:-1;
system_printf ("返回的%d\n", ret);
}
}
/*
=== main ====
*/
int main (void)
{
Task_Params taskParams;
/*呼叫板初始化函数*/
Board_initGeneral();
Board_initSPI();
/*构造任务线程*/
Task_Params_init (&taskParams);
taskParams.STACKSIZE = TASKSTACKSIZE;
taskParams.stack = task0Stack;
Task_construct(&task0Struct,(Task_FuncPtr) taskFxn、&taskParams、NULL);
hFlashPin = PIN_OPEN (&flashPinState、BoardFlashPinTable);
if (!hFlashPin){
System_abort ("初始化闪存引脚时出错");
}
/*启动 BIOS */
BIOS_start();
返回(0);
}
我不确定我的行为是什么
您好、Eduardo、
有关您提供的代码片段的一些观察结果:
masterTransaction.txBuf = 0x000000001;
事务结构的 txBuf 和 rxBuf 参数是指向数据的指针、设置 txBuf、因为您将导致 SPI 发送
从内存位置0x00000001开始的数据(如果不是、导致从开始崩溃)。
您还可以每次将事务计数设置为9、这意味着您希望发送/接收9个条目。 这意味着提供的缓冲器需要相应地调整大小。 例如、rbuf 需要至少为9个深的条目、除非您将计数更改为2 (我想您实际上只打算读取2个条目)。
器件型号:CC2650
工具/软件:Code Composer Studio
大家好、我想读取18位的 ADS8881、我有这个代码、但我不知道如何读取18位
uint16_t wbuf[]={(uint16_t) 0b1}; uint16_t rbuf[2]; int ret = 0;
void taskFxn (UArg0、UArgarg1)
{
System_printf ("启动 SPI 任务\n");
SPI_Params_init (&spiParams);
spiParams.dataSize = 9;
//spiParams.transferMode = SPI_MODE_BLOCKING;
spiParams.mode = SPI_MASTER;
spiParams.bitrate = 10000000;
spiParams.frameFormat = SPI_TI;
spiHandle = SPI_open (Board_SPI0、&spiParams);
if (spiHandle ==空)
{
while (1);
System_printf ("启动 SPI 失败");// SPI_open ()失败
}
while (1)
{
delay_ms (100);
SPI_Transaction masterTransaction;
masterTransaction.count = 18;
masterTransaction.txBuf = wbuf;
masterTransaction.rxBuf = rbuf;
RET = SPI_transfer (spiHandle、&masterTransaction);
}
这是另一种尝试:
while (1) { delay_ms (1000); SPI_Transaction masterTransaction; masterTransaction.count = 1; masterTransaction.txBuf = wbuf; masterTransaction.rxBuf = rbuf; RET = SPI_transfer (spiHandle、&masterTransaction); DELAY_ms (0.7); masterTransaction.count = 2; masterTransaction.txBuf =空; masterTransaction.rxBuf = rbuf; RET = SPI_transfer (spiHandle、&masterTransaction); }
作为读取18位的示例、我将欣赏任何代码
您好!
我会使用 SPI_POL0_PHA0帧格式而不是 TI 帧格式、它似乎更符合您的器件、我可以告诉您。 您还应将 位速率从10MHz 降低到4MHz、这是经验证的器件支持的最大值。
通过这些更改、我只需设置如下所示的传输:
uint16_t wbuf[2]={0}; uint16_t rbuf[2]={0}; masterTransaction.count = 2; masterTransaction.txBuf = wbuf; masterTransaction.rxBuf = rbuf; ret = SPI_transfer (spiHandle、 主事务);
如果您根本不需要向器件写入任何内容、则可以将 txBuf 设置为 NULL。
您还需要更改板级配置文件中的 minDmaTransfer 大小、以避免驱动程序使用轮询模式:
CONST SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1310_LAUNCHXL_SPICOUNT]={ { baseAddr = SSI0_BASE、 .intNum = INT_SSI0_comb、 .intPriority =~0、 .wiPriority = 0、 powerMngrId = PowerCC26XX_Periph_SSI0、 defaultTxBufValue = 0xFF、 .rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX, txChannelBitMask = 1< }