[DemoCode下载] ML51的Print使用方法

[复制链接]
 楼主| xinxianshi 发表于 2020-7-21 21:16 | 显示全部楼层 |阅读模式
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /*                                                                                                         */
  3. /* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved.                                         */
  4. /*                                                                                                         */
  5. /*---------------------------------------------------------------------------------------------------------*/

  6. //***********************************************************************************************************
  7. //  Website: http://www.nuvoton.com
  8. //  E-Mail : MicroC-8bit@nuvoton.com
  9. //***********************************************************************************************************

  10. #include "ML51.h"

  11. /**
  12. * [url=home.php?mod=space&uid=247401]@brief[/url]       UART0 setting as prinrf output.
  13. * @param       None
  14. * [url=home.php?mod=space&uid=266161]@return[/url]      None
  15. * [url=home.php?mod=space&uid=1543424]@Details[/url]     purchar.c setting use UART0, or use keil default.
  16. */

  17. void main (void)
  18. {
  19.        
  20. /**
  21. For UART0 P3.1 asTXD output setting
  22. * include uart.c in Common Setting for UART0
  23. */
  24.                 MFP_P16_UART0_TXD;                                                                                                                        // UART0 TXD use P5.3
  25.                 P16_QUASI_MODE;                                                                                                                           // set P5.3 as Quasi mode for UART0 trasnfer

  26. /**
  27. For UART0 initial setting
  28. * include uart.c in Common Setting for UART0
  29. */
  30.                 UART_Open(24000000,UART0_Timer1,115200);                                // Open UART0 use timer3 as baudrate generate and baud rate = 115200en(24000000,UART0_Timer1,115200);       
  31.                 ENABLE_UART0_PRINTF;                                                                                                                                                // printf must first set TI =1;
  32.                
  33. /**
  34.         UART1 loop test
  35.         UART1 TXD1 send data received by RXD1 pin. Connect TXD1 pin and RXD1 pin check result.
  36. */
  37.                 while(1)
  38.                 {
  39. //                        printf ("\n hello world! " );
  40.                         printf ("a" );
  41.                         Timer2_Delay(24000000,128,1000,1000);
  42.                 }

  43. }




 楼主| xinxianshi 发表于 2020-7-21 21:17 | 显示全部楼层
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /*                                                                                                         */
  3. /* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved.                                         */
  4. /*                                                                                                         */
  5. /*---------------------------------------------------------------------------------------------------------*/

  6. //***********************************************************************************************************
  7. //  Website: http://www.nuvoton.com
  8. //  E-Mail : MicroC-8bit@nuvoton.com
  9. //***********************************************************************************************************

  10. #include "ML51.h"

  11. /**
  12. * @brief       UART1 use as printf.
  13. * @param       None
  14. * @return      None
  15. * @details     None
  16. */


  17. void main (void)
  18. {

  19. /**
  20. For UART1 P2.3 as TXD1 / P2.3 as RXD1 GPIO setting
  21. * include gpio.c in Common Setting for UART0
  22. */
  23.     MFP_P23_UART1_TXD;                              // UART0 TXD use P0.5
  24.     P23_QUASI_MODE;                                 // set P0.5 and P0.6 as Quasi mode for UART0 trasnfer
  25. /**
  26. For UART1 initial setting
  27. * include uart.c in Common Setting for UART0
  28. */
  29.     UART_Open(24000000,UART1,115200);              // Open UART0 use timer1 as baudrate generate and baud rate = 115200en(24000000,UART0_Timer1,115200);        // Open UART0 use timer1 as baudrate generate and baud rate = 115200
  30.     set_S1CON_TI_1;                                // printf must first set TI_1 =1;
  31.    
  32. /**
  33.   UART1 loop test
  34.   UART1 TXD1 send data received by RXD1 pin. Connect TXD1 pin and RXD1 pin check result.
  35. */
  36.     while(1)
  37.     {
  38.       printf ("\n hello world! " );
  39.       Timer2_Delay(24000000,128,1000,1000);        //Means timer base 24MHz, divider 128, delay time 100 ms (100000us)
  40.     }
  41. }
wanduzi 发表于 2020-7-21 21:37 | 显示全部楼层
这个延时函数能否不这么复杂。
wanduzi 发表于 2020-7-21 21:38 | 显示全部楼层
太复杂了。
mintspring 发表于 2020-7-22 22:47 | 显示全部楼层
可以可以。
幸福小强 发表于 2020-7-23 18:06 | 显示全部楼层
看看有啥特别的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

102

主题

1019

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部

102

主题

1019

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部