How can I reset internal counter in RMT channels?
Posted: Sat Dec 30, 2017 5:25 am
Hi, I'm trying to set precise delay between two RMT channels which are set as continuous mode (RMT_CHnCONF1_REG.RMT_TX_CONTI_MODE_CHn = 1).
I supposed that I can reset RMT channels' internal timers/counters by the following code. But I failed to reset them. So far, this code can change delay between 2 channels. But it seems that it changes the timing randomly. Generated signal is still same as before calling this code though.
I supposed that I can reset RMT channels' internal timers/counters by the following code. But I failed to reset them. So far, this code can change delay between 2 channels. But it seems that it changes the timing randomly. Generated signal is still same as before calling this code though.
Code: Select all
const rmt_channel_t channel0 = RMT_CHANNEL_0;
const rmt_channel_t channel1 = RMT_CHANNEL_1;
void resetRmtChannels() {
auto& confA = RMT.conf_ch[channel0].conf1;
auto& confB = RMT.conf_ch[channel1].conf1;
confA.tx_conti_mode = 0; // Clear continuous mode flag
confB.tx_conti_mode = 0;
confA.tx_start = 0; // Stop TX
confB.tx_start = 0;
confA.ref_cnt_rst = 1; // Reset counter
confB.ref_cnt_rst = 1;
confA.mem_rd_rst = 1; // Reset reading address
confB.mem_rd_rst = 1;
confA.tx_conti_mode = 1; // Set continuous mode flag
confB.tx_conti_mode = 1;
confA.tx_start = 1; // Start TX
confB.tx_start = 1;
}