I2C Slave pulls SDA and SCL Pins low when entering Power Down mode

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

I2C Slave pulls SDA and SCL Pins low when entering Power Down mode

1,677 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by skywalk on Mon Feb 10 09:14:53 MST 2014
I try to test LPC812 power modes and use the LPCXpresso LPC812 Board and the NXP AN11332-Software together with LPCXpresso 6.1.4.

AN11332 Code works until the Device goes to "Power-Down" mode (not Deep-Power-Down).

At this moment, the SDA and SCL pins go low (~0.5 Vdc) voltage.
That disables all other I2C Traffic on the bus and the LPC will never get its Address for waking from Power-Down.
This would make the "wake from I2C" unsuable.

As far as i understand the AN11332 Code, it should work fine; the configuration seems to be OK.

Has somebody used the LPC812 I2C as an Slave and configured it for Power-Down?

/*connect the I2C SCL and SDA sigals to port pins(P0.10-P0.11)*/
regVal = LPC_SWM ->PINASSIGN7 & ~(0xFFUL << 24);
LPC_SWM ->PINASSIGN7 = regVal | (10 << 24); /* P0.10 is I2C SDA, ASSIGN0(31:24) */
regVal = LPC_SWM ->PINASSIGN8 & ~(0xFF << 0);
LPC_SWM ->PINASSIGN8 = regVal | (11 << 0); /* P0.11 is I2C SCL. ASSIGN0(7:0) */

LPC_SYSCON ->CLKOUTDIV = 120; /* CLKOUT = 60E6 / 120 = 500 kHz */
LPC_SYSCON ->CLKOUTSEL = 0x03; /* CLKOUT = Main clock */
LPC_SYSCON ->CLKOUTUEN = 0x01; /* Update CLKOUT Source      */

LPC_GPIO_PORT ->DIR0 |= (1 << 5);
regVal = LPC_SWM ->PINASSIGN8 & ~(0xFF << 16);
LPC_SWM ->PINASSIGN8 = regVal | (0x0F << 16); /* P0.15 is CLKOUT. ASSIGN8(23:16) */

LPC_GPIO_PORT ->DIR0 |= (1 << 7);
SysTick_Config(SystemCoreClock / 2);

/* Enable I2C clock */
LPC_SYSCON ->SYSAHBCLKCTRL |= (1 << 5);
/* Toggle peripheral reset control to I2C, a "1" bring it out of reset. */
LPC_SYSCON ->PRESETCTRL &= ~(0x1 << 6);
LPC_SYSCON ->PRESETCTRL |= (0x1 << 6);

I2C_SlvInit(LPC_I2C, SLAVE_ADDR, CFG_SLVENA, I2C_FMODE_PRE_DIV);
/* Ready to receive the slave address, interrupt(SLAVE ADDR STATE) if match occurs. */
LPC_I2C ->SLVCTL = CTL_SLVCONTINUE;
LPC_I2C ->INTENSET = STAT_SLVPEND;

/* Enable wake from power down using I2C */
LPC_SYSCON ->STARTERP1 |= (1 << 8);



/*****************************************************************************
** Function name:PMU_Sleep
**
** Descriptions:Put some of the peripheral in sleep mode.
**
** parameters:SleepMode: 2 is power down, 1 is deep sleep, 0 is sleep, Sleep peripheral module(s)
** Returned value:None
** 
*****************************************************************************/
void PMU_Sleep( uint32_t SleepMode, uint32_t SleepCtrl )
{
  LPC_SYSCON->PDAWAKECFG = LPC_SYSCON->PDRUNCFG;
  LPC_SYSCON->PDSLEEPCFG = SleepCtrl;
  /* If normal sleep, not deep sleep, don't do anything to SCR reg. */
  switch ( SleepMode )
  {
case MCU_POWER_DOWN:
  SCB->SCR |= NVIC_LP_SLEEPDEEP;
#if __WKT
  LPC_PMU->DPDCTRL |= (0x1 << 2);
  init_wkt(1, 10000 * 10);
#endif
#if 1
  LPC_PMU->PCON = 0x2;
#else
  LPC_SYSCON->PDSLEEPCFG &= 0xFDFF;
#endif
  break;
case MCU_DEEP_SLEEP:
  SCB->SCR |= NVIC_LP_SLEEPDEEP;
#if __WKT
  LPC_PMU->DPDCTRL |= (0x1 << 2);
  init_wkt(1, 10000 * 10);
#endif
#if 1
  LPC_PMU->PCON = 0x1;
#else
  LPC_SYSCON->PDSLEEPCFG &= 0xEFF9;
#endif
  break;
case MCU_SLEEP:
default:
  break;
  }
  __WFI();
  return;
}


标签 (1)
0 项奖励
回复
3 回复数

1,152 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Sat Feb 22 07:33:40 MST 2014
Please red this FAQ
http://www.lpcware.com/content/faq/lpcxpresso/compiler-optimization

Especially the section called
Optimized code fails to execute correctly
0 项奖励
回复

1,152 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by skywalk on Sat Feb 22 02:17:10 MST 2014
Hi,

yes, the CLKOUT is low when entering the power-down mode!

I found that the software works if no optimization is used.

BUT if the software is compiled with optimization for program space ( i need the program space for a FATfs based application), the situation as described in my original post will show up.

As soon as i have found the reason for this behaviour, i will post the result.




0 项奖励
回复

1,152 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nxp_apps on Fri Feb 21 14:33:18 MST 2014
Hi,

The application note + software works. Have you monitored the CLKOUT pin to see if the device went into power-down mode?
The observed clock on the CLKOUT pin should go low since all internal clocks are shut down in power-down mode.

In the example code, the command to place the LPC812 into power-down is the I2C slave address 0x54 followed by data byte 0xAA,
I just want to make sure first that the lpc812 went into power-down mode.

Thanks.

nxp_apps
0 项奖励
回复