uarst.c

来自「这个是通过51做的SD卡读写和MP3的程序!」· C语言 代码 · 共 33 行

C
33
字号
/************************************************************/
/*		         UARST Code for   M32L					    */
/*				   By   pasyong								*/
/*				   2006-4									*/
/*				   Base ICC6.31A					        */
/************************************************************/
#include <iom32v.h>
#include <macros.h>
#include <stdio.h>

//UART0 initialize
// desired baud rate: 9600
// actual: baud rate:9600 (0.0%)
// char size: 8 bit
// parity: Disabled
void uart0_init(void)
{
 UCSRB = 0x00; //disable while setting baud rate
 UCSRA = 0x00;
 UCSRC = BIT(URSEL) | 0x06;
 UBRRL = 0x2F; //set baud rate lo
 UBRRH = 0x00; //set baud rate hi
 UCSRB = 0x18;
}
//串口输出字符串
void Puts( unsigned char *s)
{ 
	 while (*s) 
      {
	 putchar(*s);
	 s++;
      }
}

⌨️ 快捷键说明

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