port.#1

来自「采用CYGNAL F015单片机」· #1 代码 · 共 36 行

#1
36
字号
//-----------------------------------------------------------------------------
// PORT_Init
//-----------------------------------------------------------------------------
//
// Configure the Crossbar and GPIO ports
//
#include <i2c.h>							// SFR declarations
void PORT_Init (void)
{
   XBR0    = 0x04;                     // Enable UART0
   XBR1    = 0x00;
   XBR2    = 0x40;                     // Enable crossbar and weak pull-ups
   PRT0CF |= 0x01;                     // enable TX0 as a push-pull output
   PRT0CF |= 0x40;                     // enable P1.6 (LED) as push-pull output
  // P 1^6 = 1 ;
}

//-----------------------------------------------------------------------------
// UART0_Init
//-----------------------------------------------------------------------------
//
// Configure the UART using Timer1, for <baudrate> and 8-N-1.
//
void UART0_Init (void)
{
   SCON    = 0x50;                     // SCON: mode 1, 8-bit UART, enable RX
   TMOD    = 0x20;                     // TMOD: timer 1, mode 2, 8-bit reload
   TH1    = SYSCLK/BAUDRATE/16;     // set Timer1 reload value for baudrate
   TL1=TH1
   TR1    = 1;                         // start Timer1
   CKCON |= 0x10;                      // Timer1 uses SYSCLK as time base
   PCON  |= 0x00;                      // SMOD = 1
   //TI0     = 1;                         // Indicate TX ready
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?