why cortex m3 bit manipulation is atomic

Discussion in 'Embedded Systems and Microcontrollers' started by aamirali, Jul 11, 2014.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    415
    1
    As far as I know, atomic operation are those which can not be interrupted. It implies that that they are single cycle operation.
    Because any operation having more than one cycle can be interrupted if any high priority interrupt comes.


    Now bit or port pin manipulation in cortex M3 involves 3 instruction i.e load,move,store.
    So how can this be atomic, any high priority interrupt can occur after load or move instruction.
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,140
    1,790
    I think you may be conflating two different scenarios. Modifying a single bit in a register or port requires an operation known as "read-modify-write" which preserves all of the other bits while only changing one of them. This operation has to be atomic to prevent unintended results.

    When you change all of the bits in a register or port by writing an entire byte, halfword, or word you don't need to read the contents first, you simply overwrite what is there. This operation is already atomic without any further consideration.

    In order to clarify your confusion maybe you could refer to a specific instruction that is creating the problem.
     
Loading...