cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f103x read deep switch problem

daniel239955_stm1
Associate II
Posted on April 20, 2015 at 19:20

Hello everybody, i m a newbe to stm32 programming i wrote below function for read first 7 pins of GPIOA but its value only return 0x4444444 for GPIOA->CRL , it doesent matter if i change deep config whats wrong in my configuration?

// this functions read deepswitch (8)
uint8_t readBoardAddressEnd()
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
GPIO_InitTypeDef gpioStruct;
GPIO_StructInit(&gpioStruct);
gpioStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4;
gpioStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA , &gpioStruct);
assert_param(IS_GPIO_ALL_PERIPH(GPIOA));
assert_param(IS_GET_GPIO_PIN(GPIO_Pin_4) | 
IS_GET_GPIO_PIN(GPIO_Pin_3) |
IS_GET_GPIO_PIN(GPIO_Pin_2) |
IS_GET_GPIO_PIN(GPIO_Pin_1) |
IS_GET_GPIO_PIN(GPIO_Pin_0)); 
board_address = GPIOA->CRL & ((uint8_t)0x00011111);
GPIO_StructInit(&gpioStruct);
gpioStruct.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
gpioStruct.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOC , &gpioStruct);
board_address = board_address << 1;
board_address |= GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_3);
board_address = board_address << 1;
board_address |= GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_2);
return board_address;
}

1 REPLY 1
Posted on April 20, 2015 at 19:39

May be you want to be reading the IDR (Input Data Register) not the configuration register?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..