Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Only one of wwo queues working on Tiva TM4c123GXL

Posted by jordied on 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?


Only one of wwo queues working on Tiva TM4c123GXL

Posted by davedoors on March 27, 2015

The code you posted never sends on the g_pLEDQueue queue.


Only one of wwo queues working on Tiva TM4c123GXL

Posted by jordied on March 28, 2015

Yes that is why. I feel so dumb


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


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner