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