AnsweredAssumed Answered

MCBSTM32C (STM32F107VC) ethernet driver issue

Question asked by desai.yash on Jun 24, 2013
Hey,,


I want to implement TCP/IP using no OS on MCBSTM32C (STM32F107VC). The driver ETH_STM32x.c file writen by KEIL uses RTX functions in it's receiving part. 
<i>Therefore i wrote my own function for receiving a frame, everything else is similar to the driver.
</i>
But it is not working. After a lot of checking,<b> i realised it gets stuck at a certain point(second if condition of loop). 
The issue is , the DMA OWN bit in the descriptor is never reset.
 why is this problem arising. </b>
Please Help !!!
my receiving function returns the packet length and it writes the data  from address:packet .
it returns 0 otherwise.


<pre> 
U16 receive_packet( U8 * packet)
{


U32 i,RxLen;
U32 *sp;
i = RxBufIndex;


if     (ETH->DMASR &DSR_RS ==0)                              // check if a packet has been received and buffered
{     
     return 0;
}


if((Rx_Desc[i].Stat & DMA_RX_OWN) != 0)
{
     return 0;
}
       
if( (Rx_Desc[i].Stat & DMA_RX_ES ==0)     &&     ((Rx_Desc[i].Stat & DMA_RX_SEG_MASK) == DMA_RX_SEG_MASK))
{     
     RxLen = ((Rx_Desc[i].Stat >> 16) & 0x3FFF) - 4;
     sp = (U32 *)(Rx_Desc[i].Addr & ~3);
     for (RxLen = (RxLen + 3) >> 2; RxLen; RxLen--) 
       {
         *packet++ = *sp++;
       }


}
else
{
     RxLen=0;
}
Rx_Desc[i].Stat = DMA_RX_OWN;      // Set Own bit of the Rx descriptor Status: gives the buffer back to ETHERNET DMA 


if (++i == NUM_RX_BUF) i = 0;  RxBufIndex = i;


if (ETH->DMASR & INT_RBUIE) 
{     ETH->DMASR   = INT_RBUIE;                       // Rx DMA suspended, resume DMA reception. 
     ETH->DMARPDR = 0;
}


ETH->DMASR = DSR_NIS | DSR_RS ;               // Clear the interrupt pending bits


return(RxLen);


}
</pre>

Outcomes