Hello,
I want to share global data between two tasks which have different priority level.
Let me explain what i am doing:
1. I have two task TaskA(receiving data from serial module at 10ms rate) and TaskB(sending data to ethernet)
2. TaskA has high priority than TaskB.
Below are my tasks:
void TaskA( void *pvParameters )
{
( void ) pvParameters;
portTickType xNextWakeTime;
/// Initialise xNextWakeTime – this only needs to be done once
xNextWakeTime = xTaskGetTickCount()
///Init Serial Module
for(;;)
{
/// Place this task in the blocked state until it is time to run again
///The block state is specified in ticks, the constant used converts ticks to ms
vTaskDelayUntil( &xNextWakeTime, configTASKA_FREQUENCY_10MS );
///receive data from serial modbule and write into buffer
gusFastOutputParameter1 = (uint16_t)(g_pucRxBuffer[3] << 8);
gusFastOutputParameter1 |= (uint16_t)(g_pucRxBuffer[4]);
}
}
void TaskB( void *pvParameters )
{
( void ) pvParameters;
///Init Ethenet Module
for(;;)
{
*pucRegBuffer++ = ( unsigned char )( gusFastOutputParameter1 >> 8 );
*pucRegBuffer++ = ( unsigned char )( gusFastOutputParameter1 & 0xFF );
}
}
Problem: I do not want when TaskB is reading gusFastOutputParameter1 and in between TaskA writes to gusFastOutputParameter1.
gusFastOutputParameter1 is 2 byte data but in actual application i have 128 bytes of global data.
Please give your thought on this how i can avoid data corruption using FreeRTOS features(semaphore,mutex,queues or taskENTER_CRITICAL()) which low latency.