lpcware

LPC812, PORT0_0

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by alagner on Tue Mar 25 13:27:27 MST 2014
First of all, hello from a new board user :)

Now the point:

what I am trying to achieve is setting the PORT0_0 as output and driving the RFM73 CE pin.

My looks like that:

void pins_init(void)
{
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6) | (1<<7)  | (1<<18); //gpio, switch matrix, iocon enable
  LPC_GPIO_PORT->DIR0 |= (1<<0); //P0_0 output
  LPC_IOCON->PIO0_0 &= ~(0x03<<3); //clear all pullups on P0_0
  LPC_SWM->PINENABLE0 |=(1<<0); //just in case;should off as default, added after problems
  LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<7) & ~(1<<18); //all set-up so shut them down
  // todo INT pin
}

inline void
rfm73_ce_pin_set_high_state(void)
{
  LPC_GPIO_PORT->SET0 = (1<<0);
}
inline void
rfm73_ce_pin_set_low_state(void)
{
  LPC_GPIO_PORT->CLR0 = (1<<0);
}

...and the pin goes HiZ right after disabling pullups and the output cannot be set in any way. Checked using voltmeter (always 0.3 - 0.6V) and scope.

However this one:
int
main(void)
{
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6) | (1<<18);    //gpio clock enable, io control clock enable
  LPC_IOCON->PIO0_16 = (1<<7);  //disable pullups
  LPC_GPIO_PORT->DIR0 |= (1<<16);

  for(;;)
  {
    for (volatile int i=0; i< 100000; i++);
    LPC_GPIO_PORT->NOT0 = (1<<16);
  }

  return 0;
}

blinks led like charm. What's the catch then?

Outcomes