i2c on lpc812 using lpc open

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

i2c on lpc812 using lpc open

411件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by plantman on Mon Feb 10 03:27:12 MST 2014
I am trying to use a ds1338 rtc (ds1307 compatible) on i2c with an lpc812 max board using pins P0_10, P0_11(marked sda scl) I have tried with and without pullup resistors.

I have it working on a 3.3v arduino setup but when I try to use it with  lpc open i just get an error.

any help much appreciated.

In arduino I use
  Wire.beginTransmission(DS1307_ADDRESS);

  byte zero = 0x00;
  Wire.write(zero);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_ADDRESS, 1);


what I have tried to use with lpc open.

static void readDateI2CMaster(uint16_t AddressI2C, int *date)
{
uint8_t recvData[10], sendData[10];
I2C_PARAM_T param;
I2C_RESULT_T result;
ErrorCode_t error_code;
int sindex = 0, rindex = 0;


sendData[sindex++] = (uint8_t) AddressI2C  | 0x00;
sendData[sindex++] = (uint8_t) 0x00;

recvData[rindex++] = (uint8_t) AddressI2C  | 0x01;


param.num_bytes_send    = 2;
param.num_bytes_rec     = 1;
param.buffer_ptr_send   = &sendData[0];
param.buffer_ptr_rec    = &recvData[0];
param.stop_flag         = 1;
#if defined(INTERRUPTMODE)
param.func_pt           = cbI2CComplete;
#endif

/* Set timeout (much) greater than the transfer length */
LPC_I2CD_API->i2c_set_timeout(i2cHandleMaster, 100000);

/* Do master read transfer */
#if defined(INTERRUPTMODE)
intErrCode = -1;

/* Function is non-blocking, returned error should be LPC_OK, but isn't checked here */
error_code = LPC_I2CD_API->i2c_master_receive_intr(i2cHandleMaster, &param, &result);

/* Sleep until transfer is complete, but allow IRQ to wake system
   to handle I2C IRQ */
while (intErrCode == -1) {
__WFI();
}

/* Cast saved error code from callback */
error_code = (ErrorCode_t) intErrCode;

#else
error_code = LPC_I2CD_API->i2c_master_receive_poll(i2cHandleMaster, &param, &result);
#endif

/* Completed without erors? */
if (error_code != LPC_OK) {
/* Likely cause is NAK */
DEBUGOUT("i2c_master_receive error code : %x\r\b", error_code);
errorI2C();
}

*date = (int) recvData[1];

}

ラベル(1)
0 件の賞賛
返信
0 返答(返信)