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

  • In order to enable Tap detection in the device the user must enable the Tap Interrupt in the INTSU (0x06) register and AMSR [2:0] = 000 in the SR (0x08) register. In this mode, TILT (0x03) register, XOUT (0x00), YOUT (0x01), and ZOUT (0x02) registers will update at the 120 samples/second. The user can configure Tap Detection to be detected on X and/or Y and/or Z axes. The customer can configure this by changing the XDA, YDA, and/or ZDA bit in the PDET (0x09) register. Detection for enabled axes is decided on an OR basis: If the PDINT bit is set in the INTSU (0x06) register, the device reports the first axis for which it detects a tap by the Tap bit in the TILT (0x03) register. When the Tap bit in the TILT (0x03) register is set, tap detection ceases, but the device will continue to process orientation detection data. Tap detection will resume when the TILT (0x03) register is read.

Related