AnsweredAssumed Answered

21489 sport

Question asked by tree on Sep 4, 2012
Latest reply on Sep 4, 2012 by Harshit.Gaharwar

Hi,

     I am using ADS-21489 to receive data,both sport0 and sport1 was configed as a receiver,and i did not know how to use or config the sport,I tried to use it in standerd serial mode ,and some of my code is as follows,

section("seg_sdram") unsigned short ch1_buf[DATA_LEN];//通道一采集数据用于相位检测
section("seg_sdram") unsigned short ch2_buf[DATA_LEN];//通道二采集数据用于相位检测
unsigned int sam_count;       //采集数据个数

//--------------------------波形显示----------------------------------//
section("seg_sdram") unsigned short fir_data_sam1[FIR_SAM_N];  //通道1 采集数据用于显示
section("seg_sdram") unsigned short fir_data_sam2[FIR_SAM_N];  //通道2 采集数据用于显示

/* TCB = "Transfer Control Block" */
int rcv0a_tcb[8]  = { 0,0,0,0,0, DATA_LEN,2, (unsigned short) ch1_buf}; // SPORT0 receive a tcb
int rcv0b_tcb[8]  = { 0,0,0,0,0, DATA_LEN,2, (unsigned short) ch1_buf+1}; // SPORT0 receive b tcb

int rcv1a_tcb[8]  = { 0,0,0,0,0, DATA_LEN,2, (unsigned short) ch2_buf}; // SPORT1 receive a tcb
int rcv1b_tcb[8]  = { 0,0,0,0,0, DATA_LEN,2, (unsigned short) ch2_buf+1}; // SPORT1 receive b tcb
//-------------------------------------------------------------------------------//
int rcv0a_f_tcb[8]  = { 0,0,0,0,0, FIR_SAM_N,2, (unsigned short) fir_data_sam1}; // SPORT0 receive a tcb
int rcv0b_f_tcb[8]  = { 0,0,0,0,0, FIR_SAM_N,2, (unsigned short) fir_data_sam1+1}; // SPORT0 receive b tcb

int rcv1a_f_tcb[8]  = { 0,0,0,0,0, FIR_SAM_N,2, (unsigned short) fir_data_sam2}; // SPORT1 receive a tcb
int rcv1b_f_tcb[8]  = { 0,0,0,0,0, FIR_SAM_N,2, (unsigned short) fir_data_sam2+1}; // SPORT1 receive b tcb


/**********************************************************************************
* 名称 :Init_SPORT01_DMA
* 功能 :初始化SPORT0,SPORT1和它们所对应的DMA
*      (每个sport的A和B两个数据端口都有专用的DMA)
* 入口参数 :manner:  1:相位检测;  2:FIR(采集数据显示)  3:FFT(谱分析)
*  fir_data_sam2  frequency: 1: 200KHz, 2: 1MHz, 3: 10.7MHz, 4: 21.4MHz, 5: 30.85MHz, 6: 40.05MHz, 7: 49.95MHz
* 出口参数 :无
***********************************************************************************/
void Init_SPORT01_DMA(char frequency,char manner){

unsigned int data_len;    //实际采集数据个数 相位检测
unsigned int wait_count=1;
unsigned int LIRPTL;
unsigned int IRPTL;
//为防止出现硬件错误,首先禁用SPORT
    *pSPCTL0 = 0;
    *pSPCTL1 = 0;
   
/* External clock and frame syncs generated by FPGA */
*pDIV0=0x00000000;
*pDIV1=0x00000000;

    switch(frequency)
    {
     case 1:data_len=F1_LEN;break;
     case 2:data_len=F2_LEN;break;
     case 3:data_len=F3_LEN;break;
     case 4:data_len=F4_LEN;break;
     case 5:data_len=F5_LEN;break;
     case 6:data_len=F6_LEN;break;
     case 7:data_len=F7_LEN;break;
     default:break;
    }
   
    switch(manner)
    {
     case 1:
   // Enable chain pointer registers before enabling DMA
   rcv0a_tcb[4] = *pCPSP0A = ((int) rcv0a_tcb + 7) & 0x7FFFF | (1<<19);
   rcv1a_tcb[4]  = *pCPSP1A = ((int) rcv1a_tcb  + 7) & 0x7FFFF | (1<<19);

   rcv0b_tcb[4] = *pCPSP0B = ((int) rcv0b_tcb + 7) & 0x7FFFF | (1<<19);
   rcv1b_tcb[4]  = *pCPSP1B = ((int) rcv1b_tcb  + 7) & 0x7FFFF | (1<<19);
  // asm("ssync;");
   break;
  case 2:
   // Enable chain pointer registers before enabling DMA
   rcv0a_f_tcb[4] = *pCPSP0A = ((int) rcv0a_f_tcb + 7) & 0x7FFFF | (1<<19);
   rcv1a_f_tcb[4]  = *pCPSP1A = ((int) rcv1a_f_tcb  + 7) & 0x7FFFF | (1<<19);

   rcv0b_f_tcb[4] = *pCPSP0B = ((int) rcv0b_f_tcb + 7) & 0x7FFFF | (1<<19);
   rcv1b_f_tcb[4]  = *pCPSP1B = ((int) rcv1b_f_tcb  + 7) & 0x7FFFF | (1<<19);
  // asm("ssync;");
   break; 
  case 3:
  
   break;
  default: break;
    }

*pSPCTL0 = ( SLEN13 | CKRE | SCHEN_A | SDEN_A | SCHEN_B | SDEN_B);
*pSPCTL1 = ( SLEN13 | CKRE | SCHEN_A | SDEN_A | SCHEN_B | SDEN_B);

// asm("ssync;");
Sample_Start();  //打开FPGA的帧产生信号
//wait for the completion of data transmission
delay(5000);

LIRPTL=sysreg_read(sysreg_LIRPTL);
IRPTL=sysreg_read(sysreg_IRPTL);

while((LIRPTL & 0x00000001==0x00000001)&&(IRPTL & 0x00008000==0x00008000))
{
  wait_count++;  
  if(wait_count>SAMPLE_DELAY) //表示缺少采样时钟
  {
   //Dialog_Box(18,1);
   wait_count=0;
  }  
sysreg_bit_clr(sysreg_LIRPTL,P6I);
sysreg_bit_clr(sysreg_IRPTL,P3I);           
}

Sample_Stop();  //关闭FPGA的帧产生信号
}

when tranmit completed,an interrupt accor,i check the P3I and P6I to assure that both sport cause an interrupt.

But,my 21489's sport can not receive appreciate data,so ,could you why this problem appear and how should i do to resolve it?

Regards,

Lina

Outcomes