ADXL375 maximum polling rate

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
richpaul6806
 
Posts: 16
Joined: Sun May 21, 2023 12:39 am

Re: ADXL375 maximum polling rate

Post by richpaul6806 »

I am reading the bits from starting at D0-D3 going from right to left but writing them from D3-D0 going left to right

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: ADXL375 maximum polling rate

Post by adafruit_support_bill »

Your program is reading the 4 bits in the same order as you wrote them. But you are writing just the low-order 4 bits of the register and then reading back and printing the entire 8 bit register.

The low order 4 bits are just what you wrote: 1101 == 0xD == 13
The high order 4 bits are all zero. So you are reading back: 00001101 == 0x0D == 13

User avatar
richpaul6806
 
Posts: 16
Joined: Sun May 21, 2023 12:39 am

Re: ADXL375 maximum polling rate

Post by richpaul6806 »

isnt the code RWBits(4, rate_register, 0) telling the program to start at bit 0 and write the next 4 bits(right to left)?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: ADXL375 maximum polling rate

Post by adafruit_support_bill »

It is defining a 4-bit wide field with the low-order bit at position 0.

https://docs.circuitpython.org/projects ... t/api.html
Parameters
:
num_bits (int) – The number of bits in the field.

register_address (int) – The register address to read the bit from

lowest_bit (int) – The lowest bits index within the byte at register_address

register_width (int) – The number of bytes in the register. Defaults to 1.

lsb_first (bool) – Is the first byte we read from I2C the LSB? Defaults to true

signed (bool) – If True, the value is a “two’s complement” signed value. If False, it is unsigned.

User avatar
richpaul6806
 
Posts: 16
Joined: Sun May 21, 2023 12:39 am

Re: ADXL375 maximum polling rate

Post by richpaul6806 »

Ah ok. So it is counting right to left to get the block, but once the block is set we read and write left to right. Seems like a backwards way of organizing everything but I'm sure there is some higher level reasoning for it.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”