Other Parts Discussed in Thread: TMAG5170
Hi Team,
We are using the TMAG5170-Q1, We are able to get the sensor data when the sensor is operating in DEVICE_CONFIG_OPERATING_MODE_ActiveMeasureMode.
my application demands data only for 90 second once. So in order to save power I want to put the TMAG5170 sensor to sleep mode.
Below is the overall steps: I am doing in application
1. putSensorToSleepMode()
2. wakeUpSensorFromSleepModeToActiveMeasureMode()
3. do
{
read Sensor Data
delay(90 sec)
} while (1)
I could not see any change in the sensor data.
I am attaching my driver code below .
int8_t enterConfigurationMode() { int8_t retVal = 0xFF; // To prevent undefined behavior, this function does not perform its operation // when the DATA_TYPE field (address: 0x028-6) is not set to Normal Read Mode (000b) if ( DATA_TYPE_RESULTS != DATA_TYPE_RESULTS_NormalMode ) return HALL_SENSOR_API_CALL_NOT_PERMITTED_IN_SPECIAL_READ_MODE; uint16_t input; // Set OPERATING_MODE (address: 0x006-4) to Configuration Mode (0h) retVal = normalReadRegister(DEVICE_CONFIG_ADDRESS,&input); if(retVal != HALL_SENSOR_API_CALL_SUCCESS) return retVal; input = ( input & ~(DEVICE_CONFIG_OPERATING_MODE_MASK) ) | DEVICE_CONFIG_OPERATING_MODE_ConfigurationMode; retVal = writeToRegister( DEVICE_CONFIG_ADDRESS, input); #ifdef MAX_DELAYS_IN_OPMODE_CHANGES delay_us(50); // max expected delay as given by t_start_sleep (datasheet pg. 10) #endif return retVal; } int8_t enterSleepMode() { int8_t retVal = 0xFF; // To prevent undefined behavior, this function does not perform its operation // when the DATA_TYPE field (0x028-6) is not set to Normal Read Mode (000b) if ( DATA_TYPE_RESULTS != DATA_TYPE_RESULTS_NormalMode ) return HALL_SENSOR_API_CALL_NOT_PERMITTED_IN_SPECIAL_READ_MODE; uint16_t input; // Set OPERATING_MODE (0x006-4) to Sleep Mode (5h) retVal = normalReadRegister(DEVICE_CONFIG_ADDRESS,&input); if(retVal != HALL_SENSOR_API_CALL_SUCCESS) return retVal; input = ( input & ~(DEVICE_CONFIG_OPERATING_MODE_MASK) ) | DEVICE_CONFIG_OPERATING_MODE_SleepMode; retVal = writeToRegister( DEVICE_CONFIG_ADDRESS, input); #ifdef MAX_DELAYS_IN_OPMODE_CHANGES delay_us(60); // max expected delay as given by t_go_sleep (datasheet pg. 10) #endif return retVal; } int8_t exitSleepMode() { int8_t retVal = 0xFF; // To prevent undefined behavior, this function does not perform its operation // when the DATA_TYPE field (0x028-6) is not set to Normal Read Mode (000b) if ( DATA_TYPE_RESULTS != DATA_TYPE_RESULTS_NormalMode ) return HALL_SENSOR_API_CALL_NOT_PERMITTED_IN_SPECIAL_READ_MODE; uint16_t input; // Set OPERATING_MODE (0x006-4) to Configuration Mode (0h) retVal = normalReadRegister(DEVICE_CONFIG_ADDRESS,&input); if(retVal != HALL_SENSOR_API_CALL_SUCCESS) return retVal; input = ( input & ~(DEVICE_CONFIG_OPERATING_MODE_MASK) ) | DEVICE_CONFIG_OPERATING_MODE_ConfigurationMode; retVal = writeToRegister( DEVICE_CONFIG_ADDRESS, input); #ifdef MAX_DELAYS_IN_OPMODE_CHANGES delay_us(140); // max expected delay as given by t_start_sleep + t_stand_by (datasheet pg. 10) #endif return retVal; } int8_t enterActiveMeasureMode() { int8_t retVal = 0xFF; // To prevent undefined behavior, this function does not perform its operation // when the DATA_TYPE field (address: 0x028-6) is not set to Normal Read Mode (000b) if ( DATA_TYPE_RESULTS != DATA_TYPE_RESULTS_NormalMode ) return HALL_SENSOR_API_CALL_NOT_PERMITTED_IN_SPECIAL_READ_MODE; uint16_t input; // Set OPERATING_MODE (0x006-4) to Active Measure Mode (2h) retVal = normalReadRegister(DEVICE_CONFIG_ADDRESS,&input); if(retVal != HALL_SENSOR_API_CALL_SUCCESS) return retVal; input = ( input & ~(DEVICE_CONFIG_OPERATING_MODE_MASK) ) | DEVICE_CONFIG_OPERATING_MODE_ActiveMeasureMode; retVal = writeToRegister( DEVICE_CONFIG_ADDRESS, input); #ifdef MAX_DELAYS_IN_OPMODE_CHANGES delay_us(140); // max expected delay as given by t_start_sleep + t_stand_by (datasheet pg. 10) #endif return retVal; }
I am attaching my application API code below.
appSensorErrCode_E putSensorToSleepMode(void)
{
int8_t retVal;
appSensorErrCode_E appRetVal;
retVal = enterConfigurationMode();
delay_ms(10);
retVal = enterSleepMode();
return appRetVal;
}
appSensorErrCode_E wakeUpSensorFromSleepModeToActiveMeasureMode(void)
{
int8_t retVal;
appSensorErrCode_E appRetVal;
retVal = exitSleepMode();
delay_ms(10);
retVal = enterActiveMeasureMode();
return appRetVal;
}
May i know is that something am i doing wrong.
As per the data sheet. timing is taken care in driver code. As well as before transition from sleep mode to active measure mode, the intermediate configuration mode is also taken care.
With Regards
Ilan T