This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ADXL345 I2C integration with nRF52832

I am trying to integrate an ADXL345 with my nRF52. I am attempting to implement Bjørn Spockeli's driver which I stumbled upon here: devzone.nordicsemi.com/.../

I am using sdk12.2.0, specifically the TWI_sensor example project. I have replaced the main.c file and included the ADXL345 driver files with the files downloaded from the link above.

When I program the nRF52 and use RTT viewer, it appears that the code is not working entirely. For example, I am not seeing things printed like "Setting Data rate Sucessful!" or "Setting Offsets Sucessful!". However, I added my own print commands and I see that the code stops executing within the ADXL375_I2C_register_write function as part of the original ADXL375_I2C_init function. I included my added SEGGER_RTT_printf commands below. RTT viewer will show the first "we're here!!!!" but will not go on to print "twi tx success!!!!" below that.

`ret_code_t ADXL375_I2C_register_write(uint8_t slave_addr,uint8_t * pdata, uint32_t bytes) { ret_code_t ret_code; SEGGER_RTT_printf(0,"we're here!!!!\n");

ret_code = nrf_drv_twi_tx(p_twi_master, slave_addr, pdata, bytes , false);

SEGGER_RTT_printf(0,"twi tx success!!!!\n"); return ret_code; }`

Next, I looked into the nrf_drv_twi_tx function in nrf_drv_twi.c. The following SEGGER_RTT_printf "NRF_DRV_TWI_XFER_DESC_TX success!!!!" shows in RTT viewer, but that is the last thing shown in RTT viewer. (The next thing should be the "twi tx success!!!!" shown above from the function return):

`... nrf_drv_twi_xfer_desc_t xfer = NRF_DRV_TWI_XFER_DESC_TX(address, (uint8_t*)p_data, length);

SEGGER_RTT_printf(0,"NRF_DRV_TWI_XFER_DESC_TX success!!!!\n"); return nrf_drv_twi_xfer(p_instance, &xfer, no_stop ? NRF_DRV_TWI_FLAG_TX_NO_STOP : 0); //return does not work? }`

I am confident my wiring is set up correctly. The SCL line is connected to P0.03 and the SDA line is connected to P0.04. Both of these have a 4.7k ohm resistor in parallel connected to ground. The SDO line is grounded to enable I2C. Vcc and CS are powered at around 3.6V, and finally ground is connected to ground.

Do you have any suggestions for me to get this working? I am assuming this is a wiring issue but I have checked and double checked my setup.

Thank you for any advice you may have.

Levi

Related