PIC vs AVR & RMW instructions

Discussion in 'Embedded Systems and Microcontrollers' started by rhlee, Nov 22, 2012.

  1. rhlee

    Thread Starter New Member

    May 5, 2012
    Hi again,

    I've been wanting to get into microcontrollers for while now.

    Initially I wanted to start with AVR/arduino. Compared to PIC they have larger memory, their assembler language is far saner than that of PIC's and the AVR's toolchain is "nicer". There is also the matter of larger userbase and the convenience arduino boards themselves.

    However the is one major thing bugging me about AVR chips and that is the lack of a read-modify-write instruction for critical sections of code. AVR only supports this on the larger chips like the AVR32, but with PIC you get it from the PIC12 and upwards IIRC.

    I just don't feel comfortable not having a RMW instruction. Sure you can do it in software, but it would not be 100% reliable.

    Are my concerns about RMW instructions justified? Or is that too much of an edge case?


  2. nsaspook

    AAC Fanatic!

    Aug 27, 2009
    Last edited: Nov 22, 2012
    rhlee likes this.
  3. nigelwright7557

    AAC Fanatic!

    May 10, 2008
    The danger with a lack of RMW instructions is if an interrupt changes the I/o at the same time a none RMW write to a port occurs. The I/o will get screwed up.
    The only way around is to disable interrupts while the software RMW takes place.
  4. MrChips


    Oct 2, 2009
    As far as I know, all RMW instructions must complete execution even if an interrupt occurs while the instruction is in mid-execution.

    AFSIK, the Atmel AVR does not suffer from any such deficiency.
    Perhaps you can enlighten me on this.