FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [February 2012 Threads]
Hi all,
I am running FreeRTOS successfully on a STM32F103CBT6 using Keil uVision.
I use the SPI from two different tasks. To ensure only one task is accessing the SPI at a time i use a Mutex.
So far so good.
From the flash.c-file of the demonstration i got the following function.
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
unsigned portSHORT usBit;
vTaskSuspendAll();
{
if( uxLED < partstMAX_OUTPUT_LED )
{
usBit = partstFIRST_LED << uxLED;
if( usOutputValue & usBit )
{
usOutputValue &= ~usBit;
}
else
{
usOutputValue |= usBit;
}
GPIO_Write( GPIOC, usOutputValue );
}
}
xTaskResumeAll();
}
I am wondering about the use of the SuspendAll / ResumeAll calls. What exactly are they for in this application? I see two possible explanations.
1) To ensure no other task is currently accessing the usOutputValue-variable.
2) To ensure no other task is currently calling the GPIO_Write-function.
I think the GPIO_Write-function shouldn't be the reason, there is no read modify-write operation in the function.
void GPIO_Write(GPIO_TypeDef* GPIOx, u16 PortVal)
{
GPIOx->ODR = PortVal;
}
When exactly do I need to use such a "critical section" ?
Thanks for clearing my confusion.
Benjamin
usOutputValue is a file scope variable, so you are correct in your assumption that it protects against multiple access of the usOutputValue variable.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.