-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
I'm working on ENV.III sensor with Arduino Uno and RaspberryPi Pico boards.
I found - the Pressure and Temperature from QMP6988 were incorrect because of 2 things:
1-st Issue:
Lines 12 to 13 in b1b5692
| #define QMP6988_U32_t unsigned int | |
| #define QMP6988_S32_t int |
int on avr boards is int16_t.long on both avr and 32-bit boards is int32_t
#define QMP6988_U32_t unsigned long
#define QMP6988_S32_t long2-nd Issue:
Lines 75 to 94 in 7dc1c6f
| qmp6988.qmp6988_cali.COE_a0 = | |
| (QMP6988_S32_t)(((a_data_uint8_tr[18] << SHIFT_LEFT_12_POSITION) | | |
| (a_data_uint8_tr[19] << SHIFT_LEFT_4_POSITION) | | |
| (a_data_uint8_tr[24] & 0x0f)) | |
| << 12); | |
| qmp6988.qmp6988_cali.COE_a0 = qmp6988.qmp6988_cali.COE_a0 >> 12; | |
| qmp6988.qmp6988_cali.COE_a1 = | |
| (QMP6988_S16_t)(((a_data_uint8_tr[20]) << SHIFT_LEFT_8_POSITION) | | |
| a_data_uint8_tr[21]); | |
| qmp6988.qmp6988_cali.COE_a2 = | |
| (QMP6988_S16_t)(((a_data_uint8_tr[22]) << SHIFT_LEFT_8_POSITION) | | |
| a_data_uint8_tr[23]); | |
| qmp6988.qmp6988_cali.COE_b00 = | |
| (QMP6988_S32_t)(((a_data_uint8_tr[0] << SHIFT_LEFT_12_POSITION) | | |
| (a_data_uint8_tr[1] << SHIFT_LEFT_4_POSITION) | | |
| ((a_data_uint8_tr[24] & 0xf0) >> | |
| SHIFT_RIGHT_4_POSITION)) | |
| << 12); |
a_data_uint8_tr[18] and a_data_uint8_tr[0] after leftshifting these values by 12 - they'll overflow on avr boards.changing their type to QMP6988_S32_t will solve this issue
qmp6988.qmp6988_cali.COE_a0 =
(QMP6988_S32_t)((((QMP6988_S32_t)a_data_uint8_tr[18] << SHIFT_LEFT_12_POSITION) |
(a_data_uint8_tr[19] << SHIFT_LEFT_4_POSITION) |
(a_data_uint8_tr[24] & 0x0f))
<< 12);
qmp6988.qmp6988_cali.COE_a0 = qmp6988.qmp6988_cali.COE_a0 >> 12;
qmp6988.qmp6988_cali.COE_a1 =
(QMP6988_S16_t)(((a_data_uint8_tr[20]) << SHIFT_LEFT_8_POSITION) |
a_data_uint8_tr[21]);
qmp6988.qmp6988_cali.COE_a2 =
(QMP6988_S16_t)(((a_data_uint8_tr[22]) << SHIFT_LEFT_8_POSITION) |
a_data_uint8_tr[23]);
qmp6988.qmp6988_cali.COE_b00 =
(QMP6988_S32_t)((((QMP6988_S32_t)a_data_uint8_tr[0] << SHIFT_LEFT_12_POSITION) |
(a_data_uint8_tr[1] << SHIFT_LEFT_4_POSITION) |
((a_data_uint8_tr[24] & 0xf0) >>
SHIFT_RIGHT_4_POSITION))
<< 12); Metadata
Metadata
Assignees
Labels
No labels