i have a bldc motor with hall sensors, each hall sensor is conected to PA0 PA1 PA2 which coresponds to CH1,2,3 of timer2.
So in my gpio init routine i have declared the gpio's as following
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 |GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_PinAFConfig(GPIOA, GPIO_PinSource0, GPIO_AF_TIM2);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_TIM2);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_TIM2);
And somewhere in the timer2 cc1 irq handler i want to read the bit order of the 3 hall sensors.
i was thinking ading something like this uint16_t pdata = GPIO_ReadInputData(GPIOA) & 0x0007
But i read some unusual values.
Do i need another mode for GPIO in order to read the corect data? i was thinking of using GPIO_Mode_IN , but in this case will i am able to trigger the timer2 ?