Is there a way to disable and enable the DMA channel so that the channel completely restarts after disabling it?
Currently I have a 2 Teensy 4.1 setup where information is being sent between the two teensy through serial communication using DMA. The DMA is connected to a PIT timer so that the message is sent at a constant rate. Both Teensys are connected to one button. When I press the button, I want both Teensys to stop sending information so that I can change values. Then, when I press the button again, both teensy should immediately start sending messages with the new value. I do this by disabling the DMA channel when the button is pressed the first time, resetting all buffers, and clearing the TX and RX buffers. Then enabling the channel again to start it.
However, it seems that when I press the button the second time to restart the DMA, the channel finishes sending whatever was left in the minor loops of the message from when I stopped the channel and then starts sending the new values after. I use the following code to disable and enable the DMA channel, but is there a way to clear the whole channel when I disable it so it ignores what was in the minor loop and restarts the back to the beginning major loop so that it can immediately sends the new values rather than finishing what was sent?
Currently I have a 2 Teensy 4.1 setup where information is being sent between the two teensy through serial communication using DMA. The DMA is connected to a PIT timer so that the message is sent at a constant rate. Both Teensys are connected to one button. When I press the button, I want both Teensys to stop sending information so that I can change values. Then, when I press the button again, both teensy should immediately start sending messages with the new value. I do this by disabling the DMA channel when the button is pressed the first time, resetting all buffers, and clearing the TX and RX buffers. Then enabling the channel again to start it.
However, it seems that when I press the button the second time to restart the DMA, the channel finishes sending whatever was left in the minor loops of the message from when I stopped the channel and then starts sending the new values after. I use the following code to disable and enable the DMA channel, but is there a way to clear the whole channel when I disable it so it ignores what was in the minor loop and restarts the back to the beginning major loop so that it can immediately sends the new values rather than finishing what was sent?
Code:
void DMAChannel::enable() {
DMA_SERQ = ch;
}
void DMAChannel::disable() {
DMA_CERQ = ch;
}