How ist SPI managed in ESP32

Recurrent H/W and software problems
Post Reply
PPANTHER256
Posts: 13
Joined: Wed Mar 10, 2021 5:45 am
Has thanked: 4 times
Been thanked: 4 times

How ist SPI managed in ESP32

Post by PPANTHER256 »

I have some knot in my brain with SPI.

Example:
sub MCP23S17_WRITE(register, value)
SPI.CSPIN 15
a = SPI.byte(MCP23S17_ADDR)
a = SPI.byte(register)
a = SPI.byte(value)
end sub

How does Annex32 know, that that my desired number of bytes are sent and then drive CS inactive?
In other words, is the CS set and reset after every single byte, or are the bytes clocked out, without toggling the CS pin?
It is ok with TFT, but what happens when the polling of touch interrups my SPI routine?
Annex32 cannot know how much bytes i want to send in an uninterrupted stream, but this is essential for some communications.

tnx for your answer
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: How ist SPI managed in ESP32

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Sep 05, 2021 2:21 pm I have some knot in my brain with SPI.

Example:
sub MCP23S17_WRITE(register, value)
SPI.CSPIN 15
a = SPI.byte(MCP23S17_ADDR)
a = SPI.byte(register)
a = SPI.byte(value)
end sub

How does Annex32 know, that that my desired number of bytes are sent and then drive CS inactive?
In other words, is the CS set and reset after every single byte, or are the bytes clocked out, without toggling the CS pin?
It is ok with TFT, but what happens when the polling of touch interrups my SPI routine?
Annex32 cannot know how much bytes i want to send in an uninterrupted stream, but this is essential for some communications.

tnx for your answer
Hi, the CS is automatically enabled and disabled in each SPI. function/command.
This is explained in the help [Local Link Removed for Guests]
In the example code, the CS is enabled and disabled 3 times (one for each SPI.BYTE() function)
For the exchange of multiple bytes, you can use SPI.HEX$ or SPI.STRING$ or the IOBUFFERS ([Local Link Removed for Guests])
Post Reply