Pull down Configuration
Posted: Fri Nov 29, 2013 3:58 am
Hello,
I have a problem with configuring PC13 as an input with pulldown.
I have this:
And a simple program:
When I take a measure of the voltage at the PC13 pin there are 3.3 V just like it was configured as pullup.
Maybe some body can help me,
Thanks a lot
I have a problem with configuring PC13 as an input with pulldown.
I have this:
Code: Select all
* Port C setup.
* All input with pull-up except:
* PC0 - GPIOC_OTG_FS_POWER_ON (output push-pull).
* PC7 - GPIOC_MCLK (alternate 6).
* PC10 - GPIOC_SCLK (alternate 6).
* PC12 - GPIOC_SDIN (alternate 6).
*/
#define VAL_GPIOC_MODER (PIN_MODE_OUTPUT(GPIOC_OTG_FS_POWER_ON) |\
PIN_MODE_INPUT(1) | \
PIN_MODE_INPUT(2) | \
PIN_MODE_INPUT(3) | \
PIN_MODE_INPUT(4) | \
PIN_MODE_INPUT(5) | \
PIN_MODE_INPUT(6) | \
PIN_MODE_ALTERNATE(GPIOC_MCLK) | \
PIN_MODE_INPUT(8) | \
PIN_MODE_INPUT(9) | \
PIN_MODE_ALTERNATE(GPIOC_SCLK) | \
PIN_MODE_INPUT(11) | \
PIN_MODE_ALTERNATE(GPIOC_SDIN) | \
PIN_MODE_INPUT(13) | \
PIN_MODE_INPUT(14) | \
PIN_MODE_INPUT(15))
#define VAL_GPIOC_OTYPER 0x00000000
#define VAL_GPIOC_OSPEEDR 0xFFFFFFFF
#define VAL_GPIOC_PUPDR (PIN_PUDR_FLOATING(GPIOC_OTG_FS_POWER_ON) |\
PIN_PUDR_PULLUP(1) | \
PIN_PUDR_PULLUP(2) | \
PIN_PUDR_PULLUP(3) | \
PIN_PUDR_PULLUP(4) | \
PIN_PUDR_PULLUP(5) | \
PIN_PUDR_PULLUP(6) | \
PIN_PUDR_FLOATING(GPIOC_MCLK) | \
PIN_PUDR_PULLUP(8) | \
PIN_PUDR_PULLUP(9) | \
PIN_PUDR_FLOATING(GPIOC_SCLK) | \
PIN_PUDR_PULLUP(11) | \
PIN_PUDR_FLOATING(GPIOC_SDIN) | \
PIN_PUDR_PULLDOWN(13) | \
PIN_PUDR_PULLUP(14) | \
PIN_PUDR_PULLUP(15))
#define VAL_GPIOC_ODR 0xFFFFFFFF
#define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_MCLK, 6))
#define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_SCLK, 6) | \
PIN_AFIO_AF(GPIOC_SDIN, 6))
/*And a simple program:
Code: Select all
#include "ch.h"
#include "hal.h"
#include "chprintf.h"
#include <stdio.h>
#include <string.h>
/*
* This is a periodic thread that does absolutely nothing except flashing
* a LED.
*/
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
chRegSetThreadName("blinker");
while (TRUE) {
palSetPad(GPIOA, GPIO_LED);
chThdSleepMilliseconds(500);
palClearPad(GPIOA, GPIO_LED);
chThdSleepMilliseconds(500);
}
}
/*
* Application entry point.
*/
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
if (palReadPad(GPIOC,13))
chprintf((BaseSequentialStream *)&SD1,"Hola\n");
/*
* Activates the serial driver 1 using the driver default configuration.
*/
/*
* Creates the example thread.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
while (TRUE) {
if (palReadPad(GPIOC,13))
chprintf((BaseSequentialStream *)&SD1,"Hola\n");
chThdSleepMilliseconds(1000);
}
}When I take a measure of the voltage at the PC13 pin there are 3.3 V just like it was configured as pullup.
Maybe some body can help me,
Thanks a lot