AnsweredAssumed Answered

How to Write 8 bit value on port in fastest way without disturbing other input/output pins on port

Question asked by A2 on Jun 14, 2013
Latest reply on Jun 14, 2013 by gary
I have write 8 bit value on port PA0-PA7, without disturbing PA8-PA15 in fastest possible way, also if interrupt comes & in that ISR PA8-PA15 are accessed they shouldn't make any error.

I have edited GPIO defs of the stm32f2xx.h file:
#pragma anon_unions
typedef struct
{
  __IO uint32_t MODER;    /*!< GPIO port mode register,               Address offset: 0x00      */
  __IO uint32_t OTYPER;   /*!< GPIO port output type register,        Address offset: 0x04      */
  __IO uint32_t OSPEEDR;  /*!< GPIO port output speed register,       Address offset: 0x08      */
  __IO uint32_t PUPDR;    /*!< GPIO port pull-up/pull-down register,  Address offset: 0x0C      */
  __IO uint32_t IDR;      /*!< GPIO port input data register,         Address offset: 0x10      */
  __IO uint32_t ODR;      /*!< GPIO port output data register,        Address offset: 0x14      */
  union 
  {
    struct
    {  
      __IO uint16_t BSRRL;    /*!< GPIO port bit set/reset low register,  Address offset: 0x18      */
      __IO uint16_t BSRRH;    /*!< GPIO port bit set/reset high register, Address offset: 0x1A      */
    };
    uint32_t BSRR;    
  };    
  __IO uint32_t LCKR;     /*!< GPIO port configuration lock register, Address offset: 0x1C      */
  __IO uint32_t AFR[2];   /*!< GPIO alternate function registers,     Address offset: 0x24-0x28 */
} GPIO_TypeDef;
#pragma no_anon_unions



Now I can write directly to BSRR register. I used this:, is this best way or any method:
        uint32_t i;
        for( i = 8; i < 255; i++ )
        {
             GPIOA->BSRR =  (i & 0x000000ff) | ((~i << 16) & 0x00ff0000); 
        } 

I am using Keil MDK arm

Outcomes