Code/C-Code/dspic.c
/********************************************************************
This is the DMA interrupt service routine. 
The max number of buffers that can be allocated in dsPIC 
to 1 analog input is 16. So we after every 16 samples for
each of 4 channel is collected this function is called.
Since we require 32 samples for filtering, after every 2 interrupts
the samples are used for filtering.
********************************************************************/
This is the DMA interrupt service routine.
The max number of buffers that can be allocated in dsPIC
to 1 analog input is 16. So we after every 16 samples for
each of 4 channel is collected this function is called.
Since we require 32 samples for filtering, after every 2 interrupts
the samples are used for filtering.
This is the DMA interrupt service routine . The max number of buffers that can be allocated in dsPIC to 1 analog input is 16 . So we after every 16 samples for each of 4 channel is collected this function is called . Since we require 32 samples for filtering after every 2 interrupts the samples are used for filtering .
void __attribute__((interrupt, no_auto_psv)) _DMA0Interrupt(void)
{
	int i = 0;
	for(i=0; i < 16; i++)
	{
		ch0in[i + 16*dma_num] = BufferA[4*i];
		ch1in[i + 16*dma_num] = BufferA[4*i + 1];	
		ch2in[i + 16*dma_num] = BufferA[4*i + 2];
		ch3in[i + 16*dma_num] = BufferA[4*i + 3];
	}
	if(dma_num == 0)
		dma_num = 1;
	else
	{
		dma_num = 0;
		dma_data_avail = 1;
	}
	IFS0bits.DMA0IF = 0; 
}
void __attribute__ ( ( interrupt , no_auto_psv ) ) _DMA0Interrupt ( void ) { int i = 0 ; for ( i = 0 ; i < 16 ; i ++ ) { ch0in [ i + 16 * dma_num ] = BufferA [ 4 * i ] ; ch1in [ i + 16 * dma_num ] = BufferA [ 4 * i + 1 ] ; ch2in [ i + 16 * dma_num ] = BufferA [ 4 * i + 2 ] ; ch3in [ i + 16 * dma_num ] = BufferA [ 4 * i + 3 ] ; } if ( dma_num == 0 ) dma_num = 1 ; else { dma_num = 0 ; dma_data_avail = 1 ; } IFS0bits . DMA0IF = 0 ; }
This is the DMA interrupt service routine.
This is the DMA interrupt service routine .
/* Storing the sensor values in user buffers for filtering */ /* After every 2 interrupts Data is available for filtering */ // Clearing the interrupt flag