Skip to main content
chriskuku
Senior II
July 24, 2023
Solved

GPIO set certain bits without affecting others

  • July 24, 2023
  • 3 replies
  • 4072 views

BTW, what is the forum to ask general programming questions on STM32 architecture?
STM32F103C8Tx
I have two timer interrupt routines, sharing the

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim)

call. Depending on which handle is passed, I process the code for TIM1 or TIM3.
When I enter TIM3 code A0,A1,A2,and A3 of port GPIOA are set to all 1. I achieved this by the statement

GPIOA->ODR=0xffff on initialization and whenever I exit the ISR. On entry I set GPIOA->ODR=0xffff&(~1)
(the 1 is a rotating pattern that sets A0-A3).

Now I want to toggle A4 in the code for TIM1 without affecting bits A0-A3 and A4 shouldn't be affected during the manipulation of A0-A3 in the code for TIM3.

How can I achieve this if at all?

    This topic has been closed for replies.
    Best answer by KnarfB

    This can be done with the Port bit set/reset register (GPIOx_BSRR). See the Reference manual (RM0008).

    hth

    KnarfB

    3 replies

    KnarfB
    KnarfBBest answer
    Super User
    July 24, 2023

    This can be done with the Port bit set/reset register (GPIOx_BSRR). See the Reference manual (RM0008).

    hth

    KnarfB

    chriskuku
    chriskukuAuthor
    Senior II
    July 24, 2023

    Are there HAL functions for this, too?

     

    Tesla DeLorean
    Guru
    July 24, 2023

    Frequently expressed as Macros, suggest you Grep the source, or Find-In-Files, save you hours

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Piranha
    Principal III
    July 24, 2023

    What impedes you just opening the header file and looking at those functions?