主题中讨论的其他部件: ENERGYTRACE
工具/软件:
尊敬的所有人:
当使用使用 EEPROM 存储器的 I2C 例程时、我遇到了以下情况。
MSP430FR5994上的 I2C 配置
//////////////////////////////////////////////////////////////////////////////// // Definição da Porta P5 como Serial I2C das Memórias EEPROMS // //////////////////////////////////////////////////////////////////////////////// P5OUT = 0; // Reseta Todos os Pinos da Porta P5 P5DIR = 0xFF; // Define Todos os Pinos da Porta P5 como Saídas P5OUT &=~ 0xFF; // Inicializa Todos os Pinos da Porta P5 com Nível Lógico "0" Baixo P5SEL0 |= (SDA | SCL); // P5.0 e P5.1 options select P5SEL0 = 0 // Seleciona o Pino da Porta P5.0 UCB1SDA e P5.1 UCB1SCL como Barramento I2C P5SEL1 &=~ (SDA | SCL); // P5.0 e P5.1 options select P5SEL1 = 1 // Seleciona Módulo Secundário Conforme Tabela I/O Function Selection = 1 | 0 // Configuração do Barramento I2C das Memórias EEPROMs UCB1CTLW0 |= UCSWRST + UCMST + UCMODE_3 + UCSYNC + UCSSEL__SMCLK; // Enable SW reset, I2C Master, Modo i2c, synchronous mode UCB1BRW = 40; // fSCL = SMCLK = 16.000.000/40 = 400 kHz UCB1CTLW0 &=~ UCSWRST; // Clear SW reset, resume operation UCB1IE |= UCNACKIE + UCTXIE0 + UCRXIE0; // Interrupts Enable
使用 eeprom_ackPolling()时、如下所示:
/*----------------------------------------------------------------------------*/ // Description: // Acknowledge Polling. The EEPROM will not acknowledge if a write cycle is // in progress. It can be used to determine when a write cycle is completed. /*----------------------------------------------------------------------------*/ void EEPROM_AckPolling(void) { // finished all operations do { UCB1STATW = 0x00; // clear I2C interrupt flags UCB1CTLW0 |= UCTR; // I2CTRX=1 => Transmit Mode (R/W bit = 0) UCB1CTLW0 &= ~UCTXSTT; UCB1CTLW0 |= UCTXSTT; // start condition is generated while (UCB1CTLW0 & UCTXSTT) // wait till I2CSTT bit was cleared { if (!(UCNACKIFG & UCB1STATW)) // Break out if ACK received break; } UCB1CTLW0 |= UCTXSTP; // stop condition is generated after // slave address was sent => I2C communication is started while (UCB1CTLW0 & UCTXSTP); // wait till stop bit is reset Delay_TA3_ms(6); // Aguarda 6 milisegundo } while (UCNACKIFG & UCB1STATW); }
我注意到、LPM3中的电流消耗几乎比以这种方式使用时高10倍(约640uA)、约67uA:
/*----------------------------------------------------------------------------*/ // Description: // Acknowledge Polling. The EEPROM will not acknowledge if a write cycle is // in progress. It can be used to determine when a write cycle is completed. /*----------------------------------------------------------------------------*/ void EEPROM_AckPolling(void) { Delay_TA3_ms(6); // Aguarda 6 milisegundo }
在写入 EEPROM 存储器后、论坛上的任何人是否都遇到过电流消耗的这种差异?
此致、
Anderson Portela