A couple of acronyms to know:
- PMU = Peripheral Management Unit
- ADC = Analog to Digital Converter
The PMU_Start() function expects the descriptor list to be in flash; that’s why it’s declared const. But you can copy the descriptor list to a RAM array and direct it there, the PMU isn’t going to care. Modifying the descriptor directly while it runs should work – but only if the descriptor list is in RAM, not flash.
There’s an alternative – instead of modifying the running PMU program, have the PMU program build a one-descriptor program for a second PMU channel. The one descriptor would be the descriptor that writes the ADC result to memory – just set the STOP bit in the descriptor so that the channel does that one thing then stops. Then, in the first descriptor list, instead of doing a MOVE from the ADC output register to memory, do a WRITE to the PMU control register for channel 2 to kick it off. Now, channel 2 runs, performs the transfer, and halts. Meanwhile, channel 1 waits on the next sample, then writes a new descriptor for channel 2 (with the appropriate increment) and kicks it off again.