__RAMFUNC(RAM2) void ADCHS_IRQHandler(void);
void ADCHS_IRQHandler(void)
{
uint32_t sts;
uint32_t triglliaddress, triglli, lastlli,trigaddress;
sts = Chip_HSADC_GetIntStatus(LPC_ADCHS, 1) & Chip_HSADC_GetEnabledInts(LPC_ADCHS, 1);
// Check interrupt caused by threshold crossing
if (sts & ( HSADC_INT1_THCMP_UCROSS(HSADC_CHANNEL))) {
if( adc.ntriggers>0 ) //Ignore the initial forced interrupt
{
int active = adc.active, next = adc.next;
// Grab Current destination address and next LLI for HSADC transfer
trigaddress = LPC_GPDMA->CH[HSADC_GDMA_CH].DESTADDR;
triglliaddress = LPC_GPDMA->CH[HSADC_GDMA_CH].LLI; // Address to Next LLI in CHain
// Calculate when to finish post-fill and switch buffers
triglli = ( triglliaddress - (uint32_t) &HSADC_DMA_LLI[active][0] ) / 16; // LLI Descriptor is 16 bytes
lastlli = (triglli + s.postsegs);
// Check whether last LLI rolls over
if(lastlli >= RX_SUBBUFF_NUM) lastlli = lastlli-RX_SUBBUFF_NUM;
// Flag that the ADC has Triggered
adc.triggered = 1;
// Once trailing sub-buffers are filled the DMA will switch to the start of the
// second buffer and trigger an interrupt
HSADC_DMA_LLI[active][lastlli].ctrl |= GPDMA_DMACCxControl_I;
HSADC_DMA_LLI[active][lastlli].lli = HSADC_DMA_LLI[next][0].lli;
// Store the Trigger Position Info
adc.triglli = triglli;
adc.lastlli = lastlli;
adc.triglliaddress = triglliaddress;
adc.trigaddress = trigaddress;
adc.trig = ((uint32_t)adc.trigaddress - (uint32_t)&dataRx[active][0][0] ) / 2;
// Disable Interrupts
Chip_HSADC_ClearIntStatus(LPC_ADCHS, 1, sts);
Chip_HSADC_DisableInts(LPC_ADCHS, 1, (HSADC_INT1_THCMP_UCROSS(HSADC_CHANNEL)));
adc.trigfin=1; // Flag Trigger Interrupt Finished
}
else{
Chip_HSADC_ClearIntStatus(LPC_ADCHS, 1, sts);
}
}
else{
Chip_HSADC_ClearIntStatus(LPC_ADCHS, 1, sts);
}
adc.ntriggers++;
}
|
Original Attachment has been moved to: 4MHz_SineBurst_40MSps_Triggered.txt.zip
Original Attachment has been moved to: 4MHz_SineBurst_60MSps_Triggered.txt.zip
Original Attachment has been moved to: 4MHz_SineBurst_80MSps_Triggered.txt.zip
while (adc.prefilled == 0); |
while (adc.prefilled == 0) {
sts = Chip_HSADC_GetIntStatus(LPC_ADCHS, 1) & Chip_HSADC_GetEnabledInts(LPC_ADCHS, 1);
} |