LPC1769 with HMC5883L using I2C

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

LPC1769 with HMC5883L using I2C

469 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by f_baggar@hotmail.com on Mon Nov 10 12:42:29 MST 2014

I need help interacting LPC1769 with HMC5883L through I2C. I wrote the code below to read the register 0x0A of the HMC5883L
but when i check the signal through logic analyzer i get blank. I dont see any SDA/SDC logics on the logic analyzer. What is the problem?

#include "lpc17xx.h"
#include "type.h"
#include "i2c.h"


extern volatile uint8_t I2CMasterBuffer[I2C_PORT_NUM][BUFSIZE];
extern volatile uint8_t I2CSlaveBuffer[I2C_PORT_NUM][BUFSIZE];
extern volatile uint32_t I2CReadLength[I2C_PORT_NUM];
extern volatile uint32_t I2CWriteLength[I2C_PORT_NUM];

#define PORT_USED1



int main (void)
{
  uint32_t i;

  /* SystemClockUpdate() updates the SystemFrequency variable */
  SystemClockUpdate();

    I2C1Init( );/* initialize I2c1 */

  I2CWriteLength[PORT_USED] = 2;
  I2CReadLength[PORT_USED] = 4;
  I2CMasterBuffer[PORT_USED][0] = sensor_ADDR;
  I2CMasterBuffer[PORT_USED][1] = 0x0A;/* address */
  for ( i = 0; i < 0x200000; i++ );/* Delay after write */
  I2CMasterBuffer[PORT_USED][2] = sensor_ADDR | RD_BIT;
  I2CEngine( PORT_USED );

  /* Check the content of the Master and slave buffer */
  while ( 1 );

}

/* sensor_ADDR is 0x3C
/* RD_BIT 0x01
0 项奖励
回复
2 回复数

410 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by f_baggar@hotmail.com on Mon Nov 10 14:47:50 MST 2014
I used the same hardware with arduino and it worked fine.
0 项奖励
回复

410 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon Nov 10 14:02:10 MST 2014

Quote: f_baggar@hotmail.com
... i check the signal through logic analyzer i get blank. I dont see any SDA/SDC logics on the logic analyzer. What is the problem?



Would suggest to check SCL  :)

Your wrong code should at least generate a clock signal...

If not, check your hardware (Pin setting, pull-ups)...
0 项奖励
回复