[En-Nut-Discussion] Crashing usart driver of the Ethernut3/AT91 (interrupt problem)

Julian Dohle JD at REMBE.de
Wed Feb 21 13:51:35 CET 2007


Hello,

I am currently involved in a project which uses the serial port of the Ethernut3 board. I am faced with some serious problems regarding the usart driver in  Nut/OS (4.2.1). We are sending 4 bytes out, and 4 bytes are received then. (see detailed info below). After some time the Ethernut stops sending out Data (usually after 1 to 30 seconds). It seems that this is caused by missing interrupts. I have written a workarround, but the question is why the interrupts stopped.

The program below works fine as long as there are no characaters send back from the PC.

Could anybody confirm this behavior? 

Viele Grüße / With best regards

Julian Dohle



Source Code:
#include <cfg/os.h>
#include <io.h>
#include <dev/board.h>
#include <stdio.h>
#include <sys/timer.h>
#include <dev/usartat91.h>

int main(void)
{
	/* Crashing USART Driver of the Ethernut 3 under high load
	 * Scenario: Ethernut connected to a PC via Uart0 with 57600Baud, no parity, 1 Stop, no handshake
	 * 			 Ethernut sends 4 Bytes and the PC answered with 4 bytes
	 * 			 The whole serial communication is monitored with "Free Serial Port Monitor"
	 * 
	 * Suddenly after approx. 1-30 sec. the Ethernut stops sending.
	 * As far as i figured out, no Interrupts are triggered then.
	 * UART_OVERRUNERROR in the UART Status indicates that the US_OVRE bit is set
	 *
	 * The method to clear the Error via _ioctl and UART_SETSTATUS fails because 
	 * no interrupts are triggered and therefore the variable rx_errors could not be
	 * updated.
	 * 
	 * I created a workaround which completly disables all USART Interrupts 
	 * and then enable them again, if clearing the the error with UART_SETStatus fails
	 * in file USARTAT91.c in function At91UsartSetStatus
	 * 
	 * This is only a workaround, the question is why the USART interrupts were stopped
	 * or disabled suddenly.
	 * 
	 * I have written a simple application on the PC side und c# which simply sends
	 * out 4 bytes if 4 bytes are received. I could upload it to some webspace if required
	 */
    FILE *uart;
  	NutRegisterDevice(&DEV_UART, 0, 0);
    uart = fopen(DEV_UART_NAME, "r+");
    //Set Speed
    u_long baud= 57600;
    _ioctl(_fileno(uart), UART_SETSPEED, &baud);
    NutSleep(200);
    long timeout = 40;
    u_long status=0;
    //Timeouts
    _ioctl(_fileno(uart),UART_SETWRITETIMEOUT,&timeout);
    //_ioctl(_fileno(uart),UART_SETREADTIMEOUT,&timeout);
    char bytes[]={0x4A,0x01,0x01,0x01};
    for (;;) 
    {
     	_write(_fileno(uart), bytes, 4);
 		_ioctl(_fileno(uart),UART_GETSTATUS,&status);
 		
		//Uncomment this for workarroundpatch
 		/*if(status&UART_OVERRUNERROR)
 		{      
            status=UART_ERRORS;//|UART_TXBUFFEREMPTY;
 			_ioctl(_fileno(uart),UART_SETSTATUS,&status);
 			
 		}*/
 		NutSleep(2);	 
 	 }
}
 
/* Workarround:
 * \nut\arch\arm\dev\Usartat91.c in function At91UsartSetStatus
 * Line 871:
    if ((At91UsartGetStatus() & ~UART_ERRORS) != flags) {
	    // Disable USART interrupts.
	    NutEnterCritical();
	    outr(USARTn_BASE + US_IDR_OFF, 0xFFFFFFFF);
	    // Enable UART receiver and transmitter interrupts.
	    outr(USARTn_BASE + US_IER_OFF, US_RXRDY | US_TXRDY);
	    NutIrqEnable(&SIG_UART);
	    NutExitCritical();
*/
 
 
*******************************************************************************************
REMBE(R) GmbH SAFETY + CONTROL
Postfach 1540
59918 Brilon / Germany
 
Managing Director/Geschäftsführer: Stefan Penno, MBP BA IBA
Court register/Amtsgericht: Arnsberg - HRB 3577
Tax-No.: 309/5712/0348
Vat-ID.: DE124281906
 
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed.  If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify REMBE(R) GmbH SAFETY + CONTROL and its affiliated organisations within the REMBE ALLIANCE immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. 
*******************************************************************************************



More information about the En-Nut-Discussion mailing list