I am currently using one of the chips, DSP280025C or DSP28335, to communicate with TMAG5170A2. However, no matter how I modify the sent data, the received signal always remains the same. The following is my configuration code and the sending instruction code.My CS is clock low.
InitSysCtrl();
Board_init();
Para_Init();
Tmag5170_Init();
Tmag5170_start();
while(1)
{
result=Tmag_x_result() ;
}
void mySPI0_init(){
SPI_disableModule(mySPI0_BASE);
SPI_setConfig(mySPI0_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
SPI_MODE_CONTROLLER, 1000000, 8);
SPI_setPTESignalPolarity(mySPI0_BASE, SPI_PTE_ACTIVE_LOW);
SPI_disableFIFO(mySPI0_BASE);
SPI_disableLoopback(mySPI0_BASE);
SPI_setEmulationMode(mySPI0_BASE, SPI_EMULATION_FREE_RUN);
SPI_enableModule(mySPI0_BASE);
}
void Tmag5170_Init(void)
{
Send32BitData(0x0F000407);
Send32BitData(0x00400806);
Send32BitData(0x0103aa05);
Send32BitData(0x02000000);
Send32BitData(0x11000000);
}
void Tmag5170_start(void)
{
Send32BitData(0x00002808);}
Uint32 Tmag_x_result(void )
{
Uint32 x_result_noset;
x_result_noset =Receive32BitData(0x89000000);
return x_result_noset;
}
Uint16 SPI_ReceiveData(Uint16 a)
{
Uint16 rdata;
while(SpiaRegs.SPISTS.bit.BUFFULL_FLAG);
SpiaRegs.SPITXBUF = a;
while(SpiaRegs.SPISTS.bit.INT_FLAG==0);
rdata = SpiaRegs.SPIRXBUF;
return rdata;
}
void Send32BitData(Uint32 data)
{
Uint16 highWord = (data >> 16) & 0xFFFF;
Uint16 lowWord = data & 0xFFFF;
SPI_SendData(highWord);
SPI_SendData(lowWord);
GpioDataRegs.GPASET.bit.GPIO6 = 1;
}