Hi,
Working on the pressure sensor Fxps7400, using I2C, I have download sample code of Fxpss7400 Sensor Driver.
I have some question regarding the initialization.
uint8_t fxps7xxx_init(fxps7xxx_driver_t *pDriver)
{
// Initial the sensor driver handler and interfaces
if(NULL == pDriver){
return SENSOR_INVALIDPARAM_ERR;
}
uint8_t status = SENSOR_SUCCESS;
// initialize the communication channel
status = sensor_comm_init(&pDriver->comHandle);
if(status != SENSOR_SUCCESS){
return status;
}
uint8_t data = 0;
// dummy read to flush the data in communication buffer
sensor_comm_read(&pDriver->comHandle, FXPS7XXX_DEVSTAT, sizeof(data), &data);
status = sensor_comm_read(&pDriver->comHandle, FXPS7XXX_WHO_AM_I, sizeof(data), &data);
if(data != FXPS7XXX_H_WHOAMI_VALUE){
return FXPS7XXX_DEVICE_NOT_FOUND;
}
status = load_region(pDriver, CONFIG_C_REGSITERS);
if(status != SENSOR_SUCCESS){
return status;
}
//read the part information
uint8_t part_data = 0;
uint8_t part_index = 0;
status = sensor_comm_read(&pDriver->comHandle, FXPS7XXX_PN1, sizeof(part_data), &part_data);
if(part_data == 0x16){
part_index = 0;
}else{
part_index = (part_data>>4 & 0x0F);
}
pDriver->pressureOffset = part_tbl[part_index].pabOffSet;
pDriver->pressureSensitivity = part_tbl[part_index].pabSense;
return status;
}
First, it checks if the right part is present, with the good WhoAmI value.
Then is load specific memory region. I think it is necessary to be able to read the PN. Can you firm?
Reading PN register, it uses it as index of a table to obtain some parameters.
// fxps7xxx part information table
const fxps7xxx_part_table_t part_tbl[] = {{0x16, 24939.7, 66.62},
{0x11, 25536.4, 93.34},
{0x25, 28661.6, 30.42},
{0x0, 0, 0}, //dummy
{0x40, 28900, 14},
{0x55, 28990, 14}};
When I execute this on my device, I get over I2C [0x0C;0x40] ...
Can you explain me the link between device part number (normally FXPS7400DIA4) and the one i get from the device?
The part number registers are factory programmed OTP registers that include the
numeric portion of the device part number.
Can you tell me if I shall reuse or update the data from the part_tbl[] according to my device?
thanks in advance
Francois
已解决! 转到解答。
Hello Francois,
please see below answers from an application engineer I have contacted.
DESCRIPTION
[A] For items 1, 2: The customer is reading the correct values. The values for these two registers should be: C4 = 0C and C5 = 40. So when you read them sequentially you get 400C where the 400 means 20kPa to 400kPa device (FXPS7400DI) and the C means it the I2C device. Yes, the region has to be loaded and is correct as the customer shows.
3. Is the partNo list, from the part_tbl[], is complete or can I have a new value?
[A] For item 3: If I am understanding the customers question correctly, the part number table is complete. Let me know otherwise.
4. Is the pabOffSet/pabSense from the part_tbl[] have to be adjusted trough a calibration process?
[A] For item 4: These values are fixed based on the device part number and are located in the scaling parameters table of the datasheet. Always check the latest datasheet for correct settings.
With Best Regards,
Jozef
Hi Francois,
could you please provide reading from the WHO_AM_I register? In a scope from an oscilloscope or from a logic analyzer? When you read the WHO_AM_I register, you should read the 0xC4 value.
With Best Regards,
Jozef
Hi Joseph,
Yes you're right the return is xC4.
I'm using Logic analyzer from Saleae, inc.
I can only share to you the logs because of Network policy...
The following logs show the execution of
(void)fxps7xxx_init();
(void)fxps7xxx_get_pressure_temperature(&f32Pressure, &u8Temperature);
And as you can see, it return 0xC4.
write to 0x60 ack data: 0x3E
read to 0x60 ack data: 0xC4
write to 0x60 ack data: 0x14 0xC0
write to 0x60 ack data: 0x15
read to 0x60 ack data: 0xC0
write to 0x60 ack data: 0xC4
read to 0x60 ack data: 0x0C 0x40
write to 0x60 ack data: 0x62
read to 0x60 ack data: 0xA3 0x76
write to 0x60 ack data: 0x0E
read to 0x60 ack data: 0x5E
Hello Jozef, thank you for your quickness.
Indeed I2C exchanges are correct and i have the right device, but this was not my questions
I try to understand the initialization function from the example...
Thank in advance for these answers.
Regards,
François
Hello Francois,
please see below answers from an application engineer I have contacted.
DESCRIPTION
[A] For items 1, 2: The customer is reading the correct values. The values for these two registers should be: C4 = 0C and C5 = 40. So when you read them sequentially you get 400C where the 400 means 20kPa to 400kPa device (FXPS7400DI) and the C means it the I2C device. Yes, the region has to be loaded and is correct as the customer shows.
3. Is the partNo list, from the part_tbl[], is complete or can I have a new value?
[A] For item 3: If I am understanding the customers question correctly, the part number table is complete. Let me know otherwise.
4. Is the pabOffSet/pabSense from the part_tbl[] have to be adjusted trough a calibration process?
[A] For item 4: These values are fixed based on the device part number and are located in the scaling parameters table of the datasheet. Always check the latest datasheet for correct settings.
With Best Regards,
Jozef