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

How to read and write to registers of MMA7660 using TWI


Hi, i am working on TWI sensor example in SDK1. in which i connected SCL And SDA pins tonRF52 dk boards sca and scl pins. and connected voltage and ground. when i run the application on board i am getting x,y,z values and when i shake the board its able to print SHAKE string in UART. the problem is

1).what is meaning of Tap. ineed to tap on MMA7660 or i need to shake the sensor up and down. how to tap the sensor(MMA74660) to get TAP bit in TILT register to set.

2). if i tap the sensor the TAP bit not changing in TILT register.

  1. if i want to read the register value i done fallowing. and also wanted to change register value but it is not worked.

     uint8_t reg1[2] = {MMA7660_REG_PDET,TAP_THS};
    
     nrf_drv_twi_tx(&m_twi_mma_7660, MMA7660_ADDR, reg1, sizeof(reg1), false);
    
             ret_code_t err_code;
    
             uint8_t value;
    
             uint8_t addr = MMA7660_REG_TILT;
    
             err_code = nrf_drv_twi_tx(&m_twi_mma_7660, MMA7660_ADDR, &addr, 1, true);
    
             if (NRF_SUCCESS == err_code)
    
                 err_code = nrf_drv_twi_rx(&m_twi_mma_7660, MMA7660_ADDR, (uint8_t*)&value, sizeof(value));
    
             APP_ERROR_CHECK(err_code);
    
            // printf("\n\r PDT(0x09) %x",TILT_TAP_MASK);
    
                printf("\n\r MMA7660_REG_TILT(0x03) %d",value);
    

this is not changing the MMA7660_REG_TILT(0x03) register value how i can read it.

Thankyou

Related