LPC812, PORT0_0

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC812, PORT0_0

1,514件の閲覧回数
lpcware
NXP Employee
NXP Employee
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?
ラベル(1)
0 件の賞賛
返信
6 返答(返信)

1,391件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by alagner on Sun Apr 27 13:34:56 MST 2014
OK, solved. Typos are difficult to debug (got one in switch matrix bitmask), now everything's working perfect, thanks everyone :)
0 件の賞賛
返信

1,391件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MarcVonWindscooting on Wed Mar 26 11:34:10 MST 2014
@bavarian:
You're right, we messed up the thread. THE QUESTION is: wether or not

LPC_IOCON->PIO0_0 &= ~(0x03<<3); //clear all pullups on P0_0

causes loss of control over PIO0_0 or not. And if so, why?
0 件の賞賛
返信

1,391件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bavarian on Wed Mar 26 06:39:06 MST 2014
I lost a little bit the overview what in fact you try to achieve and where the problem is  8-)
Maybe the code snippet below helps:

/* This code sets all 18GPIOs on LPC812 to output */
/* Enable AHB clock to the GPIO domain. */
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
// Configure the pins through the switch matrix
LPC_SWM->PINENABLE0 = 0xFFFFFFFF;

/* Pin I/O Configuration */
LPC_IOCON->PIO0_0 = 0x98;
LPC_IOCON->PIO0_1 = 0x98;
LPC_IOCON->PIO0_2 = 0x98;
LPC_IOCON->PIO0_3 = 0x98;
LPC_IOCON->PIO0_4 = 0x98;
LPC_IOCON->PIO0_5 = 0x98;
LPC_IOCON->PIO0_6 = 0x98;
LPC_IOCON->PIO0_7 = 0x98;
LPC_IOCON->PIO0_8 = 0x98;
LPC_IOCON->PIO0_9 = 0x98;
LPC_IOCON->PIO0_10 = 0x100;
LPC_IOCON->PIO0_11 = 0x100;
LPC_IOCON->PIO0_12 = 0x98;
LPC_IOCON->PIO0_13 = 0x98;
LPC_IOCON->PIO0_14 = 0x98;
LPC_IOCON->PIO0_15 = 0x98;
LPC_IOCON->PIO0_16 = 0x98;
LPC_IOCON->PIO0_17 = 0x98;

/* Peripheral reset control to GPIO and GPIO INT, a "1" brings it out of reset. */
LPC_SYSCON->PRESETCTRL &= ~(0x1<<10);
LPC_SYSCON->PRESETCTRL |= (0x1<<10);

/* Set port P0.0 - P0.17 to output, all LEDs off (write a '1') */
for ( i = 0; i < 18; i++)
{
  GPIOSetDir( 0, i, 1 );
  GPIOSetBitValue( 0, i, 1 );
}


0 件の賞賛
返信

1,391件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MarcVonWindscooting on Tue Mar 25 16:57:00 MST 2014

Quote: alagner

LPC_IOCON->PIO0_0 &= ~(0x03<<3) & 0x0000FFFF; //clear all pullups on P0_0 


I explained with the wrong register. The one above has bits 16..31 'reserved'. Same problem, if accessed as a 32-bit word.  My lib accesses here with 16bits. Check your header file providing LPC_IOCON. Or better use that:

LPC_IOCON->PIO0_0 = LPC_IOCON->PIO0_0 & ~(0x03<<3) & 0x0000FFFF;

This is NOT the same in this special context, contrary to intuition

Edit: Sorry the last 2 lines are bullshit! It's way too late, I should go to bed. I don't have any more ideas this night any more....
0 件の賞賛
返信

1,391件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by alagner on Tue Mar 25 16:20:44 MST 2014
Still no luck

  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6) | (1<<7)  | (1<<18); //gpio, switch matrix, iocon enable
  LPC_IOCON->PIO0_0 &= ~(0x03<<3) & 0x0000FFFF; //clear all pullups on P0_0 
  //right after the above instruction the pin goes "permanent high impedance"

  LPC_SWM->PINENABLE0 |=(1<<0);  
  LPC_GPIO_PORT->DIR0 |= (1<<0); //P0_0 output
  LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<7) & ~(1<<18) & 0xFFFFF;
0 件の賞賛
返信

1,391件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MarcVonWindscooting on Tue Mar 25 15:26:31 MST 2014
It is known, that GPIO clock is enabled on LPC812FD20, Rev 4C (current volume production) at least - in contradiction to the UM (1.3 at least). I did not believe and tried myself. It's true!

Although I like your style of 'minimally invasive' instructions (&=, |=, set, clear registers,...), I fear you run into problems that result from register (default) contents in contradiction to the UM.

Can you try with direct assignments of the config registers? Or at least check, whether the config registers you use are set as expected?

Welcome, by the way  ;-)

UPDATE: I tried the following and it works:
** Failed to inline code **
Forget it. I never can inline code in this forum, I don't know why. One less than or greater than and all seems gone.
Find the file attached.

Something else must be wrong with your headers or your hardware device.

UPDATE again: As soon as I switch off IOCON clock, my P0_0 is dead, too. And I found why:

SYSAHBCLKCTRL bits 20..31: reserved.
What you read from reserved bits is undefined (random in the worst case). What you write has to be all 0s ! This is violated by SYSAHBCLKCTRL &= ~0 already.
0 件の賞賛
返信