Skip to content

JUMPS inside macro doesn't work #8

Closed
@feuerrot

Description

@feuerrot

Code

#include "soc/soc_ulp.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/rtc_io_reg.h"
#include "soc/rtc_i2c_reg.h"
#include "soc/sens_reg.h"
#include "soc/soc.h"

.macro WAIT_SEC
        # waits for about 1s.

        STAGE_RST

bar:    WAIT    65535 # maximum according to TRM 29.4.10 - ca. 8.1ms
        STAGE_INC       1

        JUMPS   bar, 122, EQ # ~999.4ms + 122*4 cycles
.endm

.text
init:
        // rtc_gpio_init(GPIO_NUM_4)
        WRITE_RTC_FIELD(RTC_IO_TOUCH_PAD0_REG, RTC_IO_TOUCH_PAD0_MUX_SEL, 1)
        WRITE_RTC_FIELD(RTC_IO_TOUCH_PAD0_REG, RTC_IO_TOUCH_PAD0_FUN_SEL, 0)

        // rtc_gpio_set_direction(GPIO_NUM_4, RTC_GPIO_MODE_OUTPUT_ONLY);
        // rtc_gpio_output_enable(GPIO_NUM_4);
        WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TS_REG, RTC_GPIO_ENABLE_W1TS_S + 10, 1, 1)
        WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TC_REG, RTC_GPIO_ENABLE_W1TC_S + 10, 1, 0)

        # initialize counter
        JUMP    toggle


toggle:
        WRITE_RTC_REG(RTC_GPIO_OUT_W1TS_REG, RTC_GPIO_OUT_DATA_W1TS_S + 10, 1, 1)
        STAGE_RST

0:      WAIT    65535 # maximum according to TRM 29.4.10 - ca. 8.1ms
        STAGE_INC       1

        JUMPS   0b, 122, EQ # ~999.4ms + 122*4 cycles
        WRITE_RTC_REG(RTC_GPIO_OUT_W1TC_REG, RTC_GPIO_OUT_DATA_W1TC_S + 10, 1, 1)

        WAIT_SEC

        jump toggle

What do I expect:

The output of RTC GPIO 10 aka GPIO 4 stays high for about a second and then low for about a second.

What do I get:

error
The output of RTC GPIO 10 stays high for about a second and then low for about 8ms => probably for the WAIT 65535 inside the macro and a few additional cycles.
So it seems that JUMPS inside the macro WAIT_SEC doesn't work, which seems to be an issue with the binutils.

I am using the most recent binutils version (esp32ulp-elf-binutils-linux64-d2ae637d.tar.gz).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions