Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


Semaphore and SPI interuppt

Posted by *anonymous on April 11, 2011


I am using LM3SXXXX MCU. I used SPI to receive data.  I set ISR to check receive data interrupt. When interrupt occur , it call my read data task.

I defined semaphore in main like

/* Create the semaphore used to wake the Read Data task from the SPI
ISR. */
vSemaphoreCreateBinary( xSPISemaphore );
xSemaphoreTake( xSPISemaphore, 0 );

-------------------ISR code ------------------------
void vSSI_ISR(void)
unsigned portLONG ulStatus;
ulStatus = SSIIntStatus( SSI_BASE, pdTRUE );
SSIIntClear( SSI_BASE, ulStatus );

if( ulStatus & SSI_RXTO )

if( xSemaphoreGiveFromISR( xSPISemaphore, pdFALSE ) )


My read data task

for( ;; )
/* Wait for a SSI RX interrupt to wake this task. */
while( xSemaphoreTake( xSPISemaphore, portMAX_DELAY ) != pdPASS );

  and then read code algorithm……


When i start first, it work fine for single time execution .But second time when interrupt occur …But next time my  task is not block on Semaphore.,it should block . What is ur suggestion ?

Semaphore and SPI interuppt

Posted by *anonymous on April 11, 2011

Some more inforamtion , when first time Interrupt come it work s perfect but when second time interrrupt come , In ISR routine ( xSemaphoreGiveFromISR( xSPISemaphore, pdFALSE ) )  , return errQUEUE_FULL instead of pdPass…..

Semaphore and SPI interuppt

Posted by *anonymous on April 11, 2011

By Richard barry"Yes - semaphores are built on top of queues, so when you get the errQUEUE_FULL return value it means the semaphore cannot be given because it is already there. For example, if it is a binary semaphore, you can take the semaphore successfully, then give it successfully once. Once it is given the semaphore is effectively 'full'. If you attempt to give it again without first taking it again you will get this error code returned. "

I also tried to take semaphore back by xSemaphoreTake( xSPISemaphore, 0 );
at the end of the of task which ISR calling.Still same problem….

Semaphore and SPI interuppt

Posted by edwards3 on April 11, 2011

Are you sure the interrupt is being cleared properly and not just continuously executing?
Have you stepped through the code after the first successful xSemaphoreTake() to check the rest of the code is working as you think?
Consider using a counting semaphore instead, in case interrupts are coming in too quickly for the binary use.

Semaphore and SPI interuppt

Posted by *anonymous on April 11, 2011

Yes interrupt occur second time, i wrote a problem ,
xSemaphoreGiveFromISR( xSPISemaphore, pdFALSE ) )  , return errQUEUE_FULL instead of pdPass…..

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists