SAMD21 + LowsideCurrentSense

Hello,

I found some time to continue my “holy grail” quest of achieving PWM-synched adc sampling of the current-sense pins. I already had a evsys + interrupt solution, but it was a bit of a hack.

I just pushed new code with a EVSYS + DMAC solution. There are still a lot I don’t like about it. For example, it assumes all PWM are TOP-synchronized. The thing is, it is very hard to acheive whithin the constraints of bothe the event system, the dma and the fact that there is a signle ADC.

In fact I had to “cleverly” use the dma chains to keep everything event-driven.

it’s “easy” (not!) to acheive, e.g.,

TCCN_OVF -> ADC_START (evsys) -> DMA (one pin) -> stop till next OVF

but I want to scan all 3 pins, so I user the ADC’s input scan feature

TCCN_OVF -> ADC_SYNC (evsys)-> DMA (pinA) -> ADC_START (evsys) -> DMA (pinB) -> ADC_START (evsys) -> DMA (pinC) -> stop till next OVF.

yet what I don’t like is that If I use more than one TCCN_OVF, it’s going to become a total mess, and I won’t be able to assume anything on the state of ADC->INPUTCTRL.bit.INPUTOFFSET (which is the ADC scan cursor)

It’s sad because it was very hard to get there. evsys and dmac example floating arounf are much more basic than this.

anyway, not sure where to go with that.

code

1 Like