| Electronic Components Datasheet Search |
|
PIC18F010 Datasheet(PDF) 53 Page - Microchip Technology |
|
|
|||||||||||||||||||||||||||||
PIC18F010 Datasheet(HTML) 53 Page - Microchip Technology |
|
53 / 176 page ![]() 2001 Microchip Technology Inc. Preliminary DS41142A-page 51 PIC18F010/020 EXAMPLE 6-2: PROGRAM MEMORY WRITE This example will buffer a segment of memory, modify one word in the buffer, erase the segment row, and write the buffer back to memory. MOVLW 32 ; number of bytes in row MOVWF COUNTER MOVLW BUFFER_ADDR_HIGH ; point to buffer MOVWF FSR0H MOVLW BUFFER_ADDR_LOW ; MOVWF FSR0L MOVLW CODE_ADDR_UPPER ; Load TBLPTR with the base MOVWF TBLPTRU ; address of the memory row MOVLW CODE_ADDR_HIGH ; MOVWF TBLPTRH ; MOVLW CODE_ADDR_LOW ; MOVWF TBLPTRL ; READ_ROW TBLRD*+ ; read into TABLAT, and inc MOVF TABLAT, W ; get data MOVWF POSTINC0 ; store data DECFSZ COUNTER ; done? GOTO READ_ROW ; repeat MODIFY_WORD MOVLW DATA_ADDR_HIGH ; point to buffer MOVWF FSR0H MOVLW DATA_ADDR_LOW ; MOVWF FSR0L MOVLW NEW_DATA_LOW ; update buffer word MOVWF POSTINC0 MOVLW NEW_DATA_HIGH MOVWF INDF0 ERASE_ROW MOVLW CODE_ADDR_UPPER ; Load TBLPTR with the base MOVWF TBLPTRU ; address of the memory row MOVLW CODE_ADDR_HIGH ; MOVWF TBLPTRH ; MOVLW CODE_ADDR_LOW ; MOVWF TBLPTRL ; BSF EECON1,WREN ; enable write to memory BSF EECON1,FREE ; Enable Row Erase operation BSF EECON1,EEPGD ; Point to FLASH program memory MOVLW 55h MOVWF EECON2 ; write 55H MOVLW AAh MOVWF EECON2 ; write AAH BSF EECON1,WR ; start erase (CPU stall) WRITE_BUFFER_BACK MOVLW 8 ; number of write buffer groups of 4 bytes MOVWF COUNTER_HI MOVLW BUFFER_ADDR_HIGH ; point to buffer MOVWF FSR0H MOVLW BUFFER_ADDR_LOW ; MOVWF FSR0L TBLRD*- ; back the TBLPTR up one PROGRAM_LOOP MOVLW 4 ; number of bytes in write buffer MOVWF COUNTER |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |