Dear Sir,
I been testing my LPC4370 board for a project, encounter a problem that when changing descriptor match number, I did not see the expected effective sampling rate change. below are three cases with match value equal to 80, 160, 1600. they are very similiar.
I have been checking the code many times, couldn't figure out where went wrong. Can anyone give advise, very appreciated ! raymundovelarde I learn many from your posts, say thanks here.
Match = 80 Match = 160
Match = 1600

Test scenario :
/**********************************************************
* SET HSADC Clock to 20MHz
* input signal is 60Hz sin wave
* use interrupt to store 33,332 converted result to SDRAM,
* using different match value to verify match value function
**********************************************************/
Code of HSADC setting is here, full program attached as attachment
void HSADC_Setup(void)
{
uint32_t freqHSADC = 0;
/* HSADC settings */
/* 设定 HSADC Clock = 20MHz */
Chip_USB0_Init();
Chip_Clock_SetDivider(CLK_IDIV_A,CLKIN_USBPLL,2);
Chip_Clock_SetDivider(CLK_IDIV_E, CLKIN_IDIVA, 12);
Chip_Clock_SetBaseClock(CLK_BASE_ADCHS, CLKIN_IDIVE, true, false);
/* Enable HSADC register Clock */
Chip_Clock_EnableOpts(CLK_MX_ADCHS, true, true, 1);
/* Enable HSADC sample Clock */
Chip_Clock_Enable(CLK_ADCHS);
/* 初始化中断设定及状态 */
LPC_ADCHS->INTS[0].CLR_EN = 0x7F; // disable interrupt 0
LPC_ADCHS->INTS[0].CLR_STAT = 0x7F; // clear interrupt status
while(LPC_ADCHS->INTS[0].STATUS & 0x7D); // wait for status to clear, have to exclude FIFO_EMPTY
LPC_ADCHS->INTS[1].CLR_EN = 0x7F;
LPC_ADCHS->INTS[1].CLR_STAT = 0x7F;
while(LPC_ADCHS->INTS[1].STATUS & 0x7D);
/* 初始化HSADC */
LPC_ADCHS->POWER_DOWN = 0;
LPC_ADCHS->FLUSH = 1;
Chip_HSADC_Init(LPC_ADCHS);
/* FIFO interrupt 1, No Packed mode */
Chip_HSADC_SetupFIFO(LPC_ADCHS, 1, false);
/* HSADC starts with Table 0, Descriptor1 */
LPC_ADCHS->DSCR_STS = (1 << 1)| 0;
/*Set Table 0,Desciptor 0 , match no is the test target*/
/* Match value of 80,160,1600 give almost same waveform, very strange */
LPC_ADCHS->DESCRIPTOR[0][0] = (1 << 24) /* RESET_TIMER*/
| (0 << 22) /* THRESH*/
| (1600 << 8) /* set desired MATCH number here */
| (1 << 6) /* BRANCH to First*/
| (1 << 4) /* interrupt when conversion done */;
/* Set descriptor 1 to take a measurement after 0x9A clocks and branch to first descriptor*/
LPC_ADCHS->DESCRIPTOR[0][1] = (1 << 31) /* UPDATE TABLE*/
| (1 << 24) /* RESET_TIMER*/
| (0x9A << 8) /* MATCH ,wait 0x9A for HSADC to stabilize*/
| (0x01 << 6) /* BRANCH to first*/;
LPC_ADCHS->CONFIG = (0x90 << 6) /* RECOVERY_TIME*/
| (0 << 5) /* CHANNEL_ID_EN*/
| (0x01) /* TRIGGER_MASK*/;
/* Setup HSADC interrupts on group 0 - FIFO trip (full), FIFO overrun
error, and descriptor statuses */
Chip_HSADC_EnableInts(LPC_ADCHS, 0, (HSADC_INT0_FIFO_FULL | HSADC_INT0_DSCR_DONE |
HSADC_INT0_FIFO_OVERFLOW | HSADC_INT0_DSCR_ERROR));
/* do not use any bias */
Chip_HSADC_SetACDCBias(LPC_ADCHS, 0, HSADC_CHANNEL_NODCBIAS, HSADC_CHANNEL_NODCBIAS);
/* Configure HSAC power and speed setting and set data format to offset binary */
Chip_HSADC_SetPowerSpeed(LPC_ADCHS, true);
/* Enable HSADC interrupts in NVIC */
NVIC_EnableIRQ(ADCHS_IRQn);
/* Enable HSADC Power */
Chip_HSADC_EnablePower(LPC_ADCHS);
Chip_HSADC_UpdateDescTable(LPC_ADCHS,0);
freqHSADC = Chip_HSADC_GetBaseClockRate(LPC_ADCHS);
printf("%5d" , freqHSADC); /* print out CPU base clock, */
}