ULP Clock issues/details/explanations
Posted: Sun Jan 07, 2018 5:32 pm
1-) Why changing the Main Core clock, is the ULP reading frequency of the ADC also influenced? Since ULP clock is ~8MHz ???
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:
2-) I put a question that could be a correction to the datasheet in the wrong place (pull request in git) (sorry), but the datasheet says that the ULP clock is 8MHz, however, several sites introduce the idea of calibration or frequency checking, assuming it is not 8MHz. In the file RTC.H has a comment about 8.5MHz +-7%.
With this code, the variable returns me 8.833MHz, which is within the range above and well outside the 8MHz of the datasheet. Why does this discrepancy occur between information? What's the true clock of ulp?
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;