Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

CAN DOIE

2005-09-15 by albin_martinsson

Hello

Im using the CAN-interface in my application. 
My routine for CAN is interrupt-driven, here is an example of my ISR-
code:

I often get Data Overrun - error on the receive channel.
Anyone who has had the same problem? 
I also use the freeRTOS port for the LPC2129. 

B.R

Fredrik Martinsson, Sweden

void ISR_CANRX (void)
{
   tU32 *cBufdst;
   tU32 Buf[3];

   while (C1GSR&0x01) {
      // Save registers temp.
      Buf[0] = C1RID;
      Buf[1] = C1RDA;
      Buf[2] = C1RDB;
      C1CMR = 0x04; 					
      // release receive buffer
		
		
	if (++can_rxbufin>=CAN_QUEUESIZE)can_rxbufin = 0;
	cBufdst = &can_rxbuf[can_rxbufin].CmRID;
			
	if (can_rxbufin == can_rxbufout) {
	   if (++can_rxbufout>=CAN_QUEUESIZE)can_rxbufout = 0;
	}
	if (++can_rxbufsize>CAN_QUEUESIZE)
can_rxbufsize=CAN_QUEUESIZE;
			
	*cBufdst = Buf[0];
	cBufdst++;
	*cBufdst = Buf[1];
	cBufdst++;
	*cBufdst = Buf[2];
			
	// Give semaphore to start comTask
	xSemaphoreGiveFromISR( comSem, pdFALSE );
      }
	
   VICVectAddr = 0xFFFFFFFFL; 				
   // acknowledge Interrupt
}

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.