> I want to put a few bytes of configuration data in flash memory at > run time and read also. Any small example of code anywhere on > how to do this for a newbie. > TIA > z There are at least 3 ways to do this. The 628 can't write to its own flash memory during normal operation (is that what you mean by 'run time' ?), any data has to be programmed in. The 628 is also unable to directly read data tables (programmed in with DATA statements) in Flash. Some PICs can, eg 16F877 and 18F452. The latter also has table commands for doing this You'll find more information at www.piclist.com ======================================= E&O excepted ======================================= example - retlw. This simple specific example is OK for (short) tables at a fixed location but you need to be aware of boundary issues. This applies when data crosses a page boundary. Say the retlws below were at addresses 04fe 04ff 0500 0501. PC is set to 04 and byte address variable is FE to get the first one, then FF to get the second. Then the byte address variable is incremented to 00. PC is still 04. It should have been incremented to 05 clrf low_add ;byte address within 0800 block d_loop movlw 0x04 ;get data from table at 0x0800 movwf pclath ;set PC to 0800 base movf low_add,w call table ;fetch data into W ;insert code here, do what you need to with the fetched data incf low_add ;increment the byte address btfss low_add,2 ;test if 4 bytes got from table goto d_loop ;no, get another byte of data .........rest of code org 400h ;base address of table table addwf pcl retlw 0x00 retlw 0x01 retlw 0x02 retlw 0x03 ======================================= example - EEPROM written to when PIC is programmed org 0x2100 ;EEPROM address for programmer de 0x00,0x01,0x02,0x03 ;values stored in EEPROM clrf counter ;byte counter e_loop movf counter,w call read_ee ;process data in W incf counter ;loop for 4 bytes btfss counter,2 goto e_loop ........rest of code read_ee banksel eedata ;bank1 movwf eeadr ;set address from W bsf eecon1,rd ;EEPROM read movf eedata,w banksel porta ;bank0 return ;----------------------- ;write to EEPROM yourself using a variable ;insert code to move data into W, then call write .......rest of code ;set EEDATA and EEADR write banksel eedata ;bank1 movwf eedata ;data already in W banksel porta ;bank0 movf eea,w ;eea is a Bank0 variable banksel eedata ;bank1 movwf eeadr ;set address ;write value to EEPROM bcf intcon,gie bsf eecon1,wren movlw 0x55 movwf eecon2 movlw 0xaa movwf eecon2 bsf eecon1,wr ;initiate write bank0 btfss pir1,eeif ;wait for write complete goto $-1 bcf pir1,eeif return -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads