📄 f_14_18_flashtst.c
字号:
#include "config.h"#include "serial.c"#include "serio.c"#include "delay.h"#include "flash_module.c"#define BUFSIZE 64char buf[BUFSIZE];// address to write to in program memory#define FLASH_BUF 0x3F80// put this string in program memory, 'const' does it for PICC18, 'rom const' does it for MCC18#if defined(__18CXX)rom #endif const char test_string[]="Test of 'const' string in program memory";long flash_ptr;void main(void){ unsigned char c, mode; char *s; serial_init(95,1); // 19200 in HSPLL mode, crystal = 7.3728 MHz pcrlf(); printf("PIC18 On-board FLASH R/W Test"); pcrlf(); flash_ptr = FLASH_BUF; while(1){ pcrlf(); printf("'w' (write),'t' (read const. string), 'r'(read): "); c=getche(); pcrlf(); mode = c; if (mode == 'w') { flash_ptr = FLASH_BUF; printf("Enter string, %d chars max: ",BUFSIZE); pcrlf(); s = buf; do { // get a string c = getche(); if (c != 0x0D) { *s = c; s++; } }while(c != 0x0D); *s = 0; s++; pcrlf(); if (flash_writebuf(flash_ptr,buf)) { printf("Write unsuccessful!"); pcrlf(); } } else if (mode == 't' || mode == 'r'){ if (mode == 't') flash_ptr = (long) &test_string[0]; else flash_ptr = FLASH_BUF; // read from flash memory flash_readstr(buf,flash_ptr,BUFSIZE); printf("String read: %s",buf); pcrlf(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -