I like to sample an analogue mic sample. The sampling should be synced with the I2S master clock. Since I like to do some DSP after, a block of samples should be processed while another block should is sampled. My MCU is a DSPIC33CH128MP205.
So I tried to setup everything but I am still failing.Maybe someone can spot what I am doing wrong here or advise me.
I am using MPLAB with the MCC tool. Here the screenshots of the setup
Some init code:
uint16_t mic_in[64*2];
void DMA_Channel2_CallBack(void) {
if (DMA_IsOperationHalfComplete(DMA_CHANNEL_2)) {
}
if (DMA_IsOperationDone(DMA_CHANNEL_2)) {
}
}
void adc_init(void) {
// ADC1_IndividualChannelInterruptEnable(channel_AN8);
// channel 2 -> ADC channel 8 (RB3) + ADC trigger RB4 -> mic.mic_in
DMA_ChannelDisable(DMA_CHANNEL_2);
DMA_DestinationAddressSet(DMA_CHANNEL_2, (uint16_t) &mic_in[0]);
DMA_SourceAddressSet(DMA_CHANNEL_2, (uint16_t) &ADCBUF8);
DMA_TransferCountSet(DMA_CHANNEL_2, sizeof(mic_in)/sizeof(uint16_t));
DMA_ChannelEnable(DMA_CHANNEL_2);
//DMA_SoftwareTriggerEnable(DMA_CHANNEL_2);
// ADC1_SoftwareTriggerEnable();
ADC1_InterruptFlagClear();
ADC1_Enable();
//ADC1_SharedCorePowerEnable();
}