This is a bit of a strange one and it has taken me a while to debug things this far. (I'm totally new to Coldfire)
I've been using the demos from the AN3470SW app note to create an application that will talk to some of our existing equipment via serial and pass it along to a PC via ethernet, so a basic serial to ethernet converter. To get this working properly I had to modify the example slightly as well as the size of some of the TCP buffers to get optimal through put for our application.
I then added the HTTP server example to the code so I could work on a way of configuring the device.
This is when things went wrong. If I try to stream serial data through the device the RTOS crashes due to a stack gaurd word on the "Main" task being overridden.
I set a write watchpoint on the guardword and it stops in _tk_switch
_tk_switch:
move.w #0x2700,SR /* disable ints */
move.l 4(A7),D0 /* save passed tk pointer in D0 */
move.l D2,-(A7) /* push the non-volitile gp registers */
move.l D3,-(A7)
move.l D4,-(A7)
move.l D5,-(A7)
move.l D6,-(A7)
move.l D7,-(A7)
move.l A1,-(A7) //Stops here
The call stack shows that irq_handler is being called continuously and it is trying to print something to the console. I never actually see this output so I assume that the UART is not being processed because so much time is being spent in the IRQ.
I removed the printf statement to see what would happen and tried again. This time the application didn't crash, however our PC app stopped receiving data completely. If I stopped execution of the coldfire it was nearly always in the interrupt handler.
I then decided to put a break point in the interrupt handler to see when it was being called. If I run the application but don't make a TCP connection to it then the interrupt handler never gets called, however as soon as I make a connection the interrupt handler starts being called.
The interrupt handler always gets called for the first time when the main program is in a memmove operation which is called from "arprcv"
struct arp_hdr * arphdr;
struct arptabent * tp;
arphdr = (struct arp_hdr *)(pkt->nb_buff + ETHHDR_SIZE);
{
struct arp_wire * arwp = (struct arp_wire *)arphdr;
MEMMOVE(&arphdr->ar_tpa, &arwp->data[AR_TPA], 4); //Could potentially be this line
MEMMOVE(arphdr->ar_tha, &arwp->data[AR_THA], 6); //Debugger shows it has stopped here
MEMMOVE(&arphdr->ar_spa, &arwp->data[AR_SPA], 4);
MEMMOVE(arphdr->ar_sha, &arwp->data[AR_SHA], 6);
}
The memory addresses of the variables being used in memmove always seem to be the same as well.
The interesting thing is the "Value" (in debugger) of the dest and src pointer are the same.
Is something going wrong in "arprcv" that is causing a problem with the memmove that could then trigger an interrupt?
Is there any code I could put in the interrupt to try and find out the source of it?
Has anyone else had the same kind of problem?
Thanks for your time
Darren