This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129ENCPDT: While loop hangs in TCP communication

Part Number: TM4C129ENCPDT

Hi,

i am out of office for the last one month.. i am back to my project . i did  what bob said and the value of xPSR register is 0x610C0038.

Thanks

GPM

  • Hi George,

    The 0x38 in the last 8 bits of the xPSR shows that you are in the EMAC interrupt service routine. (0x38 = 56) While in the EMAC interrupt service routine, interrupts are disabled. UART4 cannot generate an interrupt with interrupts disabled. In the callback routine you should just set a flag and then return. In the main routine, when you see the flag set, then start gathering your data from the UART. 

  • Hi Bob,

    i did what you said in last post. i am using interrupt based uart communication. so i did not get data as desired. when i using polling method for UART communication, i got desired data.

    Regards

    George

  • Hi George,

    You rejected my previous answer and I am not sure why. I assume you need more explanation about how the interrupts work. If this does not help. please expand on what further clarification you require.

    By default, when the CPU is servicing one interrupt routine, all other interrupts are blocked. The EMAC callback function is part of the EMAC interrupt routine. When you added code to the EMAC callback function which is waiting for a flag set by the UART4 interrupt routine, that flag will not be set because the UART4 interrupt routine cannot be executed. You end up waiting in the while loop forever. (This is the issue you described.) Using polling for UART4 will work because it does not depend on the UART4 interrupt.

    Now this part is my opinion, but it is the opinion of a person with over 40 years of experience in embedded systems and this opinion is widely held. It is generally not a good idea to spend time within an interrupt routine polling for  something like UART characters. That means interrupts are disabled for a relatively long time. Interrupts should be used for external events that require immediate attention. If the interrupt service routine of one device takes a long time, other devices cannot be serviced. That is why I recommended that in the EMAC callback function you simply set a flag (a volatile static variable) that says the TCP frame was received. Then let the callback function complete and the EMAC interrupt service routine finish. Now in the main code you can see the flag is set and collect the UART data (which also uses interrupts and flags) and complete the response.

  • Hi Bob,

    Thanks for your detailed explanation about EMAC and other interrupts. i put flag in my callback function and waiting in the main code for uart data using this flag. I changed my software architecture with reduced number of interrupts. All are working fine.  Thanks for your Detailed reply.

    Thanks  & Regards

    George