f_14_15_eetst.c

来自「* Use 10 MHz crystal frequency. * Use 」· C语言 代码 · 共 53 行

C
53
字号
#include "config.h"#include "serial.c"#include "serio.c"#include "delay.h"#include "ee_module.c"#define BUFSIZE 64unsigned char buf[BUFSIZE];void main(void){  unsigned char c, cnt, addr,mode, *s;  serial_init(95,1); // 19200 in HSPLL mode, crystal = 7.3728 MHz  addr = 0;  pcrlf();  printf("PIC18 On-board EEPROM R/W Test");  pcrlf();  while(1){    pcrlf();    printf("Enter 'w' for write mode, else read: ");    c=getche();  pcrlf();    if (c != mode) addr=0; //reset address    mode = c;    if (mode == 'w') {      printf("Enter string, %d chars max: ",BUFSIZE);      pcrlf();      s = buf; cnt = 0;      do { // get a string	c = getche();	if (c != 0x0D) {	  *s = c; s++; cnt++;	}      }while(c != 0x0D);      *s = 0; s++;cnt++;      pcrlf();      if (eedata_writestr(buf,addr)) {	printf("Write unsuccessful!"); pcrlf();      }      addr = addr + cnt;    } else {      // read a string from EEPROM      addr = eedata_readstr(buf,addr,BUFSIZE);      printf("String read: %s",buf);      pcrlf();    }  }}                    

⌨️ 快捷键说明

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