cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the IDR of portc for STM32F103R4

Hani Ahmed
Associate II
Posted on March 26, 2018 at 20:32

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.
11 REPLIES 11
Posted on March 27, 2018 at 10:05

Is your whole PORT A set for output?

JW

Posted on March 27, 2018 at 11:43

Yes, i'm making whole of Port A & B as outputs,

and using whole of Port c as inputs

Posted on March 27, 2018 at 16:09

And can you verify that, for example by toggling all the PORT A bits?

JW

henry.dick
Senior II
Posted on March 27, 2018 at 20:51

Portc->idr would do.

Posted on March 27, 2018 at 19:10

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

Posted on March 27, 2018 at 20:47

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.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on March 27, 2018 at 21:34

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.

Posted on March 27, 2018 at 21:35

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.

Posted on March 27, 2018 at 22:03

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);
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..