uais tipos / tamanhos de variáveis são atômicos nos microcontroladores STM3

Aqui estão os tipos de dados nos microcontroladores STM32:http: //www.keil.com/support/man/docs/armcc/armcc_chr1359125009502.ht.

sses microcontroladores usam processadores ARM de 32 bit

uais tipos de dados têm acesso atômico de leitura e gravação atômic

Tenho certeza de que todos os tipos de dados de 32 bits funcionam (já que o processador é de 32 bits) e todos os tipos de dados de 64 bits NÃO (pois seriam necessárias pelo menos duas operações do processador para ler ou gravar um sistema de 64 bits). palavra), mas ebool (1 byte) euint16_t/int16_t (2 bytes)?

Contexto: estou compartilhando variáveis entre vários segmentos (núcleo único, mas vários segmentos ou "tarefas", como são chamados, em FreeRTOS) no STM32 e preciso saber se preciso impor o acesso atômico desativando interrupções, usando mutexes et

ATUALIZAR

Referindo-se a este código de exemplo:

volatile bool shared_bool;
volatile uint8_t shared u8;
volatile uint16_t shared_u16;
volatile uint32_t shared_u32;
volatile uint64_t shared_u64;
volatile float shared_f; // 32-bits
volatile double shared_d; // 64-bits

// Task (thread) 1
while (1)
{
    // Write to the values in this thread.
    // What I write to each variable will vary. Since other threads
    // are reading these values, I need to ensure my *writes* are atomic, or else
    // I must use a mutex to prevent another thread from reading a variable in the middle
    // of this thread's writing.
    shared_bool = true;
    shared_u8 = 129;
    shared_u16 = 10108;
    shared_u32 = 130890;
    shared_f = 1083.108;
    shared_d = 382.10830;
}

// Task (thread) 2
while (1)
{
    // Read from the values in this thread.
    // What thread 1 writes into these values can change at any time, so I need to ensure
    // my *reads* are atomic, or else I'll need to use a mutex to prevent the other 
    // thread from writing to a variable in the midst of reading
    // it in this thread.
    if (shared_bool == whatever)
    {
        // do something
    }
    if (shared_u8 == whatever)
    {
        // do something
    }
    if (shared_u16 == whatever)
    {
        // do something
    }
    if (shared_u32 == whatever)
    {
        // do something
    }
    if (shared_u64 == whatever)
    {
        // do something
    }
    if (shared_f == whatever)
    {
        // do something
    }
    if (shared_d == whatever)
    {
        // do something
    }
}

No código acima, para quais variáveis posso fazer isso sem usar um mute Minha suspeita é a seguinte:

volatile bool: safe - não é necessário mutexvolatile uint8_t: safe - não é necessário mutexvolatile uint16_t: safe - não é necessário mutexvolatile uint32_t: safe - não é necessário mutexvolatile uint64_t: NÃO SEGURO - VOCÊ DEVE USAR UMA SEÇÃO CRÍTICA OU MUTEX!volatile float: safe - não é necessário mutexvolatile double: NÃO SEGURO - VOCÊ DEVE USAR UMA SEÇÃO CRÍTICA OU MUTEX!

Exemplo da seção crítica com o FreeRTOS:
- https: //www.freertos.org/taskENTER_CRITICAL_taskEXIT_CRITICAL.htm

// Force atomic access with these critical section atomic access guards.
taskENTER_CRITICAL();
// do the (now guaranteed to be safe) read or write here
taskEXIT_CRITICAL();
Relacionado, mas sem responder à minha pergunta: Operações atômicas no ARMARM: A escrita / leitura de int ato (Minha própria pergunta e resposta sobre atomicidade em microcontroladores AVR de 8 bits [e Arduino]):https: //stackoverflow.com/a/39693278/456188

questionAnswers(3)

yourAnswerToTheQuestion