/*---------------------------------------------------------------------------------------------------------*/
/* */
/* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved. */
/* */
/*---------------------------------------------------------------------------------------------------------*/
//***********************************************************************************************************
// Website: http://www.nuvoton.com
// E-Mail : MicroC-8bit@nuvoton.com
//***********************************************************************************************************
//***********************************************************************************************************
// File Function: ML51 simple GPIO toggle out demo code
//***********************************************************************************************************
#include "ML51.h"
/**
* [url=home.php?mod=space&uid=247401]@brief[/url] UART2 TXD output demo
* @param None
* [url=home.php?mod=space&uid=266161]@return[/url] None
* [url=home.php?mod=space&uid=1543424]@Details[/url] conned UART2 and UART0 to loop check.
*/
void main (void)
{
#if 0 /* UART2*/
unsigned char temp=0x30;
MFP_P21_UART2_TXD;
P21_QUASI_MODE;
UART_Open(24000000,UART2,115200); /* Open UART2 use timer1 as baudrate generate and baud rate = 115200*/
MFP_P30_UART0_RXD;
P30_QUASI_MODE;
UART_Open(24000000,UART0_Timer1,115200); /* Open UART0 use timer1 as baudrate generate and baud rate = 115200 */
while(1)
{
UART_Send_Data(UART2,temp);
temp = UAR67T_Receive_Data(UART0); /* connect P5.4 and P3.0 to check receive data from UART0. */
temp++; /* loop out ascii code. */
Timer3_Delay(24000000,128,500,1000);
}
#endif
#if 1
/* UART2 lower power run mode*/
unsigned char temp=0x50;
MFP_P21_UART2_TXD;
P21_QUASI_MODE;
set_SC0CR0_SCEN; /* Enable SC module */
set_SC0CR1_UARTEN; /* set as UART mode */
set_SC0CR1_CLKKEEP;
clr_SC0CR0_CONSEL; /* clr CONSEL and AUTOCEN*/
clr_SC0CR0_AUTOCEN;
SC0ETURD0 = 0x07; /* define baud rate low byte */
SC0ETURD1 = 0x00; /* define baud rate high byte */
set_SC0CR1_PBOFF; //parity bit disable
SC0CR1&=0XCF; //datalegth 8bit
set_SC0CR0_NSB; //stop bit = 1bit
// SFRS =1;
// TA=0xAA;
// TA=0x55;
// LVRDIS = 0x5A;
// TA=0xAA;
// TA=0x55;
// LVRDIS = 0xA5;
// TA=0xAA;
// TA=0x55;
// PORDIS = 0x5A;
// TA=0xAA;
// TA=0x55;
// PORDIS = 0xA5;
FsysSelect(FSYS_LIRC);
set_PCON_LPR;
while(1)
{
UART_Send_Data(UART2,temp);
// Timer0_Delay(38400,1,1000);
}
#endif
}
|