2020-11-10 06:05 AM
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.)
2.)
3.)
4.)
5.)
6.)
Solved! Go to Solution.
2020-11-10 06:31 AM
> 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.
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.
2020-11-10 06:31 AM
> 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.
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.
2020-11-11 02:52 AM
thanks, by choosing different pins it worked