cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO Sest-Change doesnt get reflected in BSRR

pranathi1091
Associate II
Posted on November 07, 2012 at 09:17

Hello All,

I am using STM32F2 series.

I want to set PORT E pin 1, And here goes my code

GPIO_InitTypeDef *GPIO_InitStruct;

 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);

 GPIO_InitStruct->GPIO_Pin = GPIO_Pin_1 ; 

    GPIO_InitStruct->GPIO_Mode = GPIO_Mode_OUT;

    GPIO_InitStruct->GPIO_OType = GPIO_OType_PP;

    GPIO_InitStruct->GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStruct->GPIO_PuPd = GPIO_PuPd_NOPULL;

    GPIO_Init(GPIOE, GPIO_InitStruct);   

 GPIO_WriteBit(GPIOE,GPIO_Pin_1,Bit_SET);

 GPIO_SetBits(GPIOE,GPIO_Pin_1);

When I debug the code, i could not find any changes in BSRR , even if i set this.

Could anyone help in resolving this

Thanks

#gpio #gpio #gpio #bssr #gpio
6 REPLIES 6
Posted on November 07, 2012 at 12:48

Perhaps you should be looking at ODR, the bits of BSRR are documented to read as zero, so the register is considered read only. Review the reference manual.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pranathi1091
Associate II
Posted on November 07, 2012 at 12:58

Thanks for the reply clive

I could see ODR value set to 0x0002, since m using Pin No 1 when i debug.

But that pin is not set in the hardware.

Is there anything which i have missed out.

I have checked with LCKR and its not active.

Is there any fault in my configuration?

Posted on November 07, 2012 at 13:08

Maybe you are looking at the wrong pin, or it's enabled as FSMC someplace else. I don't know much about your board, or code.

IDR (input data register) should reflect the state of the pin, regardless of the configuration.

If that pin state is zero, I might also look for external shorts, either at the pin, or within the net it is connected too.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pranathi1091
Associate II
Posted on November 07, 2012 at 15:34

Thanks Clive

I am using IOTOGGLE example in the ST examples, by just changing the port pins.

Is there any clock setting i have missed out?

Other than enabling GPIO clock?

Posted on November 07, 2012 at 17:01

The code doesn't look objectionable, you could perhaps try some different pins. This might eliminate issue with PE1 specifically, or what you have it connected too.

Something like this should exercise the pin.

// STM32 GPIO TOGGLE (PE.1) STM32F2 - sourcer32@gmail.com
#include ''stm32f2xx.h''
/**************************************************************************************/
void RCC_Configuration(void)
{
/* --------------------------- System Clocks Configuration -----------------*/
/* GPIOE clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
}
/**************************************************************************************/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure PE1 */
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOE, &GPIO_InitStructure);
}
/**************************************************************************************/
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
while(1)
{
GPIO_WriteBit(GPIOE, GPIO_Pin_1, (BitAction)1); // PE1 High
GPIO_WriteBit(GPIOE, GPIO_Pin_1, (BitAction)0); // PE1 Low
}
while(1); // Don't want to exit
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pranathi1091
Associate II
Posted on November 08, 2012 at 09:12

Thanks Clive

The culprit was the PIN. It wroks fine with rest of the GPIO