Hello,everyone.
I’m got some trouble when reading the CIR data form DWM1000 module.I used MSP430F5438 as a controller and referred to the program of dwt_readaccdata(uint8 *buffer, uint16 len, uint16 bufferoffset) to read the CIR data, but the data returned was always like this, or a similar waveform with a certain delay. I have checked for a long time, but I have not been able to find the problem.
The basic configuration of the module is as follows:
Channel:1
DataRate:6.8M
PRF:16M
The procedures for turning the clock on and off for register 0x36:00 are as follows:
int getready_readCIR()
{
int SJL;
if(dw_configure.PRF==16)
{
SJL=3968;
}
else //else if(dw_configure.PRF==64)
{
SJL=4064;
}
P3OUT &=~BIT0;
Write(4,load3600kaibuf); //unsigned char load3600kaibuf[4]={0xF6,0x00,0x44,0x82};
//FACE=1,RXCLKS=01,AMCE=1,
P3OUT |=BIT0;
DelayNus(1);
return SJL;
}
void finish_readCIR()
{
P3OUT &=~BIT0;
Write(4,load3600guanbuf); //unsigned char load3600guanbuf[4]={0xF6,0x00,0x00,0x02};
//FACE=0,RXCLKS=00,AMCE=0,
P3OUT |=BIT0;
DelayNus(1);
}
Since the MSP430 has limited RAM and cannot set an excessively large cache array, I modified the program to read the CIR to only read the CIR data of one sample per cycle, and the specific procedure is as follows:
void read_CIR(int hang)
{
int j;
unsigned char FWCIR[4][4];
for(j=0;j<4;j++)
{
FWCIR[j][0]=0x65; //read form 0x25
if(hang%128==0)
{
FWCIR[j][1]=0x80;
if(hang/128==0)
{
FWCIR[j][2]=0x00;
}
else
{
FWCIR[j][2]=(unsigned char)(hang/128);
}
}
else
{
FWCIR[j][1]=0x80 | (unsigned char)(hang%128);
FWCIR[j][2]=(unsigned char)(hang/128);
}
hang+=1;
}
int m,n;
for(m=0;m<4;m++)
{
unsigned char Temp[4];
for(n=0;n<4;n++)
{
Temp[n]=FWCIR[m][n];
}
P3OUT &=~BIT0;
pan(Temp);
Read(4,Temp);
P3OUT |=BIT0;
DelayNus(1);
switch(m)
{
case 0:
{
Lrealpart=rbuf[0];
}; break;
case 1:
{
Hrealpart=rbuf[0];
}; break;
case 2:
{
Limaginarypart=rbuf[0];
}; break;
case 3:
{
Himaginarypart=rbuf[0];
}; break;
default: ; break;
}
}
}
(It should be noted that using the Read() function will store the valid data read into the rbuf variable in turn.)
The procedure for using the serial port to access CIR data and return it in real time is as follows:
void msp_to_pc(void)
{
int i,JJ;
WDTCTL = WDTPW+WDTHOLD;
P3SEL |= BIT4+BIT5;
P3DIR |= BIT4;
UCA0CTL1 |= UCSWRST;
UCA0CTL0 = 0x00;
UCA0CTL1 |= UCSSEL_2;
UCA0BR0 = 0X8A;
UCA0BR1 = 0X00;
UCA0MCTL = UCBRS_7+UCBRF_0;
UCA0CTL1 &= ~UCSWRST;
getready_readCIR();
for(i=0;i<SJL;i+=4)
{
read_CIR(i);
FINAL_data[0]=Lrealpart;
FINAL_data[1]=Hrealpart;
FINAL_data[2]=Limaginarypart;
FINAL_data[3]=Himaginarypart;
for(JJ=0;JJ<4;JJ++)
{
UCA0TXBUF = FINAL_data[JJ];
DelayNms(1);
while(!(UCA0IFG & UCTXIFG));
}
}
fasongbaoshu++;
finish_readCIR();
}
In addition to the basic configuration of the main() function, the following procedures are used for ranging and accessing CIR data:
while(1)
{
for(anchor_num=1;anchor_num<2;anchor_num++) //For single anchor
{
flag1=youxiaocejucishu; //Mark1
tx_rx(); //two-way ranging process
cejucishu++; //Mark2
if (flag1!=youxiaocejucishu) //correct two-way raging
{
msp_to_pc();
}
}
cejuzushu++; //Mark3
}
The general situation is like the above, if you have any suggestions for the above questions, please be sure to leave a message to me, thank you very much!