2012-11-07 12:17 AM
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 #gpio2012-11-07 03:48 AM
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.
2012-11-07 03:58 AM
2012-11-07 04:08 AM
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.2012-11-07 06:34 AM
2012-11-07 08:01 AM
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
}
2012-11-08 12:12 AM