AnsweredAssumed Answered

GPIO toggle, uneven high and low.

Question asked by ashok.arun on Dec 9, 2011
Latest reply on Dec 9, 2011 by Clive One
Hi,

 I want to measure the clock of my stm32f225rg chip. I am doing it by toggling the bit of gpio port B and checking using scope.  Rather than using the routines in the standard peripheral library, I am programming the registers directly.  The routine for toggling is below.
while (1)
      {

        GPIOB->BSRRL = GPIO_Pin_15;     // Set
        GPIOB->BSRRH = GPIO_Pin_15;      // ReSet
        GPIOB->BSRRL = GPIO_Pin_15;     // Set
        GPIOB->BSRRH = GPIO_Pin_15;      // ReSet
        GPIOB->BSRRL = GPIO_Pin_15;     // Set
        GPIOB->BSRRH = GPIO_Pin_15;      // ReSet
        GPIOB->BSRRL = GPIO_Pin_15;     // Set
        GPIOB->BSRRH = GPIO_Pin_15;      // ReSet
        GPIOB->BSRRL = GPIO_Pin_15;     // Set
        GPIOB->BSRRH = GPIO_Pin_15;      // ReSet
        GPIOB->BSRRL = GPIO_Pin_15;     // Set
        Delay(200);
        GPIOB->BSRRH = GPIO_Pin_15;     // ReSet
        Delay(200);

      }

The toggling can be observed in the scope, but I find the on and off times different. Though the number of instructions for the bitset and bitreset are 4 it seems bitset is using 5 clock cycles and bitreset 4. Any help  would be appreciated.

Outcomes