AnsweredAssumed Answered

Turning two GPIO pins on turns them both off FRDM-K82F

Question asked by Michael Arthur on May 27, 2016
Latest reply on May 29, 2016 by xiangjun.rong

EDIT: helps if I use the ground from the board instead of the 12V in for the board I am soldering up!

 

First of all this is the first arm board I've ever programmed so have mercy on me.

 

I have configured two pins PTB16 and PTB17 (it looks like the quick reference doc in the cardboard box got them the wrong way round as they correspond as below I am yet to double check this against the RM etc)

 

//define two pins for vcc1 and vcc2 #define VALVE_VCC1_PIN 16U //PTB17 #define VALVE_VCC1_GPIO GPIOB #define VALVE_VCC1_PORT PORTB #define VALVE_VCC2_PIN 17U //PTB16 #define VALVE_VCC2_GPIO GPIOB #define VALVE_VCC2_PORT PORTB

 

So I've configured them in pin_mux.c

CLOCK_EnableClock(kCLOCK_PortA);  PORT_SetPinMux(VALVE_VCC1_PORT, VALVE_VCC1_PIN, kPORT_MuxAsGpio); PORT_SetPinMux(VALVE_VCC2_PORT, VALVE_VCC2_PIN, kPORT_MuxAsGpio);     

 

Then in main.c I init the pins

/* Output pin configuration */  gpio_pin_config_t valve_config =   {   kGPIO_DigitalOutput, 1,   };    /*  Sets the configuration */  void initState() {   GPIO_PinInit(VALVE_VCC1_GPIO, VALVE_VCC1_PIN, &valve_config);   GPIO_PinInit(VALVE_VCC2_GPIO, VALVE_VCC2_PIN, &valve_config); }

 

Then I use the GPIO_TogglePinsOutput functions to turn them on, which individually if I only do one, works. however if I do both they both fail.

 

//stop when flow is going. void openValve() {   GPIO_TogglePinsOutput(VALVE_VCC2_GPIO, 1U << VALVE_VCC2_PIN); }   //stop when flow stops void closeValve() {   GPIO_TogglePinsOutput(VALVE_VCC1_GPIO, 1U << VALVE_VCC1_PIN); }

 

I have no idea why and I don't own a jlink debugger (however work does have one) am using KDS studio

 

I am doing this project for fun and it would be great to learn how to use this board better.

 

lastly thank you!

Outcomes