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

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 ]    [ 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