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
SPI transferBits(*data, *out, bits) sending strange
Re: SPI transferBits(*data, *out, bits) sending strange
Hello,
It seems that nobody uses is function ?????????
It could be usefull when using SPI devices which doesn't use 8bits dialog !!!!!!!!!!!
For me, i'm using an MCP3008 ( 10 bits ADC SPI ), and this device could use only 17bits instead of 24 to dialog with it's MCU and using this method could lead to a very fast sampling device !!!
ANY ADVICE ????????????????????????????
Thanks !
It seems that nobody uses is function ?????????
It could be usefull when using SPI devices which doesn't use 8bits dialog !!!!!!!!!!!
For me, i'm using an MCP3008 ( 10 bits ADC SPI ), and this device could use only 17bits instead of 24 to dialog with it's MCU and using this method could lead to a very fast sampling device !!!
ANY ADVICE ????????????????????????????
Thanks !
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: SPI transferBits(*data, *out, bits) sending strange
Kinda depends on what ESP you use. Some ESP32 types can only do SPI transactions in 8 bit increments.
Re: SPI transferBits(*data, *out, bits) sending strange
Thanks for your answer !
I'm using a Lolin32 Lite clone, may be it's concerned by the content of your answer ?
I'll try with another model of clone and tell you if this is the same situation !
Pierre
I'm using a Lolin32 Lite clone, may be it's concerned by the content of your answer ?
I'll try with another model of clone and tell you if this is the same situation !
Pierre
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: SPI transferBits(*data, *out, bits) sending strange
Hm, that chip uses the 'classic' ESP32, which should be capable of non-multiple-of-8-bit transactions. Sorry, then it's not your hardware and I don't know enough about the Arduino environment to tell you what the issue is.
Who is online
Users browsing this forum: lbernstone and 46 guests