Добавил:
ИВТ (советую зайти в "Несортированное") Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
interfeysy_1 / ИДЗ_машинка / даташиты / esp32_technical_reference_manual_en.pdf
Скачиваний:
13
Добавлен:
26.01.2024
Размер:
9.62 Mб
Скачать

30 ULP Coprocessor (ULP)

Figure 30­20. Sample of a ULP Operation Sequence

The specific timing of the wakeup, program execution and sleep sequence is governed by the ULP FSM as follows:

1.On the ULP timer expiration the FSM wakes up the ULP and this process takes two clock cycles.

2.Then, before executing the program, the FSM waits for the number of cycles configured in RTC_CNTL_ULPCP_TOUCH_START_WAIT field of the RTC_CNTL_TIMER2_REG register. This time is spent waiting for the 8 MHz clock to get stable.

3.The ULP program is executed.

4.After calling HALT instruction, the program is stopped. The FSM requires additional two clock cycles to put the ULP to sleep.

30.6RTC_I2C Controller

The ULP coprocessor can use a separate I²C controller, located in the RTC domain, to communicate with external I²C slave devices. RTC_I2C has a limited feature set, compared to I2C0/I2C1 peripherals.

30.6.1 Configuring RTC_I2C

Before the ULP coprocessor can use the I²C instruction, certain parameters of the RTC_I2C need to be configured. This can be done by the program running on one of the main CPUs, or by the ULP coprocessor itself. Configuration is performed by writing certain timing parameters into the RTC_I2C registers:

1.Set the low and high SCL half-periods by using RTC_I2C_SCL_LOW_PERIOD_REG and RTC_I2C_SCL_HIGH_PERIOD_REG in RTC_FAST_CLK cycles (e.g. RTC_I2C_SCL_LOW_PERIOD=40, RTC_I2C_SCL_HIGH_PERIOD=40 for 100 kHz frequency).

2.Set the number of cycles between the SDA switch and the falling edge of SCL by using RTC_I2C_SDA_DUTY_REG in RTC_FAST_CLK (e.g. RTC_I2C_SDA_DUTY=16).

3.Set the waiting time after the START condition by using RTC_I2C_SCL_START_PERIOD_REG (e.g. RTC_I2C_SCL_START_PERIOD=30).

4.Set the waiting time before the END condition by using RTC_I2C_SCL_STOP_PERIOD_REG (e.g. RTC_I2C_SCL_STOP_PERIOD=44).

Espressif Systems

668

ESP32 TRM (Version 5.0)

Submit Documentation Feedback

30ULP Coprocessor (ULP)

5.Set the transaction timeout by using RTC_I2C_TIMEOUT_REG (e.g. RTC_I2C_TIMEOUT=200).

6.Enable the master mode (set the RTC_I2C_MS_MODE bit in RTC_I2C_CTRL_REG).

7.Write the address(es) of external slave(s) to SENS_I2C_SLAVE_ADDRn (n: 0-7). Up to eight slave addresses can be pre-programmed this way. One of these addresses can then be selected for each transaction as part of the ULP I²C instruction.

Once RTC_I2C is configured, instructions ULP I2C_RD and I2C_WR can be used.

30.6.2 Using RTC_I2C

The ULP coprocessor supports two instructions (with a single OpCode) for using RTC_I2C: I2C_RD (read) and I2C_WR (write).

30.6.2.1 I2C_RD ­ Read a Single Byte

The I2C_RD instruction performs the following I²C transaction (see Figure 30-21):

1.Master generates a START condition.

2.Master sends slave address, with r/w bit set to 0 (“write”). Slave address is obtained from SENS_I2C_SLAVE_ADDRn, where n is given as an argument to the I2C_RD instruction.

3.Slave generates ACK.

4.Master sends slave register address (given as an argument to the I2C_RD instruction).

5.Slave generates ACK.

6.Master generates a repeated START condition.

7.Master sends slave address, with r/w bit set to 1 (“read”).

8.Slave sends one byte of data.

9.Master generates NACK.

10.Master generates a STOP condition.

Master

Slave

1

START

2

3

4

Slave Address W

 

Reg Address

 

 

ACK

 

 

 

 

5 6

RSTRT

ACK

7

8

9

10

Slave Address R

 

NACK

 

STOP

 

 

 

 

 

 

 

Data

 

 

 

 

 

 

 

 

Figure 30­21. I²C Read Operation

Note:

The RTC_I2C peripheral samples the SDA signals on the falling edge of SCL. If the slave changes SDA in less than 0.38 microseconds, the master will receive incorrect data.

The byte received from the slave is stored into the R0 register.

30.6.2.2 I2C_WR ­ Write a Single Byte

The I2C_WR instruction performs the following I²C transaction (see Figure 30-22):

Espressif Systems

669

ESP32 TRM (Version 5.0)

Submit Documentation Feedback

Соседние файлы в папке даташиты