2012-11-08 07:15 AM
hello , im a newbie to stm32 and im just starting with stm32f4 discovery,
i have to write an 8 bit value to GPIOA ODR from bit2 to bit9 while not altering bit0 and bit1 how can i do that? it`s a noob question but i want learn kindly help regards #set-bits-in-odr2012-11-08 08:24 AM
hello , im a newbie to stm32 and im just starting with stm32f4 discovery, i have to write an 8 bit value to GPIOA ODR from bit2 to bit9 while not altering bit0 and bit1 how can i do that?
*((__IO uint32_t *)&GPIOA->BSRRL) = ((x & 0xFF) << 2) | ((~x & 0xFF) << (2 + 16)); // Set the 1 bits, Clear the 0 bits, QED or GPIOA->ODR = (GPIOA->ODR & ~(0xFF << 2)) | ((x & 0xFF) << 2);