Specifications

mikroElektronika | Free Online Book | PIC Microcontrollers | Appendix B: Examples
; loop
banksel ADRESL
movf ADRESL,w ; Lower byte of conversion result is
; copied to W
banksel PORTB
movwf PORTB ; Byte is copied to PORTB
bsf ADCON0,1 ; Starts new conversion
goto loop ; Jump to label "loop"
end ; End of program
EXAMPLE 12
Using EEPROM memory
This example demonstrates write to and read from built-in EEPROM memory. The program works as follows. The main loop
constantly reads EEPROM memory location at address 5 (decimal). This number is displayed on port D. The same loop tests
the state of three push-buttons connected to port A. The push-buttons "INCREMENT" and "DECREMENT" have the same
purpose like in example 7 - increment and decrement the variable "cnt" which is thereafter displayed on port B. The push-
button "MEMO" enables that variable to be written to EEPROM memory. In order to check it, it is enough to press this push-
button and switch off the device. On the next switch on, the program displays the value of the variable on port D (at the
moment of writing, this value was displayed on port B).
http://www.mikroe.com/en/books/picmcubook/appb/ (39 of 54)5/3/2009 11:36:02 AM