This article from http://blog.csdn.net/hellogv/
# Include "SPCE061A. H "unsigned int tmp_data; void uart_init () {ASM (" int off "); // disable IRQ and FIQ interruption * p_iob_dir = 0x0400; * p_iob_attrib = 0x0480; * p_iob_data = 0x0000; * p_uart_command1 = c_uart_reset; // UART internal reset * p_uart_baudscalarhigh = 0x05; // The baud rate is set to 9600 * p_uart_baudscalarlow = 0x00; * p_uart_command1 = 0x80; // 1000 0000 allows RX to interrupt * p_uart_command2 = 0xc0; // 1100 0000 control word ASM ("int IRQ"); tmp_data = * p_uart_data; // clear the receiving buffer (required)} Char getdata () {tmp_data = * p_uart_command2; tmp_data = tmp_data & 0x0080; while (tmp_data = 0) {tmp_data = * p_uart_command2; tmp_data = tmp_data & 0x0080; * p_watchdog_clear = c_wdtclr;} return * p_uart_data;} void senddata (char data) {* p_watchdog_clear = 0x0001; tmp_data = * p_uart_command2; tmp_data = tmp_data & 0x0040; // determine whether data transmission is ready while (tmp_data = 0) // wait {tmp_data = * p_uart_command2; tmp_data = tmp_data & 0x0040; * p_watchdog_clear = 0x0001;} * p_uart_data = data; * p_watchdog_clear = 0x0001;} int main () {uart_init (); while (1) {* p_watchdog_clear = c_wdtclr;} return 0;} void irq7 (void) _ attribute _ (ISR); void irq7 (void) {_ ASM ("IRQ off"); senddata (getdata (); // send it back when you receive it _ ASM ("IRQ on ");}