Post Go back to editing

ADXL362 will only read axis

Thread Summary

The user encountered an issue where reading multiple axes (X, Y, Z) of the ADXL362 via SPI worked correctly in the main function but failed when refactored into separate functions. The problem was resolved by identifying that the UART function used for printing the data was causing the issue, leading to incorrect readings for the Y axis.
AI Generated Content

HI, I am trying to read the X, Y and Z axis of the ADXL362. When all the SPI communication is done in the main I can read all axis fine. When I refactor the code into their own functions e.g. read_x_axis, read_y_axis and read_z_axis it will only let me read one of the axis.

For example if I try and read the x axis on its own it will work. If I try and read the y  axis on its own it will work. But if I try and read the x axis and then the y axis, the x axis will return valid results but the y axis returns a constant number, in my case 29545.

I am setting the device into measurment mode correctly.

Am I not doing something else correctly in the setup?

Thanks