TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS570LC4357: 使用LWIP协议栈 emac功能收发数据,发送数据始终正常,接收数据在接收一段时间后不再进入中断接收

Part Number:TMS570LC4357Other Parts Discussed in Thread:HALCOGEN

你好,我在使用TMS570lc457芯片通过emac模块收发数据。在测试的过程中发现在初始化后一段时间内收发都正常,但是在通道0的接收缓存区计数寄存器计数到0x000000CD后再发送数据不再进入接收中断。(我使用通道0来接收数据并使能了中断)同时发送功能始终正常。您能帮我分析一下为什么emac模块不再中断接收吗?

如图:

我的接收中断函数如下:

#pragma INTERRUPT(EMACCore0RxIsr, IRQ)
uint32 countrxisr = 0;
void EMACCore0RxIsr(void)
{char* tmpptr;uint32_tCurFinishCP=HWREG(EMAC_BASE + EMAC_RXCP(0));/*当前已经完成数据接收的缓冲区指针*/EMACDesc_t*RXCP=EMAC_SL_CurRXCP;/*当前处理的接收缓冲区指针*/MACFrame_t*MacFramePtr=NULL;ECTRL_C0RXEN=0U;/*在处理数据之前先禁用中断*/HWREG(EMAC_BASE + EMAC_RXCP(0))=CurFinishCP;/*确认当前已经处理过的CP*/HWREG(EMAC_BASE + EMAC_MACEOIVECTOR)  =1U;/*确认接收中断处理完毕*/

	if ( countrxisr == 0U )//first frame
	{
		HWREG(EMAC_BASE + EMAC_RXHDP(0))	 =	 CurFinishCP;
		EMAC_SL_CurRXCP = (EMACDesc_t*)CurFinishCP;
		RXCP = (EMACDesc_t*)CurFinishCP;
		countrxisr = 1;
	}/*当前接收队列已经到达队尾,重新将接收缓存区指针指向首位置*/
	else if (HWREG(EMAC_BASE + EMAC_RXHDP(0)) == 0U)
	{HWREG(EMAC_BASE + EMAC_RXHDP(0))	 =	 CurFinishCP;
		EMAC_SL_CurRXCP = (EMACDesc_t*)CurFinishCP;
		RXCP = (EMACDesc_t*)CurFinishCP;}/*当前接收队列已经到达队尾,重新将接收缓存区指针指向首位置*/
	else
	{
		EMAC_SL_CurRXCP 	=	((EMACDesc_t*)(CurFinishCP)) + 1U;
		EMAC_SL_CurRXCP = (EMACDesc_t*)((char*)EMAC_SL_CurRXCP + 4);  /* appear 4 byte more data than 3137,so add this offsets */
	}/*更新最后一次处理的CP*/


	while ( (uint32_t)(RXCP) <= CurFinishCP ){/*1============================================================================1*//*仅处理单包数据包,对于拆分的数据包直接丢弃*/if ( (RXCP->EOP == 1U) && (RXCP->SOP == 1U) ){MacFramePtr=(MACFrame_t*)EMACSwizzleData((uint32)RXCP->BufferPtr);/*MAC层数据帧信息指针*/switch ( MacFramePtr->FrameType ){case IPV4_DT_ARP_FRAME :{if ( EMACSwizzleData16(RXCP->Length) <= sizeof EMAC_SL_RXBuffer.Data[0].Buffer  ){memcpy(EMAC_SL_RXBuffer.Data[EMAC_SL_RXBuffer.Tail.Cnt].Buffer, EMACSwizzleData(RXCP->BufferPtr),EMACSwizzleData16(RXCP->Length));EMAC_SL_RXBuffer.Tail.Cnt++;}break;}/*接收到ARP数据帧,先将数据存放到接收缓冲区中,稍候再处理*/case IPV4_DT_IP_FRAME :{IPHeader_t* IPHeaderPtr=(IPHeader_t*)(EMACSwizzleData(RXCP->BufferPtr) + 14U);/*当前数据包的IP头信息*/if ( (IPHeaderPtr->SrcIP == REMOTE_IP_ADDR) && ((IPHeaderPtr->DstIP == LOCAL_IP_ADDR)||(IPHeaderPtr->DstIP == BROADCAST_IP_ADDR))&& (IPHeaderPtr->Protol == IP_PROTO_UDP)  ){EMAC_SL_IsRXRemoteUDPData=TRUE;if ( EMACSwizzleData16(RXCP->Length) <= sizeof EMAC_SL_RXBuffer.Data[0].Buffer  ){memcpy(EMAC_SL_RXBuffer.Data[EMAC_SL_RXBuffer.Tail.Cnt].Buffer, EMACSwizzleData(RXCP->BufferPtr), EMACSwizzleData16(RXCP->Length));EMAC_SL_RXBuffer.Tail.Cnt++;}}/*接收IP地址与本地IP地址匹配,且数据类型为UDP,则处理数据帧*/break;}/*接收到IP数据帧,先将数据存放到接收缓冲区中,稍候再处理*/default :{break;}}}/*1============================================================================1*/RXCP->Length=RX_BUFFER_SIZE;RXCP->OWNER=1U;RXCP++;
		RXCP = (char*)RXCP + 4; /* here don't know why data in buffer is 32* 5 byte while 3137 is 32 *4 byte, perhaps because of LWIP protocol */}ECTRL_C0RXEN=1U;/*重新激活中断*/


}

我的LWIP的初始化函数是这样写的:

void EMAC_LwIP_init (uint8_t * macAddress)
{
unsigned int ipAddr;
uint32 emacCtrlBase = 0xFCF78800U;
uint32 emacBase = 0xFCF78000U;

EMACInit(emacCtrlBase,emacBase);
IntMasterIRQEnable();//中断

/* for static IP address. Change address as required, and uncomment the previous statement. */ uint8 ip_addr[4] = { 172, 22, 1, 1 };
uint8 netmask[4] = { 255, 255, 255, 0 };
uint8 gateway[4] = { 172, 22, 1, 1 }; //网关 路由器端口
ipAddr = lwIPInit(0, macAddress,
*((uint32_t *)ip_addr),
*((uint32_t *)netmask),
*((uint32_t *)gateway),
IPADDR_USE_STATIC );

Mu Haitao:

我自己觉得可能是中断函数队尾处理那里没有写对,您能提供一个正确的R0通道EMAC接收中断的函数让我参考吗

,

Ben Qin:

你好,你参考过这个例程吗:

C:\ti\Hercules\HALCoGen\v04.07.01\examples\TMS570LC43x

,

Mu Haitao:

你好,HAL库里的例程并没有使用LWIP协议栈,是一个自环的emac收发。我的emacint函数参考了该库文件,并没有解决我遇到的问题

,

Ben Qin:

查看下这个文件:

www.ti.com/…/spna239.pdf

赞(0)
未经允许不得转载:TI中文支持网 » TMS570LC4357: 使用LWIP协议栈 emac功能收发数据,发送数据始终正常,接收数据在接收一段时间后不再进入中断接收
分享到: 更多 (0)

© 2024 TI中文支持网   网站地图 鲁ICP备2022002796号-1