/*---------------------------------------------------------------------------------------------------------*/
/* */
/* Copyright(c) 2015 Nuvoton Technology Corp. All rights reserved. */
/* */
/*---------------------------------------------------------------------------------------------------------*/
//***********************************************************************************************************
// Nuvoton Technology Corp.
// E-mail: MicroC-8bit@nuvoton.com
//***********************************************************************************************************
// Application : UART Function
// RXD => P1.1 ; TXD => P1.0 (default)
//
// Output : UART receive a byte and transmit the same byte to PC
//***********************************************************************************************************
//------------------------- <<< Use Configuration Wizard in Context Menu >>> --------------------------------
// <o0.6> UART pin Select
// <0=> Select P1.0, P1.1 as UART pin(default)
// <1=> Select P2.6, P2.7 as UART pin(28 pin only)
//-------------------------------- <<< end of configuration section >>> -------------------------------------
#define Uart_Port_Sel 0x00
#include <stdio.h>
#include "N79E715.h"
#include "Typedef.h"
#include "Define.h"
#include "Common.h"
#include "Delay.h"
#include "Version.h"
UINT8 u8Uart_Data;
//-----------------------------------------------------------------------------------------------------------
void main (void)
{
AUXR1 |= Uart_Port_Sel; // Select P10/P11 as UART pin(default)
InitialUART0_Timer1(9600); // 9600 Baud Rate [url=home.php?mod=space&uid=72445]@[/url] 11.0592MHz
Show_Version_Number_To_PC();
printf ("\n*===================================================================");
printf ("\n* Name: N79E715 Series UART Sample Code.");
printf ("\n*===================================================================");
printf ("\n UART receive a byte and transmit the same byte to PC.\n");
ES = 1; // Enable serial interrupt
EA = 1; // Enable global interrupt
while(1); // Endless
}
//-----------------------------------------------------------------------------------------------------------
void UART_ISR(void) interrupt 4
{
if (RI == 1)
{ // If reception occur
RI = 1; // Clear reception flag for next reception
u8Uart_Data = SBUF; // Read receive data
SBUF = u8Uart_Data; // Send back same data on UART
}
else TI = 0; // If emission occur
// Clear emission flag for next emission
}
//-----------------------------------------------------------------------------------------------------------
|