2015-04-20 10:20 AM
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;
}
2015-04-20 10:39 AM
May be you want to be reading the IDR (Input Data Register) not the configuration register?