61a communicates with RS232 of the PC and receives messages in an interrupted manner.

Source: Internet
Author: User

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 ");}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.