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

TMS320C6748: Unable to setup SPI 3 pin mode connection.

Part Number:TMS320C6748

Hello, I am new to TMS320C6748 board. I wanted to setup SPI connection between this board as master and any other sensor as slave using 3 pin mode. I am not getting any direct sample code for it. 
I am sharing my code. Currently it's BITERRFLG is getting set, which giving generating an error.
Please help.
Your early assistance is appreciated.

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <\ti\pdk_C6748_2_0_0_0\C6748_StarterWare_1_20_03_03\include\hw\hw_psc_C6748.h>
#include <\ti\pdk_C6748_2_0_0_0\C6748_StarterWare_1_20_03_03\include\psc.h>
#include <\ti\pdk_C6748_2_0_0_0\C6748_StarterWare_1_20_03_03\include\hw\soc_C6748.h>
#include <\ti\pdk_C6748_2_0_0_0\C6748_StarterWare_1_20_03_03\drivers\psc.c>
#include <\ti\pdk_C6748_2_0_0_0\C6748_StarterWare_1_20_03_03\include\spi.h>
#include <\ti\pdk_C6748_2_0_0_0\C6748_StarterWare_1_20_03_03\include\hw\hw_spi.h>
#include <\ti\pdk_C6748_2_0_0_0\C6748_StarterWare_1_20_03_03\drivers\spi.c>

#define SPIGCR0 0x0000
#define SPIGCR1 0x0001
#define SPIINT0 0x0002
#define SPILVL 0x0003
#define SPIFLG 0x0004
#define SPIPC0 0x0005
#define SPIPC1 0x0006
#define SPIPC2 0x0007
#define SPIPC3 0x0008
#define SPIPC4 0x0009
#define SPIPC5 0x000A
#define SPIRES1 0x000B
#define SPIRES2 0x000C
#define SPIRES3 0x000D
#define SPIDAT0 0x000E
#define SPIDAT1 0x000F
#define SPIBUF 0x0010
#define SPIEMU 0x0011
#define SPIDELAY 0x0012
#define SPIDEF 0x0013
#define SPIFMT0 0x0014
#define SPIFMT1 0x0015
#define SPIFMT2 0x0016
#define SPIFMT3 0x0017
#define INTVECT0 0x0018
#define INTVECT1 0x0019


void main()
{ PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_SPI0, PSC_POWERDOMAIN_ALWAYS_ON,PSC_MDCTL_NEXT_ENABLE);
volatile unsigned int * spi0_ptr = (unsigned int *)0x01C41000 ;
unsigned int i,flg0,rx0;
/* Configure SPI0 for master */
/* 1. Take the SPI0 out of reset */
spi0_ptr[SPIGCR0]=0x01;


/* 2. Configure SPI0 for master */
spi0_ptr[SPIGCR1]=0x03;
/* 3. Configure SPI0 for 3-pin mode */
spi0_ptr[SPIPC0]=0x0E00;
/* 4. Chose SPI0 SPIFMT1 */
spi0_ptr[SPIDAT1]=0x01000000;
/* 5. Configure SPI0 for WAITENA=1,SHIFTDIR=0,POLARITY=1,PHASE=0,
CHARLEN=16 */
//spi0_ptr[SPIFMT1]=0x00221810;


/* 6. Configure SPI0 for C2TDELAY=2,T2CDELAY=2,T2EDELAY=4,C2EDELAY=8 */
spi0_ptr[SPIDELAY]=0x02020408;
//SPIDelayConfigure(SOC_SPI_0_REGS,0,0,20,20);

/* 7. Configure SPI0 for polling */
spi0_ptr[SPIINT0]=0x00;
/* 8. Enable SPI0 communication */
spi0_ptr[SPIGCR1]|=0x01000000;
spi0_ptr[SPIFLG] &= 0xFFFFFFEF;
/* 9. Handle data transfer and error checking using polling */
SPIClkConfigure(SOC_SPI_0_REGS, 150000000, 1000000, SPI_DATA_FORMAT1);


/* Wait for master receive data */
for(i=1;i<0x10000;++i){spi0_ptr[SPIDAT0] = 0x00;
}
while(1){
 unsigned int a =  SPIDataReceive(*spi0_ptr);
 printf("0x%02X\n",a);rx0=spi0_ptr[SPIBUF]&0xFFFF;printf("0x%02X\n", rx0);
flg0=spi0_ptr[SPIFLG];
if(flg0&0x10){
printf("Master bit transmission error\n");
exit(5);
}
if(flg0&0x08){
printf("Master detected slave desynchronization error\n");
exit(6);
}
if(flg0&0x02){
printf("Master detected slave timeout error\n");
exit(7);
}
if(flg0&0x100)
break;
else if(flg0){
printf("Unknown master error\n");
exit(8);
}
}
rx0=spi0_ptr[SPIBUF]&0xFFFF;
printf("0x%02X", rx0);
}

Vivian Gao:

Hi

Jonathan has already asked the experts on the English forum for you, please refer to the answers in link below

e2e.ti.com/…/tms320c6748-spi-communication-with-ads1298

赞(0)
未经允许不得转载:TI中文支持网 » TMS320C6748: Unable to setup SPI 3 pin mode connection.
分享到: 更多 (0)