Forum Discussion
Altera_Forum
Honored Contributor
15 years agoHi Daixiwen,
I agree it could be a cache problem. How do I flush the cache as you suggest? Here you find my code. As you can see, I tried to insert a couple of flush functions I found around (now commented), but they had no effect. Maybe this is not the correct location to place them. Do I need to place them inside pkt_send function?void ecat_send(char*data, int len)
{
PACKET outpkt;
/*
OS_ENTER_CRITICAL();
alt_dcache_flush_all ();
alt_icache_flush_all ();
OS_EXIT_CRITICAL();
*/
LOCK_NET_RESOURCE(FREEQ_RESID);
outpkt = pk_alloc(len+20);
UNLOCK_NET_RESOURCE(FREEQ_RESID);
if (!outpkt) {
printf("Error: pk_alloc() failed");
dtrap();
return;
}
outpkt->net = ecat_net;
memcpy(outpkt->nb_buff + ETHHDR_BIAS, data, len+ETHHDR_SIZE);
outpkt->nb_plen = ETHHDR_BIAS + len;
/* if a packet oriented send exists, use it: */
if (outpkt->net->pkt_send) {
outpkt->nb_prot = outpkt->nb_buff;
outpkt->net->pkt_send(outpkt);
}
else {
outpkt->net->raw_send(ecat_net, outpkt->nb_buff, outpkt->nb_plen);
LOCK_NET_RESOURCE(FREEQ_RESID);
pk_free(outpkt);
UNLOCK_NET_RESOURCE(FREEQ_RESID);
}
}
Regards