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

twi sensor

i am programming nrf-51 dk's program.

i have to get data from sensor, so i am studying example code which is twi_sensor.

i don't know well these function.

nrf_drv_twi_tx(&m_twi_mma_7660, MMA7660_ADDR, reg, sizeof(reg), false);

i know function's parameters is

[in] p_instance TWI instance.
[in] address Address of a specific slave device (only 7 LSB).
[in] p_data Pointer to a transmit buffer.
[in] length Number of bytes to send.
[in] xfer_pending After a specified number of bytes, transmission will be suspended (if xfer_pending is set) or stopped (if not).

but how do i know TWI instance and address Address of a specific slave device?

the example code's parameters that is m_twi_mma_7660, MMA7660_ADDR are acceleration sensor's instance and address.

but i'm going to use heart rate sensor.

and when i execute the example program, nrf_drv_twi_tx returns error.

so it is locked at 'while(m_set_mode_done == false);'.

what is the problem?

ret_code_t err_code;
/* Writing to MMA7660_REG_MODE "1" enables the accelerometer. */
uint8_t reg[2] = {MMA7660_REG_MODE, ACTIVE_MODE};

err_code = nrf_drv_twi_tx(&m_twi_mma_7660, MMA7660_ADDR, reg, sizeof(reg), false);  

APP_ERROR_CHECK(err_code);

while(m_set_mode_done == false);

please let me know. i need help....

Parents
  • By the way . i dont have this example , so i just geuss the m_set_mode_done is a ack of callback that MMA7660 is enable finish or not.

    The program stuck in here becaue the MMA7660 is not yet ready or other reasons. Please ensure the slave of address, i2c pin assign , pin config is correct. If you have checked above , please check the timing of i2c protocol is right.

Reply
  • By the way . i dont have this example , so i just geuss the m_set_mode_done is a ack of callback that MMA7660 is enable finish or not.

    The program stuck in here becaue the MMA7660 is not yet ready or other reasons. Please ensure the slave of address, i2c pin assign , pin config is correct. If you have checked above , please check the timing of i2c protocol is right.

Children
No Data
Related