/*---------------------------------------------------------------------------------------------------------*/
/* */
/* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved. */
/* */
/*---------------------------------------------------------------------------------------------------------*/
//***********************************************************************************************************
// Website: http://www.nuvoton.com
// E-Mail : MicroC-8bit@nuvoton.com
//***********************************************************************************************************
#include "ML51.h"
/**
* [url=home.php?mod=space&uid=247401]@brief[/url] PDMA receiv from UART2(SC0) RX demo.
* @param None
* [url=home.php?mod=space&uid=266161]@return[/url] None
* [url=home.php?mod=space&uid=1543424]@Details[/url] after PDMA transfer done UART2 RX data in XRAM 0x100 start area.
*/
unsigned char xdata RxDatabuffer[100] _at_ 0x100;
unsigned char ct;
void PDMA0_ISR(void) interrupt 20 // Vector [url=home.php?mod=space&uid=72445]@[/url] 0xA3
{
PDMA_Close(PDMA0);
SFRS=0;DMA0TSR=0;
printf (" \n PDMA receiv UART2 RX finish! " );
}
void main (void)
{
/* Enable UART0 for printf function*/
MFP_P31_UART0_TXD;
P31_QUASI_MODE;
UART_Open(24000000,UART0_Timer3,115200);
ENABLE_UART0_PRINTF;
/* Enable UART2 RX */
MFP_P55_UART2_RXD;
P55_INPUT_MODE;
UART_Open(24000000,UART2,115200);
/* Clear XRAM base address area to 00h */
for(ct=0;ct<10;ct++)
{
RxDatabuffer[ct]=0;
}
/* Define PMDA function as UART RX to memory, define base address and PDMA receive length */
PDMA_Open(PDMA0,SMCRX,0x100,100);
/* Define interrupt after full transfer */
PDMA_Interrupt_Enable(PDMA0,PDMAFULLINT);
/* Global interrupt enable */
ENABLE_GLOBAL_INTERRUPT;
/* Start PDMA transfer */
PDMA_Run(PDMA0);
while(1);
}
|