MAX3421E: reduce default SPI freq to 20 MHz to accomodate granularity on ESP32#11078
MAX3421E: reduce default SPI freq to 20 MHz to accomodate granularity on ESP32#11078dhalbert wants to merge 2 commits into
Conversation
|
If I remember correctly, the actual baudrate set should be the highest possible that is lower than the requested baudrate, so that you can always request the maxium badurate supported by the device you are trying to communicate with. This seems to be a bug in the baudrate setting code, not in the driver. |
|
@deshipu says:
We discussed this internally and agree the baudrate should be a ceiling. The current documentation (from 2018) says: As you correctly point out, this is a bad idea. We'll fix this. On some boards, like nRF528xx, it is already a ceiling. |
|
So I will make this a draft since the better fix to fix the SPI baudrate semantics. |
|
SPI @ 20 MHz definitely helps the Feather V2 <-> MAX3241E. That was a key finding you worked out. I am experiencing two other issues that are causing instability with the MAX3241E.
I can submit a separate patch for these two. Still testing... |
|
This is going to be superseded by #11081, assuming that is merged. |
|
Closing in favor of #11081, which is a more general solution. |
The problem here is that the default SPI frequency for the MAX3421E is 24 MHz. However, the SPI frequency ("baudrate") has different granularity on different Espressif chips. On ESP32-C6, 24 MHz is actually 20 MHz. On ESP32, 24 MHz is actually ~26.67 MHz (26.666...). On ESP32-S2, it's also 26.67 MHz.
The max spec of the MAX3421E is 26 MHz, so it's at the hairy edge. On S2 it works some of the time, but not ESP32; I'm not sure why. but in any case, it's too high.
20 MHz is OK on all, so I've changed the default from 24 MHz to 20 MHz, and documented this. I re-tested on ESP32 and other chips.
Also fixed a tiny typo in
espressif/mpconfigport.mk.Claude Code was helpful on this. It started out on incorrect theories, but was good at instrumenting whether the MAX3421E setup was working or not. It suggested lower baudrates as a test at one point, and that set me on a quest of which baud rates actually worked. I then discovered the different quantization of the baudrates.
This raises a long-term issue of whether SPI clock rates (and similar) should round down or not. I'll open an issue about that.