TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS570LS1114接收TPS65381A-Q1回复数据整体右移了一位,导致接回来的数据不正确

TMS570LS1114接收TPS65381A-Q1回复数据整体右移了一位,导致接回来的数据不正确,接回来的数据应该是以0xA8开头的,我的接回来的是0x50开头的,我发送命令使用的是无奇偶校验的命令,有大神知道是什么原因吗?

user6121941:

回复 Susan Yang:

#include "sys_common.h"
#include "spi.h"
#include "gio.h"

spiDAT1_t peizhi;

uint16 cmd[2] = {0x5D55,0x3E00};//0x55解锁写命令, 0x3E
uint16 rcv[5] = {0};
/* USER CODE END */
void main(void)
{
/* USER CODE BEGIN (3) */int i;spiInit();peizhi.CS_HOLD = 1;peizhi.DFSEL = SPI_FMT_1;peizhi.WDEL = 0;peizhi.CSNR = SPI_CS_0;while(1){
spiTransmitAndReceiveData(spiREG3, &peizhi, 1, cmd, rcv);for(i=0;i<100;i++);spiTransmitAndReceiveData(spiREG3, &peizhi, 1, &cmd[1], &rcv[1]);
}
/* USER CODE END */
}
您好,我抓了一下波形,时序图和datasheet的一致,这是源码,我用的是无奇偶校验的命令,为什么所有写命令回复是都是FF? 是我的命令发的错误还是什么原因呢? 能帮忙解答一下吗?谢谢您

Susan Yang:

回复 user6121941:

建议您先试一下下面的程序

/** @file example_SPI_Master_Slave.c
*@brief Application main file
*@date 25.July.2013
*@version 03.06.00
*
*This file contains an example of SPI1 and SPI2 Master / Slave configurations.
*
*PIN Connections must be as Below
*------------------------------
*SPI1 ( Master )SPI2 ( SLave)
*------------------------------
*SIM0--->SIMO
*S0MI<---SOMI
*CLK--->CLK
*CS0--->CS0
*
*------------------
*GUI configurations
*------------------
*1) Driver TAB
*- Select SPI2
*- Select SPI1
*2) VIm Channel 0-31
*- Enable SPI2 Level 0 and Level 1 channels.
*3) SPI2 TAB
*- SPI2 Global SubTAB
*- Uncheck Master Mode
*- Uncheck Internal Clock
*- SPI2 Port SubTAB
*- Uncheck DIR for CS 0
*3) SPI1 TAB
*- Have it default
*4) Generate Code.
*
*//* (c) Texas Instruments 2009-2013, All rights reserved. *//* USER CODE BEGIN (0) */
/* USER CODE END *//* Include Files */#include "sys_common.h"
#include "system.h"/* USER CODE BEGIN (1) */
#include "spi.h"
/* USER CODE END *//** @fn void main(void)
*@brief Application main function
*@note This function is empty by default.
*
*This function is called after startup.
*The user can use this function to implement the application.
*//* USER CODE BEGIN (2) */
uint16 TX_Data_Master[16] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 };
uint16 TX_Data_Slave[16]= { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20 };
uint16 RX_Data_Master[16] = { 0 };
uint16 RX_Data_Slave[16]= { 0 };
/* USER CODE END */void main(void)
{
/* USER CODE BEGIN (3) */spiDAT1_t dataconfig1_t;dataconfig1_t.CS_HOLD = FALSE;dataconfig1_t.WDEL= TRUE;dataconfig1_t.DFSEL= SPI_FMT_0;dataconfig1_t.CSNR= 0xFE;/* Enable CPU Interrupt through CPSR */_enable_IRQ();/* Initialize SPI Module Based on GUI configuration* SPI1 - Master ( SIMO, SOMI, CLK, CS0 )* SPI2 - Slave( SIMO, SOMI, CLK, CS0 )* */spiInit();/* Initiate SPI2 Transmit and Receive through Interrupt Mode */spiSendAndGetData(spiREG2, &dataconfig1_t, 16, TX_Data_Slave, RX_Data_Slave);/* Initiate SPI1 Transmit and Receive through Polling Mode*/spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 16, TX_Data_Master, RX_Data_Master);while(1);
/* USER CODE END */
}/* USER CODE BEGIN (4) */
/* USER CODE END */
赞(0)
未经允许不得转载:TI中文支持网 » TMS570LS1114接收TPS65381A-Q1回复数据整体右移了一位,导致接回来的数据不正确
分享到: 更多 (0)