uarst.c
上传用户:xulicw
上传日期:2014-06-22
资源大小:133k
文件大小:1k
源码类别:

单片机开发

开发平台:

C++ Builder

  1. /************************************************************/
  2. /*          UARST Code for   M32L     */
  3. /*    By   pasyong */
  4. /*    2006-4 */
  5. /*    Base ICC6.31A         */
  6. /************************************************************/
  7. #include <iom32v.h>
  8. #include <macros.h>
  9. #include <stdio.h>
  10. //UART0 initialize
  11. // desired baud rate: 9600
  12. // actual: baud rate:9600 (0.0%)
  13. // char size: 8 bit
  14. // parity: Disabled
  15. void uart0_init(void)
  16. {
  17.  UCSRB = 0x00; //disable while setting baud rate
  18.  UCSRA = 0x00;
  19.  UCSRC = BIT(URSEL) | 0x06;
  20.  UBRRL = 0x2F; //set baud rate lo
  21.  UBRRH = 0x00; //set baud rate hi
  22.  UCSRB = 0x18;
  23. }
  24. //串口输出字符串
  25. void Puts( unsigned char *s)
  26.  while (*s) 
  27.       {
  28.  putchar(*s);
  29.  s++;
  30.       }
  31. }