2013-06-14 05:15 AM
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_unionstypedef 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_unionsNow 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 arm2013-06-14 05:19 AM
Also I have started a thread on keil :
, why there is difference in timing between two.I have also tried by changing the macro with do{}while(0);, nut no effect2013-06-14 10:53 AM
If the 8 bits are aligned to a byte boundary, it is faster to write the byteto the Output Data Register:
for (uint8_t i = 8; i <
255
; ++i)
((uint8_t __IO*)&GPIOA->ODR)[0] = i;
-Gary