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

📄 flash.c

📁 Hitech microchip PIC C18 Compiler
💻 C
字号:
/*A sample project file to be used with HI-TIDE, to demonstrate the functionality of the microcontroller's FLASH memory.*//*Refer to flash.txt for additional information*//*Source code for flash_read and flash_write routines used in this example is found in ~/PIC18/sources/	 directory*/#include <pic18.h>#include "flash.h"#include <stdio.h>void init(void);volatile bit RESET;volatile const unsigned char old_text[]="Insert text here";	/*this is the variable in FLASH where the old text resides*/unsigned char new_text[]="HI-TECH Software";	/*unlike the old_text this is not a CONST -> stored in data RAM */far unsigned char * source_ptr = (far unsigned char *)new_text;    /*pointers to data*/far unsigned char * dest_ptr = (far unsigned char *)old_text;unsigned char size = sizeof(new_text);						void main(void){    init();	while(1){		printf("\rcode string reads: %s\n",dest_ptr);	/*print the string from flash*/		printf("\rwriting to flash...\n");		flash_write(source_ptr,size,dest_ptr);			/*write to flash memory from data memory */		printf("\rcode string reads: %s\n",dest_ptr);	/*print the string from flash*/		while(!RESET);		RESET=0;	}}void putch(unsigned char c){	while(!TXIF)continue;    TXREG=c;					/*transmit a character to Serial IO */}void init(void){    RBIE=1;            /*enable PORTB interrupts to */    GIEH=1;            /*allow interrupts from PUSH BUTTONS */    GIEL=1;     SPBRG = DIVIDER;       /*enable serial port transmissions */    TXSTA = (SPEED|0x20);  /*and set up BAUD rate generator*/    RCSTA = (0x90);															TRISB=0xF0;        /*use port B inputs for interface*/	TRISC=0x80;	RESET=0;}

⌨️ 快捷键说明

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