Hi, I'm trying to better understand how ADC FIFO works. I was able to make the 'S32K312 PIT BTCU parallel ADC FIFO DMA DS3.5 RTD300' example working on sdk5.0.0. I was then trying to modify it as I have ADC1 and ADC0 using different number of channels :
ADC0
ADC 1
I created two trigger event with same pit source and two DMA channels (one for FIFO1 and the other for FIFO2). BTCU has been set as following:
The code compile and both callback functions are called:
void BctuWatermarkNotif_2(void)
{
result2[0] = (uint16_t) (BctuDmaFifo2[0]&0xFFFF)>>3;
val2[0] = ((float) result2[0]/ adcMax) * (ADC_VREFH - ADC_VREFL);
result2[1] = (uint16_t) (BctuDmaFifo2[1]&0xFFFF)>>3;
val2[1] = ((float) result2[1]/ adcMax) * (ADC_VREFH - ADC_VREFL);
result2[2] = (uint16_t) (BctuDmaFifo2[2]&0xFFFF)>>3;
val2[2] = ((float) result2[2]/ adcMax) * (ADC_VREFH - ADC_VREFL);
}
void BctuWatermarkNotif_1(void)
{
result1[0] = (uint16_t) (BctuDmaFifo1[0]&0xFFFF)>>3;
val1[0] = ((float) result1[0]/ adcMax) * (ADC_VREFH - ADC_VREFL);
result1[1] = (uint16_t) (BctuDmaFifo1[1]&0xFFFF)>>3;
val1[1] = ((float) result1[1]/ adcMax) * (ADC_VREFH - ADC_VREFL);
result1[2] = (uint16_t) (BctuDmaFifo1[2]&0xFFFF)>>3;
val1[2] = ((float) result1[2]/ adcMax) * (ADC_VREFH - ADC_VREFL);
result1[3] = (uint16_t) (BctuDmaFifo1[3]&0xFFFF)>>3;
val1[3] = ((float) result1[3]/ adcMax) * (ADC_VREFH - ADC_VREFL);
}
but valx[] array does not contain correct values, look like they are shifting.
here some screenshot:
I have attached the source code.
Can you please provide some information about how fix it ?
Can I use a single FIFO when adc0 and 1 use a different number of channels?
Thanks in advance.
regards
Hi@PaoloRB
1.I have checked your code , the watermask value is wrong in your code.
Please refer to below modification.
2.Can I use a single FIFO when adc0 and 1 use a different number of channels?
Yes, this can be done via "Adc Target Mask", for example, in your case, you can set i to 0b011,
then adc0 and adc1 will be work in parallel and trigger on same trigger source and the data
can be save to fifo1 or fifo2 as you like.