[DemoCode下载] M05开发有模板

[复制链接]
524|3
 楼主| xinpian101 发表于 2019-5-27 19:29 | 显示全部楼层 |阅读模式
  1. /******************************************************************************
  2. * [url=home.php?mod=space&uid=288409]@file[/url]     main.c
  3. * [url=home.php?mod=space&uid=895143]@version[/url]  V1.00
  4. * $Revision: 3 $
  5. * $Date: 14/01/28 11:45a $
  6. * [url=home.php?mod=space&uid=247401]@brief[/url]    Template project for M051 series MCU
  7. *
  8. * @note
  9. * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved.
  10. *****************************************************************************/
  11. #include <stdio.h>
  12. #include "M051Series.h"


  13. void SYS_Init(void)
  14. {
  15.     /* Unlock protected registers */
  16.     SYS_UnlockReg();

  17.     /* Enable IP clock */
  18.     CLK->APBCLK = CLK_APBCLK_UART0_EN_Msk;

  19.     /* Update System Core Clock */
  20.     /* User can use SystemCoreClockUpdate() to calculate SystemCoreClock and cyclesPerUs automatically. */
  21.     SystemCoreClockUpdate();

  22.     /* Set P3 multi-function pins for UART0 RXD and TXD  */
  23.     SYS->P3_MFP = SYS_MFP_P30_RXD0 | SYS_MFP_P31_TXD0;

  24.     /* Lock protected registers */
  25.     SYS_LockReg();

  26. }


  27. int main()
  28. {
  29.     int8_t ch;

  30.     SYS_Init();

  31.     /* Init UART0 to 115200-8n1 for print message */
  32.     UART_Open(UART0, 115200);

  33.     printf("Simple Demo Code\n\n");

  34.     printf("Please Input Any Key\n\n");

  35.     do
  36.     {
  37.         printf("Input: ");
  38.         ch = getchar();
  39.         printf("%c\n", ch);
  40.     }
  41.     while(1);

  42. }

  43. /*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/


 楼主| xinpian101 发表于 2019-5-27 19:29 | 显示全部楼层
一般你就这样,先看看能否跑起来,如果正常,那就接着写自己的代码就行了。
equivalent 发表于 2019-5-29 20:35 | 显示全部楼层
一般新入手一个MCU,都是用官方代码例程点个灯先
稳稳の幸福 发表于 2019-5-29 22:30 | 显示全部楼层
基本的运行代码。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

130

主题

1651

帖子

1

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