I’m attempting to establish communication with an MCP3304 ADC using AXI Quad SPI. While I’ve successfully designed a custom overlay, I’m facing difficulties in interacting with the sensor. I’m seeking guidance on how to create a Python wrapper to facilitate this communication.
Below is the screenshot of the implemented design and the related files:
As far i remember, sending data was very straight forward. But, for receiving you have to send two extra cycle of data, so can you delete first two cycle of data which is useless. But it is completely depends on the IC, how its protocol is written. So, if whatever i was testing is similar to yours, you want to have 3 received data bytes then you actually have to sent total of 5 bytes of data.
In my opinion, your IC is not similar and you have only one extra byte, so omit 255 in this case. The two data later on is the data you want. if you want to have 3 data bytes, you have to send a garbage address at the end, so can you receive one extra bytes of data.
This datasheet will explain more about what they are:
As i can see, you have selected channel 1 by sending the command according to the above reference.
the received data
202(0xCA-0b’11001010), here 11 is don’t care, 0 is start bit, 0 is sign bit, 1010 - MSB
0x43- 0b’01000011 LSB
so, your data is 0101001000011 (2627 in decimal)
I have made the necessary modifications in the design to accommodate multiple slaves, but I’m encountering challenges while creating a Python wrapper for it. If there is any example code or a sample wrapper available for handling multiple slaves, please provide it to assist me in this task.
First of all, ext_spi_clk can’t exceed axi4 clock according to the datasheet. Also, a maximum speed of ext_spi_clk is around 80-100 MHz (check product guide PG153 please)
As I stated in a previous post, I had a tough time implementing slave mode as there was probably a bug that might have been fixed by now. But I have not tried since. I have not seen any wrapper available for it. The OP of that post probably found a solution, you can ask him.
It is actually quite easy if go through the register values mentioned in the datasheet. you just need to set the SPI Slave Select Register (0x70) value. If it is missing something, you might need to adjust other registers e.g. control register (0x60).