Only one of wwo queues working on Tiva TM4c123GXL

jordied wrote on Friday, March 27, 2015:

I have a task which is monitoring the status of two push buttons. Called SwitchTask:

        while(1) {
		//
		// Poll the debounced state of the buttons.
		//
		ui8CurButtonState = ButtonsPoll(0, 0);
		//
		// Check if previous debounced state is equal to the current state.
		//
		if(ui8CurButtonState != ui8PrevButtonState)
			{
				ui8PrevButtonState = ui8CurButtonState;

				//
				// Check to make sure the change in state is due to button press
				// and not due to button release.
				//
				if((ui8CurButtonState & ALL_BUTTONS) != 0)
					{
						if((ui8CurButtonState & ALL_BUTTONS) == LEFT_BUTTON)
							{
								ui8Message = LEFT_BUTTON;
								ui8MessageToScreen = LEFT_BUTTON;
								//
								// Guard UART from concurrent access.
								//
								xSemaphoreTake(g_pUARTSemaphore, portMAX_DELAY);
								UARTprintf("Left Button is pressed.\n");
								xSemaphoreGive(g_pUARTSemaphore);
							}
						else if((ui8CurButtonState & ALL_BUTTONS) == RIGHT_BUTTON)
							{
								ui8Message = RIGHT_BUTTON;
								ui8MessageToScreen = RIGHT_BUTTON;
								//
								// Guard UART from concurrent access.
								//
								xSemaphoreTake(g_pUARTSemaphore, portMAX_DELAY);
								UARTprintf("Right Button is pressed.\n");
								xSemaphoreGive(g_pUARTSemaphore);
							}

						//
						// Pass the value of the button pressed to LEDTask.
						//
						if(xQueueSend(g_pScreenButtonQueue, &ui8MessageToScreen, portMAX_DELAY) !=
						        pdPASS)
							{
								//
								// Error. The queue should never be full. If so print the
								// error message on UART and wait for ever.
								//
								UARTprintf("\nScreen Queue full. This should never happen.\n");

								while(1)
									{
									}
							}
						if(xQueueSendToFront(g_pScreenButtonQueue, &ui8Message, portMAX_DELAY) !=
													        pdPASS)
						{
							//
							// Error. The queue should never be full. If so print the
							// error message on UART and wait for ever.
							//
							UARTprintf("LED Queue full. This should never happen.\n");

							while(1)
								{
								}
						}
				}
			}

		//
		// Wait for the required amount of time to check back.
		//
		vTaskDelayUntil(&ui16LastTime, ui32SwitchDelay / portTICK_RATE_MS);
	}

I haev tried xQueueSend, xQueueSendToFront and xQueueSendToBack. The Queues are initialized like this:

    g_pLEDQueue = xQueueCreate(5, sizeof(uint8_t));
g_pScreenButtonQueue = xQueueCreate(5, sizeof(uint8_t));

However only the Screen Task actually receives . They are called like this:

    if(xQueueReceive(g_pScreenButtonQueue, &i8MessageFromButton,10) == pdPASS) {
        // Does stuff
     }

    if(xQueueReceive(g_pLEDQueue , &i8Message,10) == pdPASS) {
        // Does stuff
     }

I have tired butting 0 and 10.

If I swap the order of the If statements for the send then it works. Any ideas?

davedoors wrote on Friday, March 27, 2015:

The code you posted never sends on the g_pLEDQueue queue.

jordied wrote on Saturday, March 28, 2015:

Yes that is why. I feel so dumb