#define PLLCTL_SETTING CLK_PLLCTL_72MHz_HXT
#define PLL_CLOCK 72000000
uint32_t volatile u32IsTestOver = 0;
void SYS_Init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
/* Enable HIRC, HXT and LXT clock */
CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);
CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk);
CLK_EnableXtalRC(CLK_PWRCTL_LXTEN_Msk);
/* Wait for HIRC, HXT and LXT clock ready */
CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);
CLK_WaitClockReady(CLK_STATUS_HXTSTB_Msk);
CLK_WaitClockReady(CLK_STATUS_LXTSTB_Msk);
/* Select HCLK clock source as HIRC and and HCLK clock divider as 1 */
CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKDIV0_HCLK(1));
/* Set core clock as PLL_CLOCK from PLL */
CLK_SetCoreClock(PLL_CLOCK);
CLK_EnableModuleClock(UART0_MODULE);
CLK_EnableModuleClock(PDMA_MODULE);
/*---------------------------------------------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*---------------------------------------------------------------------------------------------------------*/
/* Set PD multi-function pins for UART0 RXD and TXD */
SYS->GPD_MFPL &= ~(SYS_GPD_MFPL_PD0MFP_Msk | SYS_GPD_MFPL_PD1MFP_Msk);
SYS->GPD_MFPL |= (SYS_GPD_MFPL_PD0MFP_UART0_RXD | SYS_GPD_MFPL_PD1MFP_UART0_TXD);
}
uint16_t usart_dma_buf[100]= {0x00};
uint8_t PDMA_TEST_LENGTH=100;
int main()
{
int8_t item[100];
uint8_t i;
/* Unlock protected registers */
SYS_UnlockReg();
SYS_Init();
/* Lock protected registers */
SYS_LockReg();
UART_Open(UART0, 115200);
for(i=0; i<100; i++)
{
usart_dma_buf[i]=i;
}
PDMA_Open(0x4);
PDMA_SetTransferCnt(2, PDMA_WIDTH_8, PDMA_TEST_LENGTH);
/* transfer width is one word(32 bit) */
PDMA_SetTransferAddr(2, (uint32_t)(&usart_dma_buf[PDMA_TEST_LENGTH]), PDMA_SAR_INC, UART0_BASE, PDMA_DAR_FIX);
PDMA_SetTransferMode(2, PDMA_UART0_TX, FALSE, 0);
//burst size is 4
PDMA_SetBurstType(2, PDMA_REQ_SINGLE, 0);
PDMA_EnableInt(2, PDMA_INT_TRANS_DONE);
NVIC_EnableIRQ(PDMA_IRQn);
UART0->INTEN|=UART_INTEN_TXPDMAEN_Msk;
u32IsTestOver=0;
Delay_Init();
EXTI_Init();
printf("\r\n");
while(u32IsTestOver == 0);
if(u32IsTestOver == 1)
printf("test done...\r\n");
else if(u32IsTestOver == 2)
printf("target abort...\r\n");
printf("Simple Demo Code\r\n");
printf("Please Input Any Key\r\n");
GPIO_SetMode(PC, BIT9, GPIO_MODE_OUTPUT);
while(1)
{
/* Get input character */
scanf("%s",item);
/* Print input character back */
printf("%s\r\n", item);
}
}
void PDMA_IRQHandler(void)
{
uint32_t status = PDMA_GET_INT_STATUS();
if (status & 0x1) { /* abort */
printf("target abort interrupt !!\n");
if (PDMA_GET_ABORT_STS() & 0x4)
u32IsTestOver = 2;
PDMA_CLR_ABORT_FLAG(PDMA_ABTSTS_ABTIFn_Msk);
} else if (status & 0x2) { /* done */
if ( PDMA_GET_TD_STS() & (1 << 2)) {
u32IsTestOver = 1;
PDMA_CLR_TD_FLAG(PDMA_TDSTS_TDIFn_Msk);
}
} else if (status & 0x300) { /* channel 2 timeout */
printf("timeout interrupt !!\n");
u32IsTestOver = 3;
PDMA_CLR_TMOUT_FLAG(0);
PDMA_CLR_TMOUT_FLAG(1);
} else
printf("unknown interrupt !!\n");
}
按照例程写了一个串口DMA,UART0_TX的DMA,使能了中断,运行时也能进到中断,检测到了发送完成的标志,但是电脑的调试助手收不到DMA发送的数据,调试的数据都能收到,收到的数据如下图所示:
请问下这个问题怎么解决!
|