⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 l_9_3_autobaud.c

📁 PIC_Hi-Tech_C_Mike_Pearces_I2C_routines Microchi PIC_Hi-Tech C_I2C_for_EEPROM_24LC01B Code
💻 C
字号:
#include "config.h"#include "serial.c"#include "serio.c"// do autobaud detection// prototypesvoid autobuad(void);// HSPLL mode, crystal = 7.3728 MHz // so Fosc = 29,491,200char baud_rate[] = {191,95,47,31,15,7};// enter carriage return repeatedly// to set baud ratevoid autobaud(void){  char i,c,exit;  i=0;  serial_init(baud_rate[i],1);  exit = 0;  while(!exit) {    // wait for character    while (!RCIF);  // check RCIF bit     c = RCREG;    if (FERR || OERR) {      // baud rate too fast, reset      i = 0;      CREN = 0; // clear error      CREN = 1;    }    if (c == 0x0D) { // found baud rate      printf("Found baud rate."); pcrlf();      exit = 1;    } else {      i++;      if (i > 5) i = 0;  // try again      serial_init(baud_rate[i],1);    }  }}  // Try to automatically determine baud rate,// then echovoid main(void){  char c;  autobaud();  while(1){    // do character echo    c = getch();    c++;    putch(c);  }}

⌨️ 快捷键说明

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