Hello all!
I just bought the FRDM-KL25Z Board and trying to do some basic IO-stuff. I use MCUXpresso/Eclipse IDE.
Now I´m wondering, how to enable the Pull-Up resistors. Here´s my code (L. 39-41), but unfortunately the Input-Pin is floating, so no Pullup seem to be activated...
Furthermore, I had to comment out L.44 and L.47, because the compiler threw errors ('kPORT_UnLockRegister' undeclared), even if it was the example from the SDK reference.
Anyone have an idea how to activate the Pullups?
#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_port.h"
#include "fsl_gpio.h"
static void delay(volatile uint32_t nof) {
while(nof!=0) {
__asm("NOP");
nof--;
}
}
int main(void) {
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
CLOCK_EnableClock(kCLOCK_PortB);
CLOCK_EnableClock(kCLOCK_PortE);
PORT_SetPinMux(PORTB, 18u, kPORT_MuxAsGpio);
PORT_SetPinMux(PORTE, 3u, kPORT_MuxAsGpio);
static const gpio_pin_config_t LED_configOutput = {
kGPIO_DigitalOutput,
1,
};
static const gpio_pin_config_t switch_configInput = {
kGPIO_DigitalInput,
0,
};
GPIO_PinInit(GPIOB, 18u, &LED_configOutput);
GPIO_PinInit(GPIOE, 3u, &switch_configInput);
port_pin_config_t pinConfig = {
kPORT_PullUp,
kPORT_FastSlewRate,
kPORT_PassiveFilterDisable,
kPORT_LowDriveStrength,
kPORT_MuxAsGpio,
};
PORT_SetPinConfig(PORTE, 3u, &pinConfig);
while(1) {
if((((GPIOE->PDIR) >> 3) & 0b1) == 0) {
GPIO_ClearPinsOutput(GPIOB, 1<<18);
delay(2000000);
GPIO_SetPinsOutput(GPIOB, 1<<18);
delay(1200000);
}
}
return 0;
}