AnsweredAssumed Answered

The problem with SPORT simulating UART Rx

Question asked by Joshua on Sep 11, 2010
Latest reply on Sep 27, 2010 by Joshua

  Now i am using SPORT1 as UART on ADSP-BF561 EVB.

 

  The SPORT TX with DMA2_3 & interrupt mode is OK as that is said in the EE-191.

 

  But the SPORT Rx is more boring, I do not know how could I make it.

 

  Here is my main codes:

 

  /* Init SPORT   */

  void InitSPORT(void)

{

     .......

    *pSPORT1_RCR1   = 0;

    *pSPORT1_RCR2   = 0;

 

    *pSPORT1_RFSDIV    = 0x0020;

    *pSPORT1_RCLKDIV  = 0x00BC;   //  390MHz/(3*(2*115k2)) ,following EE191.

 

    *pSPORT1_RCR2       = 0x001F;

    *pSPORT1_RCR1       = 0x0413;

    ssync();    

 

}

 

/* ReadSport1   */

HESULT ReadSport1(UINT32 TaskID, void *buf, UINT16 length, DEV_WORK_MODE sync_or_overlapped, Interrupt func)

{

     UINT16  temp;

     UINT8   *Rx_buf;

     UINT8   *ptr;

     UINT32 *buffer;

 

     Rx_buf  = (UINT8 *)buf;

     buffer    = (UINT32 *)malloc(length * sizeof(UINT32));

 

     if(DEV_Sync == sync_or_overlapped)

     {

          ;

     }

     else

     {

          *pSPORT1_RCR1   &= ~RSPEN;       //Disable SPORT1

          ssync();

 

          *pDMA2_2_CONFIG           = 0;

          *pDMA2_2_START_ADDR  = buffer;

          *pDMA2_2_X_COUNT        = length;

          *pDMA2_2_CONFIG          = 0x008A;     // Interrupt mode

          ssync();

 

          *pDMA2_2_CONFIG         |= DMAED;      // enable DMA

          ssync();

 

          *SPORT1_RCR1              |= RSPEN;                  // enable SPORT

          ssync();

     }

     Unpack_Data(buffer, Rx_buf, length);                        // getting UART 8bit data.

 

     free(buffer);

     return 0;

 

}

 

 

/*  Unpack_Data   */

//  UINT32 *buf_in   => The data buffer received from SPORT1(Following the UART format)

//                               The wide of data is 29bits.(By EE191)

//  UNIT8   *buf_out => The REAL data needed.

//  UINT16  length

 

void Unpack_Data(UINT32 *buf_in, UINT8 *buf_out, UINT16 length)

{

     UINT32  *ptr1;

     UINT8   *ptr2;

     UINT8        i;

     UINT32 temp;

     UINT8  data = 0;

 

     for(ptr1 = buf_in, ptr2 = buf_out; ptr1 < buf_in + length; ptr1++; ptr2++)

     {

          for(i=0; i<8; i++)

          {

               temp = 0x00000008 << (i + 1);     // Getting valid data

               temp = *ptr1 & temp;                   // Bit(3,6,9,...,24) wil be sampled.

               temp >>=(i + 1) * 2 + 1;

               data     |= (UINT8)temp;

          }

          *ptr2          = data;

     }

 

}

 

Some doubts is here.

1) Is the function of Unpack_Data OK? If not, How can l DO it ? Please in C,NOT in assemble.

 

2) How could I make the the SPORT_RXIsr ?

Outcomes