void ReloadPDMA(void)
{
/* transfer width is half word(16 bit) and transfer count is ADCDatalenght+1 */
PDMA_SetTransferCnt(PDMA, ADC_PDMA_CH, PDMA_WIDTH_16, ADC_DMA_SAMPLE_COUNT);
/* Clear PDMA transfer done interrupt flag */
PDMA_CLR_TD_FLAG(PDMA, ADC_PDMA_OPENED_CH);
}
else if (status & (PDMA_INTSTS_REQTOF1_Msk)) /* Check the DMA time-out interrupt flag */
{
PDMA_CLR_TMOUT_FLAG(PDMA, ADC_PDMA_CH);
printf("REQTOF\r\n");
}
else
{
}
}
void PDMA_Init(void)
{
SYS_ResetModule(PDMA_RST);
/* Configure PDMA peripheral mode form ADC to memory */
/* Open PDMA Channel 1 based on ADC_PDMA_CH setting*/
// PDMA_Open(PDMA, BIT0 << ADC_PDMA_CH);
PDMA_Open(PDMA, 0);
/* transfer width is half word(16 bit) and transfer count is ADCDatalenght+1 */
PDMA_SetTransferCnt(PDMA, ADC_PDMA_CH, PDMA_WIDTH_16, ADC_DMA_SAMPLE_COUNT);
/* Set source address as ADC data register (no increment) and destination address as g_i32ConversionData array (increment) */
PDMA_SetTransferAddr(PDMA, ADC_PDMA_CH, (uint32_t) & (EADC->CURDAT), PDMA_SAR_FIX, (uint32_t)pdmaConvertedData, PDMA_DAR_INC);
/* Waiting for 12MHz clock ready */
CLK_WaitClockReady(CLK_STATUS_HXTSTB_Msk);
/* Set core clock as PLL_CLOCK from PLL */
CLK_SetCoreClock(FREQ_192MHZ);
/* Set PCLK0/PCLK1 to HCLK/2 */
CLK->PCLKDIV = (CLK_PCLKDIV_APB0DIV_DIV2 | CLK_PCLKDIV_APB1DIV_DIV2);
/* Set reference voltage to external pin (3.3V) */
SYS_SetVRef(SYS_VREFCTL_VREF_PIN);
/* Lock protected registers */
SYS_LockReg();
}
/*
* This is a template project for M480 series MCU. Users could based on this project to create their
* own application without worry about the IAR/Keil project settings.
*
* This template application uses external crystal as HCLK source and configures UART0 to print out
* "Hello World", users may need to do extra system configuration based on their system design.
*/
int main()
{
SYS_Init();
/* Init UART to 115200-8n1 for print message */
UART_Open(UART0, 115200);