# Loosing interrupts on queue and semaphore  

**URL:** <https://forums.freertos.org/t/loosing-interrupts-on-queue-and-semaphore/3100>\
**Category:** Kernel\
**Created:** [November 2, 2005, 11:39am UTC](https://forums.freertos.org/t/loosing-interrupts-on-queue-and-semaphore/3100 "2005-11-02T11:39:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 2, 2005, 11:39am UTC](https://forums.freertos.org/t/loosing-interrupts-on-queue-and-semaphore/3100/1 "2005-11-02T11:39:07Z")

</div>

**nobody** wrote on [Wednesday, November 02, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/8ace83fc/#1e1e):

Hello,  
i am working&nbsp; at a CAN application which reads from multiple CAN interfaces by interrupt, and releases a semaphore (…i also tried a queue) to notify a task. I am loosing up to 30% of my CAN-interrupts.  
When i remove the queue/semaphore functions everything seems to be ok.

Port : ARM7  
Hardware LPC2294&nbsp;&nbsp;

Any Idea ???

&nbsp;  
Thanx,

Peter

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 2, 2005, 2:08pm UTC](https://forums.freertos.org/t/loosing-interrupts-on-queue-and-semaphore/3100/2 "2005-11-02T14:08:54Z")

</div>

**nobody** wrote on [Wednesday, November 02, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/8ace83fc/#1e1e/3a45):

How fast is the LPC running?&nbsp; (MHz, waitstates, etc), and what is the baud of the CAN?

Are you able to post your ISR code with and without the queues?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 3, 2005, 10:04am UTC](https://forums.freertos.org/t/loosing-interrupts-on-queue-and-semaphore/3100/3 "2005-11-03T10:04:21Z")

</div>

**nobody** wrote on [Thursday, November 03, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/8ace83fc/#1e1e/5c2f):

Hello,

the LPC is running with 48 MHz, (… i also tried 60MHz). The behavior is the same at internal an external RAM.

CAN-Baudrate is 500Kbps

The CAN-ID’s are sent in 1 ms 25% Bus-Load,  
10 ms (3% Busload) and 100ms (0,3 % Busload)  
There are no bursts at the Bus (checked with Vector-CANalyzer)

The problems occure at 1 and 10 ms&nbsp;&nbsp;&nbsp;&nbsp;

static portCHAR can\_isr(unsigned int can\_nr)  
{  
//&nbsp;&nbsp;&nbsp; portBASE\_TYPE xTaskWoken = pdFALSE;  
/\* put data it inside CAN-Ringbuffer \*/  
&nbsp;&nbsp;&nbsp; if(LPC\_CAN[can\_nr]-\>ctrl.gsr.dw & 0x1) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; can\_buffer-\>recv\_ringb[can\_nr].entries[can\_buffer-\>recv\_ringb[can\_nr].w\_ptr].can.id.dw =  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPC\_CAN[can\_nr]-\>rcv.id.dw;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; can\_buffer-\>recv\_ringb[can\_nr].entries[can\_buffer-\>recv\_ringb[can\_nr].w\_ptr].can.data[0].dw =  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPC\_CAN[can\_nr]-\>rcv.data[0].dw;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; can\_buffer-\>recv\_ringb[can\_nr].entries[can\_buffer-\>recv\_ringb[can\_nr].w\_ptr].can.data[1].dw =  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPC\_CAN[can\_nr]-\>rcv.data[1].dw;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; can\_buffer-\>recv\_ringb[can\_nr].entries[can\_buffer-\>recv\_ringb[can\_nr].w\_ptr].ts =  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; T0\_TC;  
&nbsp;&nbsp;&nbsp; /\* release CAN-message \*/  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPC\_CAN[can\_nr]-\>ctrl.cmr.b[0] = 0x4;  
&nbsp;&nbsp;&nbsp; /\*Ring buffer movement\*/&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; can\_buffer-\>recv\_ringb[can\_nr].w\_ptr ++;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(can\_buffer-\>recv\_ringb[can\_nr].w\_ptr \>= CAN\_RING\_SIZE) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; can\_buffer-\>recv\_ringb[can\_nr].w\_ptr = 0;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; can\_rx\_cnt[can\_nr]++;  
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xTaskWoken = xSemaphoreGiveFromISR(CanIrqSem, xTaskWoken );  
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xTaskWoken = xQueueSendFromISR(CanIrqQ,&can\_nr, xTaskWoken);  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; if(LPC\_CAN[can\_nr]-\>ctrl.gsr.dw & 0x2) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; can\_buffer-\>recv\_ringb[can\_nr].ovrcnt++;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LPC\_CAN[can\_nr]-\>ctrl.cmr.b[0] =&nbsp; 0x8;  
&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp; return pdFALSE;  
//&nbsp;&nbsp;&nbsp; return xTaskWoken;  
}

void can0\_rx\_isr(void)  
{  
&nbsp;&nbsp;&nbsp; portENTER\_SWITCHING\_ISR();  
&nbsp;&nbsp;&nbsp; portBASE\_TYPE xTaskWoken = pdFALSE;  
&nbsp;&nbsp;&nbsp; xTaskWoken = can\_isr(0);  
&nbsp;&nbsp;&nbsp; /\* acknowledge Interrupt \*/&nbsp;&nbsp;&nbsp;  
//&nbsp;&nbsp;&nbsp; VICVectAddr = 0x0L;  
&nbsp;&nbsp;&nbsp; VICVectAddr = 0xFFFFFFFFL;  
&nbsp;&nbsp;&nbsp; /\*return from ISR by switching or recovering \*/  
&nbsp;&nbsp;&nbsp; portEXIT\_SWITCHING\_ISR(xTaskWoken);  
}

Thankx,

Peter
