I get frequency results with an ADC reading from ULP 74kHz with 240MHz and 50kHz with 160MHz. As far as I imagine, this should not happen for the simple fact that the ULP cclock is "fixed" ~8MHz.
The code used to read the frequency of the ADC is a simple pin toggle interrupted by the WAKE of the ULP, see codes:
Code: Select all
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();
void IRAM_ATTR wk(void*z)
{
(*(volatile uint32_t *)(GPIO_OUT_REG)) ^= (1<<2);
}
extern "C" void app_main()
{
REG_WRITE(GPIO_ENABLE_REG, BIT2);
ulp();
}
void ulp()
{
adc1_config_channel_atten(ADC1_CHANNEL_5, ADC_ATTEN_0db);
adc1_config_width(ADC_WIDTH_12Bit);
adc1_ulp_enable();
rtc_isr_register(wk, NULL, RTC_CNTL_SAR_INT_ST_M);
REG_WRITE(RTC_CNTL_INT_ENA_REG, BIT5);
//esp_sleep_enable_ulp_wakeup();
ulp_load_binary(0, ulp_main_bin_start, (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t));
ulp_run((&ulp_main - RTC_SLOW_MEM) / sizeof(uint32_t));
}
Code: Select all
.bss
.global value
value:.long 0
.text
.global main
main:
move r3, value
jump lop
lop:
adc r0, 0, 5+1
jumpr wkup, 20, lt
jump lop
wkup:
wake
jump lop
Code: Select all
// calibrate 8M/256 clock against XTAL, get 8M/256 clock period
uint32_t rtc_8md256_period = rtc_clk_cal(RTC_CAL_8MD256, 100);
uint32_t rtc_fast_freq_hz = 1000000ULL * (1 << RTC_CLK_CAL_FRACT) * 256 / rtc_8md256_period;