打印
[活动]

EFM8BB1测评——串口

[复制链接]
561|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
今天捣鼓了一下串口。
代码:
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <SI_EFM8BB1_Register_Enums.h>
#include "retargetserial.h"
#include "InitDevice.h"

//-----------------------------------------------------------------------------
// SiLabs_Startup() Routine
// ----------------------------------------------------------------------------
// This function is called immediately after reset, before the initialization
// code is run in SILABS_STARTUP.A51 (which runs before main() ). This is a
// useful place to disable the watchdog timer, which is enable by default
// and may trigger before main() in some instances.
//-----------------------------------------------------------------------------
void SiLabs_Startup (void)
{
  // Disable the watchdog here
}

//-----------------------------------------------------------------------------
// Main Routine
//-----------------------------------------------------------------------------
void main (void)
{
   unsigned char inputcharacter;       // Used to store character from UART

   enter_DefaultMode_from_RESET();
   SCON0_TI = 1;                       // This STDIO library requires TI to
                                       // be set for prints to occur
   while (1)
   {
      RETARGET_PRINTF ("\nEnter character: ");
      inputcharacter = getchar();
      RETARGET_PRINTF ("\nCharacter entered: %c", inputcharacter);
      RETARGET_PRINTF ("\n     Value in Hex: %bx", inputcharacter);
   }
}

效果图:

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:绿水本无忧因风皱面,青山原不老为雪白头。

553

主题

3530

帖子

19

粉丝