-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Update hspi_slave.c #5489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update hspi_slave.c #5489
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
I found that SPI communication did not work due te a wrong timing of the MISO signal with respect to SCK. With slower processores like Arduino UNO (and a small delay of sck due to th level converter) it works, but with a faster Arduino DUE (without converter) it did not. Together with Jiri Bilek I found that MISODM_S has to be set. In the documentation for the ESP32 (should have a very similar SPI interface) I found that also MOSIDN_S should be set in SPI1C2. The MISO timing is correct, I tested it for a clock of 4 MHZ and 320 kHz. With experiments I found that also the timing of MOSI is robust. Neither a delay of 70 ns in SCK nor in MOSI did disturb the communication. Some oscillograms are here: http://homepage.o2mail.de/g.ackermann/hspi_slave.htm Jiri Bilek added the ICACHE_RAM_ATTR to the function hspi_slave_setStatus() because this function may be indirect called from an interrupt handler.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,7 +92,7 @@ void hspi_slave_begin(uint8_t status_len, void * arg) | |
| SPI1S1 = (((status_len * 8) - 1) << SPIS1LSTA) | (0xff << SPIS1LBUF) | (7 << SPIS1LWBA) | (7 << SPIS1LRBA) | SPIS1RSTA; | ||
| SPI1P = (1 << 19); | ||
| SPI1CMD = SPIBUSY; | ||
|
|
||
| SPI1C2=(0x2<<SPIC2MOSIDN_S) | (0x1<<SPIC2MISODM_S); // GuaAck. 30.10.2018; timing of MISO | ||
| ETS_SPI_INTR_ATTACH(_hspi_slave_isr_handler,arg); | ||
| ETS_SPI_INTR_ENABLE(); | ||
| } | ||
|
|
@@ -114,7 +114,7 @@ void hspi_slave_end() | |
| SPI1P = B110; | ||
| } | ||
|
|
||
| void hspi_slave_setStatus(uint32_t status) | ||
| void ICACHE_RAM_ATTR hspi_slave_setStatus(uint32_t status) // GuaAck. 30.10.2018 | ||
|
||
| { | ||
| SPI1WS = status; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.