2018-03-26 11:32 AM
Hi
I'm using STM32F103R4 and trying to read the IDR of portc but it only i get data for PC4 & PC5, so how i can figure it out
below my configuration
GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; GPIO_Init(GPIOC, &GPIO_InitStructure); while (1) { GPIOA-> ODR = GPIO_ReadInputData(GPIOC); } #stm32f103r4 Note: this post was migrated and contained many threaded conversations, some content may be missing.2018-03-27 01:05 AM
Is your whole PORT A set for output?
JW
2018-03-27 04:43 AM
Yes, i'm making whole of Port A & B as outputs,
and using whole of Port c as inputs
2018-03-27 09:09 AM
And can you verify that, for example by toggling all the PORT A bits?
JW
2018-03-27 11:51 AM
Portc->idr would do.
2018-03-27 12:10 PM
So what should i do then, i'm new in the 32bit systems and my experience in of MCU programming is still early in general
2018-03-27 01:47 PM
Well you're trying to determine if your issue is one of input or output.
If you use GPIOA->ODR ^= 0xFFFF; you'll see them all move, depending on what else you're using the pins for on your board/design. What pins are being used by the debug interface?
while(1) GPIOA->ODR = GPIOC->IDR; // Copies C pins to A pins
while(1)
{
GPIOA->ODR = GPIOC->IDR; // A is C
GPIOB->ODR = ~GPIOC->IDR; // B is Inverse of C
}
Check also that you've enabled all the clocks and pins properly.
2018-03-27 02:34 PM
Hi Clive
for outputs texting it is working OK, my main issue to when i try to configure port as inputs, it don't work as expected, some IDR bits are responding but others not, i think there is some thing wrong with my configuration but i don't know it
Note: i'm configuring whole the ports as inputs or outputs.
2018-03-27 02:35 PM
Hi dhenry
my main issue when i try to configure port as inputs, it don't work as expected, some IDR bits are responding but others not, i think there is some thing wrong with my configuration but i don't know it
Note: i'm configuring whole the ports as inputs or outputs.
2018-03-27 03:03 PM
Not familiar with the board you're using or how you have it wired up. You have selected Input Pull-Down, is that appropriate?
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_INPUT_FLOATING; GPIO_Init(GPIOC, &GPIO_InitStructure);