Strange behaviour of DAC cosine wave generator
Posted: Mon Mar 22, 2021 4:31 pm
Hi all,
I'm using the DAC cosine wave generator as documented here: https://docs.espressif.com/projects/esp ... or_enablev
I am not able to get a 100KHz output, it maxes out at about 55KHz. It is claimed that the max frequency should be 100KHz, as mentioned here: https://docs.espressif.com/projects/esp ... ig_t4freqE
However, the freq member of the dac_cw_config_t struct has tricky wording in the documentation:
Also, the offset setting is strange as well. I would like no offset, so i set offset to zero in the dac_cw_config_t struct. See relevant docs here: https://docs.espressif.com/projects/esp ... _t6offsetE
However, it seems that setting offset to zero results in a rather high offset, actually the same as the max offset of 128. Setting offset to 1 or -1 returns the wave to roughly where it should be given those offsets.
Here is the code:
Any insights to the strange frequency and offset behaviour? Should I revert to I2S driven DAC for now to get higher output frequencies and stable offset behaviour?
Thank you!
I'm using the DAC cosine wave generator as documented here: https://docs.espressif.com/projects/esp ... or_enablev
I am not able to get a 100KHz output, it maxes out at about 55KHz. It is claimed that the max frequency should be 100KHz, as mentioned here: https://docs.espressif.com/projects/esp ... ig_t4freqE
However, the freq member of the dac_cw_config_t struct has tricky wording in the documentation:
So maybe the promised 100KHz max is a typo, and the max is actually 55KHz as would be suggested by the max value of the freq member (55000). Is this true?Set frequency of cosine wave generator output. Range: 130(130Hz) ~ 55000(100KHz).
Also, the offset setting is strange as well. I would like no offset, so i set offset to zero in the dac_cw_config_t struct. See relevant docs here: https://docs.espressif.com/projects/esp ... _t6offsetE
However, it seems that setting offset to zero results in a rather high offset, actually the same as the max offset of 128. Setting offset to 1 or -1 returns the wave to roughly where it should be given those offsets.
Here is the code:
Code: Select all
void app_main(void)
{
dac_cw_config_t dac_cw_config = {
.en_ch = DAC_CHANNEL_1,
.scale = DAC_CW_SCALE_1,
.phase = DAC_CW_PHASE_180,
.freq = 55000,
.offset = 127
};
printf("Hello world!\n");
dac_cw_generator_config(&dac_cw_config);
dac_output_enable(DAC_CHANNEL_1);
dac_cw_generator_enable();
while (true) {
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
Thank you!