Queu Send from ISR…Doesn’t !

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 ); QueueHandle_t isrQueue; TaskHandle_t xQueueTask = NULL; define rxQueue_RATE ( portMAX_DELAY ) isrQueue = xQueueCreate( 1, sizeof(uint8t) ); xTaskCreate( QueueRxFunction, “rxDataQueue”, 140, NULL, 2, (TaskHandlet)xQueueTask ); Function in MAIN: void QueueRxFunction( void *pvParameters ) { uint8_t rxValue = 0; portBASE_TYPE xStatus;
for(;;)
{
    if( uxQueueMessagesWaiting( isrQueue ) != 0 )
    {
          //printf("Queue should be emptyn");
    }

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

    if( xStatus == pdPASS )
    {
        printf("Rcvd message from ISR %in", 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 !

Hi, I found one (large) silly error that I think I have fixed. The queue task: void QueueRxFunction( void *pvParameters ) { uint8_t rxValue = 0; BaseType_t xStatus; BaseType_t xTaskWokenByReceive = pdFALSE;
for(;;)
{
    if( uxQueueMessagesWaiting( isrQueue ) != 0 )
    {
          //printf("Queue should be emptyn");
    }

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

    if( xStatus == pdPASS )
    {
        printf("Rcvd message from ISR %in", rxValue);
    }
}
} However, it’s not yet functioning – still never reaches the “xQueueReceiveFromISR” line. Thanks, Gary

Queu Send from ISR…Doesn’t !

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 !

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 !

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 !

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 !

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 !

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 !

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 !

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!