SPI transferBits(*data, *out, bits) sending strange
Posted: Thu Oct 12, 2023 4:17 pm
Hello,
This code:
uint16_t readSPI(uint8_t first, uint16_t last) {
CS_LOW_inline();
uint32_t ret = 0;
uint32_t *out = &ret;
uint32_t data = first << 16;
data |= last;
SPI.transferBits( data, out, 17); // here is the problem
CS_HIGH_inline();
return ret & 0x0FFF;
}
does not return bits from 16-0 but instead bits from 23-7 so I have to write SPI.transferBits( data, out, 24);
to obtain the last bits (which is my interest)
Is it normal ????
Thanks for your advices !!!!!!!
Pierre
This code:
uint16_t readSPI(uint8_t first, uint16_t last) {
CS_LOW_inline();
uint32_t ret = 0;
uint32_t *out = &ret;
uint32_t data = first << 16;
data |= last;
SPI.transferBits( data, out, 17); // here is the problem
CS_HIGH_inline();
return ret & 0x0FFF;
}
does not return bits from 16-0 but instead bits from 23-7 so I have to write SPI.transferBits( data, out, 24);
to obtain the last bits (which is my interest)
Is it normal ????
Thanks for your advices !!!!!!!
Pierre