JZ2440串口

JZ2440串口

JZ2440串口

JZ2440串口

JZ2440串口

//115200,8,n,1

void uart0_init()

{

     //GPH2,3用于TXD0,RXD0

     GPHCON &= ~((3<<4) |(3<<6));

     GPHCON |= ((2<<4) | (2<<6));

     //使能内部上拉

     GPHUP &= ~((1<<2) |(1<<3)); 

 

     //设置波特率

     //UBRDIVn = (int)( UART clock / ( buad ratex 16) ) –1

    //   = 50000000 / (115200 * 16) - 1

    //   = 26

    UBRDIV0 = 26;

 

     UCON0 = 0x5;

     ULCON0 = 0x3;

}

int putchar(int c)

{

     /* UTRSTAT0 */

     /* UTXH0 */

 

     while (!(UTRSTAT0 & (1<<2)));

     UTXH0 = (unsigned char)c;

    

}

 int puts(const char *s)

{

     while (*s)

     {

              putchar(*s);

              s++;

     }

}


相关文章:

  • 2021-05-09
  • 2021-05-31
  • 2021-09-12
  • 2021-11-19
  • 2021-08-07
猜你喜欢
  • 2022-01-04
  • 2021-11-22
  • 2021-12-23
  • 2021-07-08
  • 2021-10-30
  • 2021-05-27
  • 2022-12-23
相关资源
相似解决方案