Closed AhdHahn closed 1 year ago
_status.dr is updated through a union based on the result of a function call. See the source which defines the structure below, specifically line 113.
IRQ_handler
calls the read
function, which calls the transfer
function, which in turn sets the value of _status.dr
based on the result of the SPI transfer
Is _status.dr not updating? If it isn't try using the develop
branch since commits to that branch may solve your issue.
Hello Mirageofmage, Thank you very much for fast reply. In the "_transfer" function sets the "_status.raw" value which part of the "_transfer" function changes the “_status.dr” logic? Thanks.
_status.dr
is just one bit within _status
. as all mcp3x6x do full duplex, and the first byte read back corresponds to the status, the return value of spi->transfer(addr)
corresponds exactly bit aligned to this status, just like Mirageofmage pointed out with the status_t union
@arthanth is this some real issue or are you just trying to understand the code? if first please specify your problem.
I use MCP3564 (ADC 9 Click) with ESP32 (Wemos D1 R32 pinOut-R32). Voltage incorect value it show 0 and 2.39 in mux mode. I try to fix follow the previous issue but it does not work now. So I am trying to understand the code and debuging.
Voltage incorect value it show 0 and 2.39 in mux mod
You should check the configuration 0 register of your MPC3564. The default Voltage Reference is set to 2.4V.
And also check ADCDATA REGISTER if the result is what you expected.
a few more thoughts:
_spi->begin();
adding the actual pins. Also just yesterday figured out there is a _spi->transfer32();
for at least some ESP32 variants... should not matter to you, but might help to speed up communication.mcp.begin()
does set some defaults, which are not necessarily the defaults according the datasheet. all settings done by you (select channel, clk_sek, vref, gain, timing, ...) should be done after the begin()
I am closing this as no actual question/issue seems open. please feel free to come back if you run into troubles again.
How is the “_status.dr” logic changed? (In the IRQ_handler() does not change the “_status.dr”) Thanks