Well, doenst work too. Variable still in value declared in Ctomtor wrote:Should be e.g.:urbanze wrote:
Code in ulp
.global x
x: .long 0
.global entry
entry:
move r0, x
ld r0, r0, x
add r0, r0, 1
halt
I comment before with another two tests, and anyone doenst worked
.global x
x: .long 0
.global entry
entry:
move r1, x // load address of x in r1
ld r0, r1, 0 // load data from x in r0
add r0, r0, 1 // increment r0
st r0,r1,0 // store r0 as new content of x
halt
Images: https://i.imgur.com/0sWX7Z6.png https://i.imgur.com/Tr9yMz7.png
Code in C:
Code: Select all
#include <C:\msys32\ESP32\ESP32\components\arduino\cores\esp32\Arduino.h>
#include <C:\msys32\ESP32\ESP32\components\arduino\libraries\WiFi\src\WiFi.h>
#include <C:\msys32\ESP32\esp-idf\components\freertos\include\freertos\FreeRTOS.h>
#include <C:\msys32\ESP32\esp-idf\components\freertos\include\freertos\task.h>
#include <C:\msys32\ESP32\esp-idf\components\esp32\include\esp_system.h>
#include <C:\msys32\ESP32\esp-idf\components\ulp\include\esp32\ulp.h>
#include <C:\msys32\ESP32\esp-idf\components\ulp\ulp.c>
#include <C:\msys32\ESP32\ESP32\build\main\ulp_main.h>
extern uint32_t ulp_x = 3;
extern const uint8_t ulp_main_bin_start[] asm("_binary_ulp_main_bin_start");
extern const uint8_t ulp_main_bin_end[] asm("_binary_ulp_main_bin_end");
void ulp();
extern "C" void app_main()
{
initArduino();
Serial.begin(115200);
ulp();
Serial.printf("\nClock:%d RAM: %d", ESP.getCpuFreqMHz(), ESP.getFreeHeap());
esp_deep_sleep(15000000);
}
void ulp()
{
Serial.printf("\nULP_X: %d", ulp_x & UINT16_MAX);
delay(100);
ulp_load_binary(0, ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t));
ulp_run((&ulp_entry - RTC_SLOW_MEM) / sizeof(uint32_t));
delay(100);
Serial.printf("\nULP_X: %d", ulp_x & UINT16_MAX);
}
Code: Select all
.global x
x: .long 0
.global entry
entry:
move r1, x // load address of x in r1
ld r0, r1, 0 // load data from x in r0
add r0, r0, 1 // increment r0
st r0,r1,0 // store r0 as new content of x
halt