cancel
Showing results for 
Search instead for 
Did you mean: 

Sequential Read of ADXL345

brandondutoit
Associate
Posted on October 23, 2016 at 23:44

Hello, I am having problems reading the 6 output registers sequentially using the HAL drivers. I am able to read them one at a time without problems, but can't seem to get the sequential thing working? I'm using the following HAL function:

HAL_I2C_Master_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions)

where pData is defined as a uint8_t[6]. Do I need to run a loop to fill all 6 spaces in the variable or will all fill at the same time? And which of the XferOptions below do I use because this confuses me? *I2C_FIRST_AND_LAST_FRAME: No sequential usage, functional is same as associated interfaces in no sequential mode *I2C_FIRST_FRAME: Sequential usage, this option allow to manage a sequence with start condition, address and data to transfer without a final stop condition *I2C_NEXT_FRAME: Sequential usage, this option allow to manage a sequence with a restart condition, address and with new data to transfer if the direction change or manage only the new data to transfer if no direction change and without a final stop condition in both cases * I2C_LAST_FRAME: Sequential usage, this option allow to manage a sequence with a restart condition, address and with new data to transfer if the direction change or manage only the new data to transfer if no direction change and with a final stop condition in both cases #!stm32f4 #!i2c #!adxl345
1 REPLY 1
michaelc.barton9
Associate II
Posted on October 24, 2016 at 09:56

no, you don't need to loop around, the function will do that for you, you just need to tell it how many bytes to read (the 6) eg:  uint8_t Data[6]  HAL_I2C_Master_Sequential_Receive_IT(hi2c, ADXL_ACC_X, Data, 6, I2C_FIRST_FRAME )

as for

XferOptions

, I'm guessing the one I used *should* work but I don't use HAL myself

from personal experience, I found the ADXL345 not the most straightforward accelerometer to use, so good luck !