cancel
Showing results for 
Search instead for 
Did you mean: 

MCU pin not getting low even after enabling pull-down resistor for that specific pin

GPach.3
Associate

 I was implementing 2-way switch project on my Nucleo-F303RE. For that, I put the 13th and 14th pins of port-c as input and the 15th pin of the same port as output. I am using pull-down resistor for 13th and 14th pin but even after enabling pull-down resistor of these pins. SFR window in debug mode shows 13th bit of IDR still high.

 I have made sure that no pin should be connected to any external source

Here is my code and screenshots:

 /*

* Pin 13, 14, 15 of port-c will be used:-

  -> 13 and 14 pins will be used for input

  -> 15 pin will be used for output

* RCC address - 0x40021000 :-

  -> RCC_AHBENR - 0x40021014

  -> 19th bit for GPIOC

* GPIOC address - 0x48000800 :-

  -> GPIOC_MODER - 0x48000800

   => 15 (31[0] and 30[1]), 14(29[0] and 28[0]), 13(27[0] and 26[0])

  -> GPIOC_PUPDR - 0x48000808 :-

   => 14(29[1] and 28[0]), 13(27[1] and 26[0])

  -> GPIOC_IDR  - 0x48000810 :-

   => 13th and 14th bits

  -> GPIOC_ODR  - 0x48000814 :-

   => 15th bit

*/

#include<stdio.h>

#include<stdint.h>

int main(void)

{

uint32_t volatile *const pClkCntrl      = (uint32_t*)0x40021014;

uint32_t volatile *const pPortCMode   = (uint32_t*)0x48000800;

uint32_t volatile *const pPortCPullDwn = (uint32_t*)0x4800080C;

uint32_t volatile *const pPortC_IP     = (uint32_t*)0x48000810;

uint32_t volatile *const pPortC_OP    = (uint32_t*)0x48000814;

*pClkCntrl   |= ( 1 << 19 );    // enabling clock for GPIOC

*pPortCMode  &= ~(0xFC000000);    // reseting port c mode reg

*pPortCMode  |= (0x40000000);    // setting 15th(port-c) pin in output mode and 13th and 14th pins of port-c in input mode

*pPortCPullDwn &= ~(0x3C000000);    // resetting port c pull-up, pull-down reg

*pPortCPullDwn |= (0x28000000);    // enabling pull-down resistor for 13th and 14th pin

    /* Loop forever */

for(;;);

}

1.)0693W000005AwOpQAK.png 

2.)

0693W000005AwPEQA0.png 

3.)

0693W000005AwPOQA0.png4.)0693W000005AwQ2QAK.png 

5.)

0693W000005AwQHQA0.png6.)0693W000005AwQbQAK.png

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

> Nucleo-F303RE

> 13th and 14th pins of port-c as input and the 15th pin of the same port as output

PC13-15 are not good choices since they're connected to things on the board.

0693W000005AwkHQAS.png 

Schematic is available on the resources page:

https://www.st.com/en/evaluation-tools/nucleo-f303re.html#documentation

You can remove these components but you'll also need to make sure PC13MODE, PC14MODE and PC15MODE are configured to allow these to work as standard GPIO pins.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

> Nucleo-F303RE

> 13th and 14th pins of port-c as input and the 15th pin of the same port as output

PC13-15 are not good choices since they're connected to things on the board.

0693W000005AwkHQAS.png 

Schematic is available on the resources page:

https://www.st.com/en/evaluation-tools/nucleo-f303re.html#documentation

You can remove these components but you'll also need to make sure PC13MODE, PC14MODE and PC15MODE are configured to allow these to work as standard GPIO pins.

If you feel a post has answered your question, please click "Accept as Solution".

thanks, by choosing different pins it worked