ST R2, R1, 0 // write value of R2 into the third array element,\r
// i.e. array[2]\r
\r
+Note about instruction execution time\r
+-------------------------------------\r
+\r
+ULP coprocessor is clocked from RTC_FAST_CLK, which is normally derived from the internal 8MHz oscillator. Applications which need to know exact ULP clock frequency can calibrate it against the main XTAL clock::\r
+\r
+ #include "soc/rtc.h"\r
+\r
+ // calibrate 8M/256 clock against XTAL, get 8M/256 clock period\r
+ uint32_t rtc_8md256_period = rtc_clk_cal(RTC_CAL_8MD256, 100);\r
+ uint32_t rtc_fast_freq_hz = 1000000ULL * (1 << RTC_CLK_CAL_FRACT) * 256 / rtc_8md256_period;\r
+\r
+ULP coprocessor needs 2 clock cycle to fetch each instuction (fetching is not pipelined), plus certain number of cycles to execute, depending on the instruction. See description of each instruction for details on the execution time.\r
+\r
+Note that when accessing RTC memories and RTC registers, ULP coprocessor has lower priority than the main CPUs. This means that ULP coprocessor execution may be suspended while the main CPUs access same memory region as the ULP.\r
+\r
+\r
**NOP** - no operation\r
----------------------\r
\r
-**Syntax:**\r
+**Syntax**\r
**NOP**\r
-**Operands:**\r
+**Operands**\r
None\r
-**Description:**\r
+**Cycles**\r
+ 2 (fetch) + 1 (execute)\r
+**Description**\r
No operation is performed. Only the PC is incremented.\r
\r
**Example**::\r
**ADD** - Add to register\r
-------------------------\r
\r
-**Syntax:**\r
+**Syntax**\r
**ADD** *Rdst, Rsrc1, Rsrc2*\r
\r
**ADD** *Rdst, Rsrc1, imm*\r
\r
\r
-**Operands:**\r
+**Operands**\r
- *Rdst* - Register R[0..3]\r
- *Rsrc1* - Register R[0..3]\r
- *Rsrc2* - Register R[0..3]\r
- *Imm* - 16-bit signed value\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
\r
-**Description:**\r
+**Description**\r
The instruction adds source register to another source register or to a 16-bit signed value and stores result to the destination register.\r
\r
**Examples**::\r
**SUB** - Subtract from register\r
--------------------------------\r
\r
-**Syntax:**\r
+**Syntax**\r
**SUB** *Rdst, Rsrc1, Rsrc2*\r
\r
**SUB** *Rdst, Rsrc1, imm*\r
\r
-**Operands:**\r
+**Operands**\r
- *Rdst* - Register R[0..3]\r
- *Rsrc1* - Register R[0..3]\r
- *Rsrc2* - Register R[0..3]\r
- *Imm* - 16-bit signed value\r
\r
-**Description:**\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
+**Description**\r
The instruction subtracts the source register from another source register or subtracts 16-bit signed value from a source register, and stores result to the destination register.\r
\r
-**Examples:**::\r
+**Examples**::\r
\r
1: SUB R1, R2, R3 //R1 = R2 - R3\r
\r
**AND** - Logical AND of two operands\r
-------------------------------------\r
\r
-**Syntax:**\r
+**Syntax**\r
**AND** *Rdst, Rsrc1, Rsrc2*\r
\r
**AND** *Rdst, Rsrc1, imm*\r
\r
-**Operands:**\r
+**Operands**\r
- *Rdst* - Register R[0..3]\r
- *Rsrc1* - Register R[0..3]\r
- *Rsrc2* - Register R[0..3]\r
- *Imm* - 16-bit signed value\r
\r
-**Description:**\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
+**Description**\r
The instruction does logical AND of a source register and another source register or 16-bit signed value and stores result to the destination register.\r
\r
-**Example**::\r
+**Examples**::\r
\r
1: AND R1, R2, R3 //R1 = R2 & R3\r
\r
\r
**OR** *Rdst, Rsrc1, imm*\r
\r
-\r
**Operands**\r
- *Rdst* - Register R[0..3]\r
- *Rsrc1* - Register R[0..3]\r
- *Rsrc2* - Register R[0..3]\r
- *Imm* - 16-bit signed value\r
+\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
\r
**Description**\r
The instruction does logical OR of a source register and another source register or 16-bit signed value and stores result to the destination register.\r
- *Rsrc2* - Register R[0..3]\r
- *Imm* - 16-bit signed value\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Description**\r
The instruction does logical shift to left of source register to number of bits from another source register or 16-bit signed value and store result to the destination register.\r
\r
*Rsrc2* - Register R[0..3]\r
*Imm* - 16-bit signed value\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Description**\r
The instruction does logical shift to right of source register to number of bits from another source register or 16-bit signed value and store result to the destination register.\r
\r
- *Rsrc* – Register R[0..3]\r
- *Imm* – 16-bit signed value\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Description**\r
The instruction move to destination register value from source register or 16-bit signed value.\r
\r
- *Rdst* – Register R[0..3], address of the destination, in 32-bit words\r
- *Offset* – 10-bit signed value, offset in bytes\r
\r
+**Cycles**\r
+ 2 (fetch) + 4 (execute)\r
+\r
**Description**\r
The instruction stores the 16-bit value of Rsrc to the lower half-word of memory with address Rdst+offset. The upper half-word is written with the current program counter (PC), expressed in words, shifted left by 5 bits::\r
\r
\r
*Offset* – 10-bit signed value, offset in bytes\r
\r
+**Cycles**\r
+ 2 (fetch) + 4 (execute)\r
+\r
**Description**\r
The instruction loads lower 16-bit half-word from memory with address Rsrc+offset into the destination register Rdst::\r
\r
- EQ – jump if last ALU operation result was zero\r
- OV – jump if last ALU has set overflow flag\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
\r
**Description**\r
The instruction makes jump to the specified address. Jump can be either unconditional or based on an ALU flag.\r
\r
- *LT* (less than) – jump if value in R0 < threshold\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Description**\r
The instruction makes a jump to a relative address if condition is true. Condition is the result of comparison of R0 register value and the threshold value.\r
\r
- *LT* (less than) – jump if value in stage_cnt < threshold\r
- *GT* (greater than) – jump if value in stage_cnt > threshold\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Description**\r
The instruction makes a jump to a relative address if condition is true. Condition is the result of comparison of count register value and threshold value.\r
\r
**Description**\r
The instruction sets the stage count register to 0\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Examples**::\r
\r
1: STAGE_RST // Reset stage count register\r
**Operands**\r
- *Value* – 8 bits value\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Description**\r
The instruction increments stage count register by given value.\r
\r
**Operands**\r
- *Value* – 8 bits value\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Description**\r
The instruction decrements stage count register by given value.\r
\r
\r
**Operands**\r
No operands\r
+\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Description**\r
- The instruction halt the processor to the power down mode\r
+ The instruction halts the ULP coprocessor and restarts ULP wakeup timer, if it is enabled.\r
\r
**Examples**::\r
\r
- 1: HALT // Move chip to powerdown\r
+ 1: HALT // Halt the coprocessor\r
\r
\r
\r
-**WAKE** – wakeup the chip\r
---------------------------\r
+**WAKE** – Wake up the chip\r
+---------------------------\r
\r
**Syntax**\r
**WAKE**\r
**Operands**\r
No operands\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Description**\r
The instruction sends an interrupt from ULP to RTC controller.\r
\r
**Operands**\r
- *sleep_reg* – 0..4, selects one of ``SENS_ULP_CP_SLEEP_CYCx_REG`` registers.\r
\r
+**Cycles**\r
+ 2 (fetch) + 2 (execute)\r
+\r
**Description**\r
The instruction selects which of the ``SENS_ULP_CP_SLEEP_CYCx_REG`` (x = 0..4) register values is to be used by the ULP wakeup timer as wakeup period. By default, the value from ``SENS_ULP_CP_SLEEP_CYC0_REG`` is used.\r
\r
**Operands**\r
- *Cycles* – number of cycles for wait\r
\r
+**Cycles**\r
+ 2 (fetch) + *Cycles* (execute)\r
+\r
**Description**\r
The instruction delays for given number of cycles.\r
\r
- *Rdst* – Destination Register R[0..3], result will be stored to this register\r
- *Wait_Delay* – number of cycles used to perform the measurement\r
\r
+**Cycles**\r
+ 2 (fetch) + *Wait_Delay* + 3 * TSENS_CLK\r
\r
**Description**\r
The instruction performs measurement using TSENS and stores the result into a general purpose register.\r
- *Sar_sel* – Select ADC: 0 = SARADC1, 1 = SARADC2\r
- *Mux* - selected PAD, SARADC Pad[Mux+1] is enabled\r
\r
+**Cycles**\r
+ 2 (fetch) + 21 + max(1, SAR_AMP_WAIT1) + max(1, SAR_AMP_WAIT2) + max(1, SAR_AMP_WAIT3) + SARx_SAMPLE_CYCLE + SARx_SAMPLE_BIT\r
+\r
**Description**\r
The instruction makes measurements from ADC.\r
\r
- *High*, *Low* — Define range of bits to read. Bits outside of [High, Low] range are masked.\r
- *Slave_sel* - Index of I2C slave address to use.\r
\r
+**Cycles**\r
+ 2 (fetch) + I2C communication time\r
+\r
**Description**\r
``I2C_RD`` instruction reads one byte from I2C slave with index ``Slave_sel``. Slave address (in 7-bit format) has to be set in advance into `SENS_I2C_SLAVE_ADDRx` register field, where ``x == Slave_sel``.\r
8 bits of read result is stored into `R0` register.\r
- *High*, *Low* — Define range of bits to write. Bits outside of [High, Low] range are masked.\r
- *Slave_sel* - Index of I2C slave address to use.\r
\r
+**Cycles**\r
+ 2 (fetch) + I2C communication time\r
+\r
**Description**\r
``I2C_WR`` instruction writes one byte to I2C slave with index ``Slave_sel``. Slave address (in 7-bit format) has to be set in advance into `SENS_I2C_SLAVE_ADDRx` register field, where ``x == Slave_sel``.\r
\r
- *High* – High part of R0\r
- *Low* – Low part of R0\r
\r
+**Cycles**\r
+ 2 (fetch) + 6 (execute)\r
+\r
**Description**\r
The instruction reads up to 16 bits from a peripheral register into a general purpose register: ``R0 = REG[Addr][High:Low]``.\r
\r
- *Low* – Low part of R0\r
- *Data* – value to write, 8 bits\r
\r
+**Cycles**\r
+ 2 (fetch) + 10 (execute)\r
+\r
**Description**\r
The instruction writes up to 8 bits from a general purpose register into a peripheral register. ``REG[Addr][High:Low] = data``\r
\r