-->
Page 1 of 1

What SPI mode will applied when calling SPI.begin()?

PostPosted: Tue Mar 14, 2023 6:19 am
by Sean Wang
We know SPI has some configurations. For example, there are 4 combinations of clock phase and polarity, the number of data bits, shift direction(MSB or LSB first). I want to know what configurations will be applied when calling SPI.begin().

Re: What SPI mode will applied when calling SPI.begin()?

PostPosted: Thu Apr 27, 2023 7:00 am
by rooppoorali
As far as I know, when calling SPI.begin() on an ESP8266, the SPI configuration is set to the following default values:

Clock phase: 0 (data is sampled on the leading edge of the clock pulse)
Clock polarity: 0 (the clock is low when idle)
Data bits: 8 bits per transfer
Bit order: MSB first (most significant bit is transmitted first)
Clock frequency: 4 MHz

Re: What SPI mode will applied when calling SPI.begin()?

PostPosted: Fri May 19, 2023 1:54 am
by leoa69
Sean Wang wrote:We know SPI has some configurations. For example, there are 4 combinations of clock phase and polarity, the number of data bits, shift direction(MSB or LSB first). I want to know what configurations will be applied when calling SPI.begin().


The SPI mode applied when calling SPI.begin() depends on the specific library or framework you are using. However, in most cases, the default SPI mode is Mode 0 (CPOL = 0, CPHA = 0). This means that the clock polarity (CPOL) is set to 0, indicating that the idle state of the clock is low, and the clock phase (CPHA) is set to 0, meaning that data is sampled on the leading (first) edge of the clock signal.

It's important to consult the documentation or reference of the library or hardware you are using to confirm the default SPI mode or to check if there are options to specify a different mode when calling SPI.begin().