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




Loading

Queu Send from ISR...Doesn't !

Posted by groger57 on December 31, 2015

Hello: Actually 2 questions here:

1 - The Queue handle has to get from one source file/function to the source file for the ISR. Is the best way to do this through an extern declaration? in MAIN: QueueHandlet isrQueue; in ISR file: extern QueueHandlet isrQueue;

2 - The queue task for receive does not seem to be detecting the send update. Here's the declarations: void QueueRxFunction( void *pvParameters ); QueueHandlet isrQueue; TaskHandlet xQueueTask = NULL; define rxQueueRATE ( portMAXDELAY )

isrQueue = xQueueCreate( 1, sizeof(uint8t) ); xTaskCreate( QueueRxFunction, "rxDataQueue", 140, NULL, 2, (TaskHandlet)xQueueTask );

Function in MAIN: void QueueRxFunction( void *pvParameters ) { uint8t rxValue = 0; portBASETYPE xStatus;

for(;;)
{
    if( uxQueueMessagesWaiting( isrQueue ) != 0 )
    {
          //printf("Queue should be empty\n");
    }

    xStatus = xQueueReceive( isrQueue, &rxValue, rxQueue_RATE );        

    if( xStatus == pdPASS )
    {
        printf("Rcvd message from ISR %i\n", rxValue);
    }
}

}

Function in ISR: void TIM6DACIRQHandler(void) { long xHigherPriorityTaskWoken = pdFALSE;

if( TIM_GetITStatus(TIM6, TIM_IT_Update) ) 
{
.
.
.
   uint8_t flag = TRUE;
   xQueueSendFromISR(isrQueue, &flag, &xHigherPriorityTaskWoken);
   portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}

Thank you for any help on this....(hoping eveyone at the FreeRTOS Support forum has a safe and excellent 2016!)


Queu Send from ISR...Doesn't !

Posted by groger57 on December 31, 2015

Hi, I found one (large) silly error that I think I have fixed. The queue task:

void QueueRxFunction( void *pvParameters ) { uint8t rxValue = 0; BaseTypet xStatus; BaseType_t xTaskWokenByReceive = pdFALSE;

for(;;)
{
    if( uxQueueMessagesWaiting( isrQueue ) != 0 )
    {
          //printf("Queue should be empty\n");
    }

    xStatus = xQueueReceiveFromISR( isrQueue, (void*)&rxValue, &xTaskWokenByReceive );        

    if( xStatus == pdPASS )
    {
        printf("Rcvd message from ISR %i\n", rxValue);
    }
}

}

However, it's not yet functioning - still never reaches the "xQueueReceiveFromISR" line.

Thanks, Gary


Queu Send from ISR...Doesn't !

Posted by groger57 on December 31, 2015

Couple of other things that might be of interest:

The interrupt being set up and used is a timer driven interrupt to trigger an ADC read (STM32)

I have #define configLIBRARYKERNELINTERRUPTPRIORITY 15 NVICInitStructure.NVICIRQChannelPreemptionPriority = configLIBRARYKERNELINTERRUPTPRIORITY

In main I call NVICPriorityGroupConfig( NVICPriorityGroup_4 ); before the scheduler launch.

The code gets to line 602 in port.c (FreeRTOS 8.2.0) configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );

And stays there. Why would it do this when the interrupt is set up for a priority of 15, which is lower than the maximum of 0 ?

Thanks...


Queu Send from ISR...Doesn't !

Posted by richard_damon on December 31, 2015

The FromISR functions should only be used IN an ISR, and those shouldn't have for(;;) loops.

Tasks getting data from a queue that was put in within an ISR don't use FromISR routines, but the normal xQueueReceive function.


Queu Send from ISR...Doesn't !

Posted by groger57 on December 31, 2015

In my ISR I use nothing but: xQueueSendFromISR(isrQueue, &flag, &xHigherPriorityTaskWoken); portENDSWITCHINGISR( xHigherPriorityTaskWoken );

As you suggested, I changed my code to use a regular receive queue and it's still stopped at 602 in port.c

something I don't understand is at the beginning of my program I print out the value of configMAXSYSCALLINTERRUPT_PRIORITY and it prints out (decimal) 80

Does that mean the priority of my timer interrupt must be at least 81 for the ISR to function correctly with the queue?


Queu Send from ISR...Doesn't !

Posted by groger57 on December 31, 2015

Also, the value of ulCurrentInterrupt in port .c is 0, which makes no sense! In the Timer interrupt setup, I have this: / #define configLIBRARYKERNELINTERRUPTPRIORITY (14) NVICInitStructure.NVICIRQChannel = TIM6DACIRQn; NVICInitStructure.NVICIRQChannelPreemptionPriority = configLIBRARYKERNELINTERRUPTPRIORITY; NVICInitStructure.NVICIRQChannelSubPriority = 0; NVICInitStructure.NVICIRQChannelCmd = ENABLE; NVICInit(&NVICInitStructure);

No matter what the #define is, the value of ulCurrentInterrupt is always 0.

What could be wrong?


Queu Send from ISR...Doesn't !

Posted by rtel on December 31, 2015

I can have a proper look at this tomorrow (it's nearly 11pm here) but first off, do you have configASSERT() defined? Assuming you are using a recent version of FreeRTOS that will catch most interrupt misconfiguration issues.


Queu Send from ISR...Doesn't !

Posted by groger57 on December 31, 2015

yes, I have it defined to: define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }

ok, thanks, I appreciate your assistance when you can get back to me. hope the rest of your evening is uninterrupted (no pun intended) Gary


Queu Send from ISR...Doesn't !

Posted by rtel on January 1, 2016

1 - The Queue handle has to get from one source file/function to the source file for the ISR. Is the best way to do this through an extern declaration? in MAIN: QueueHandlet isrQueue; in ISR file: extern QueueHandlet isrQueue;

That work work fine.

The code gets to line 602 in port.c (FreeRTOS 8.2.0) configASSERT( ucCurrentPriority >= ucMaxSysCallPriority ); And stays there. Why would it do this when the interrupt is set up for a priority of 15, which is lower than the maximum of 0 ?

In which case the interrupt priority is not valid, and you are never writing to the queue.

something I don't understand is at the beginning of my program I print out the value of configMAXSYSCALLINTERRUPT_PRIORITY and it prints out (decimal) 80

80 is the priority shifted up into the most significant bits of the byte. See the Cortex-M hardware documentation and http://www.freertos.org/RTOS-Cortex-M3-M4.html (that link is at the top of the "my application does not run, what could be wrong) FAQ page, which is always the first place to start).

Does that mean the priority of my timer interrupt must be at least 81 for the ISR to function correctly with the queue?

That would depend on the library you were using the set the interrupt priority. If you are using the CMSIS libraries, then no, the priority you set would have to be the unshifted value. See the link above.

Also, the value of ulCurrentInterrupt in port .c is 0, which makes no sense!

I think index 0 is the stack start address - that doesn't seem to make sense.

In any case, I think the reason your queue is not receiving is because, do to the assert() catching the invalid interrupt priority, nothing is actually being sent to it.

Regards.


Queu Send from ISR...Doesn't !

Posted by groger57 on January 1, 2016

Hi RTE: Now functioning! Problem - I took the suggestion on your page literally with respect to placing this "before" the scheduler launch: NVICPriorityGroupConfig( NVICPriorityGroup_4 );

After placing it in the TImer 6 configuration, and before the call to
NVICInit(&NVICInitStructure);

Moving it there fixed it....the details will get you every time... Thanks for taking the time to look at this!


[ 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