; 12 juin 2015 ; tourne sur PC ASUS Win 8.1 ; sur Win XP PIV 2,6 Ghz ; 10 aout 2011 velo_11z.asm ; 02 juin 2007 velo_10z.asm misimDE version 1.7.9 ; 12 mai 2005 velo_7z.asm rajout Interrupt sur entree RB0 et interrupt Tmr0 ; 09 sept 2004 velo_6z.asm : modif routine BCD pour ne pas afficher les 0 non significatifs ; et afffichage KMs au format xxxx.x ; 02 sept 2004 ; B0 simule capteur de Tour : ~ 3 impuls par tour de pedale ; 761 tour de pedale pour 1km avec roue de diam 700 ; PI.D= 2,199114858 metre ; rapport 52/16 =3,250 developpé=7,147 M soit 139,9 tours de pedales par KM ; si 3,1 tour volant d'inertie par tour de pedale => 434 impuls= 1km ou 43 impuls=100M ; **** HARDWARE PLUGINS ***** ; simple switch :Port A:3 Raz compteurs ; switch : Port B:0 (Tdp) ; LCD Display : 2x24, Port A:ERS, Port B:7654xxxx ; LED : Port A:4 ;------------------- ; routine LCD 2lignes de 8 car 6 bits I/O : PortB 7 6 5 4 et PortA 0 1 ; inclus routine delai4m.inc @4MHz ; programme simple pour decoder/ lire Telecommande Infrarouge Marantz 5200 ;******************************************************* ; Quartz = 4MHz ; Cycle = 1/Fosc = 1uSec ;******************************************************* include #define misimDE Radix DEC EXPAND  __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC ;*********************************************************** ; Equates, I/O, vars ;********************************************************** OSC_FREQ EQU D'4000000' ; Oscillator Frequency is 4MHz ; constantes a definir dans le programme principal: ; afficheur LCD en mode 4 bits LCD_DATA_TRIS EQU TRISB ; LCD DATA Port B LCD_DATA EQU PORTB ; LCD DATA 11,12,13,14 bits 4,5,6,7 LCD_CTRL_TRIS EQU TRISA ; LCD CTRL Port A LCD_CTRL EQU PORTA ; LCD CTRL 4,5,6 bits 0,1,2 ifdef misimDE LCD_E EQU 2 ; LCD: Ligne de commande de controle de l'afficheur LCD_RW EQU 1 ; LCD: Ligne de Lecture/Ecriture de l'afficheur LCD_RS EQU 0 ; LCD: Ligne de selection de l'afficheur-> RA0 else LCD_E EQU 1 ; LCD: Ligne de commande de controle de l'afficheur LCD_RS EQU 0 ; LCD: Ligne de selection de l'afficheur-> RA0 endif ; misc. LINE1 EQU 0x080 ; Set display to line 1 character 0 LINE2 EQU 0x0C0 ; Set display to line 2 character 0 #DEFINE Led_Hecto PORTA,4 ; led entre RA2 et +5V 1=eteint 0=allumé #DEFINE PinRaz PORTA,3 #DEFINE RAMStart 0x0C ; pour 16F84 #define Tpd1 43 ; impuls pour 100M #define Tpd2 434 ; impuls pour 1Km kms EQU RAMStart hectometre EQU RAMStart+1 count1 EQU RAMStart+2 count2 EQU RAMStart+3 count3 EQU RAMStart+4 LCDtmp EQU RAMStart+5 LCDtmp1 EQU RAMStart+6 ASCII_O EQU RAMStart+7 ; ASCII One's digit to print ASCII_T EQU RAMStart+8 ; ASCII Ten's digit to print ASCII_H EQU RAMStart+9 ; ASCII Hundred's digit to print ; variable pour convertion binaire --> BCD 16bits bdixmil EQU RAMStart+10 bmille EQU RAMStart+11 bcent EQU RAMStart+12 bdix EQU RAMstart+13 bun EQU RAMstart+14 btmp EQU RAMstart+15 ; A counter, used multiple places valx EQU RAMstart+16 val1 EQU RAMstart+18 val2 EQu Ramstart+20 Nt1 EQU RamStart+22 ; Nb de tours de pedale Nt2 EQU RamStart+24 ; Nb de tour de pedale pour Hectometre Nt3 EQU RamStart+26 ; Nb de tour de pedale pour Kms Seconde EQU RamStart+28 CptmS EQU RamStart+29 Minute EQU RamStart+30 Heure EQU RamStart+31 COMND EQu RamStart+32 status_temp EQU RamStart+33 w_temp EQU RAMstart+34 Drapeaux EQU RAMstart+35 reste EQU RAMstart+36 result EQU RAMstart+37 count EQU RAMstart+38 LastRam EQU RAMstart+39 ifNdef misimDE IF ( (LastRam) > 0x4E ) ERROR "Attention debordement zone RAM" ENDIF ENDIF ;*************************** ; Program start ;************************** ORG 0x00 ; RESET vector location RESET GOTO DEBUT ;**************************** org 0x004 ; adresse d'interruption INTERRUPT BCF STATUS, RP0 ; Select bank 0 movwf w_temp ; sauver registre W swapf STATUS , w ; swap status avec résultat dans w movwf status_temp ; sauver status swappé btfsC INTCON,TOIF ; oui, tester si interrupt timer en cours call IT_Timer btfsC INTCON,INTF ; oui, tester si interrupt RB0 en cours call IT_RB0 swapf status_temp,w ;fetch status, reswap nibbles movwf STATUS ;restore status swapf w_temp,f ;swap nibbles in preparation swapf w_temp,w ;for the swap restoration of w retfie ;return from interrupt IT_Timer incf CptmS,F movf Cptms,W ;ifdef misimDE ;sublw 5 ;else sublw 20 ; 20 x 50mS => 1sec ;endif BTFSS STATUS,Z goto IT_T1 incf Seconde,F Clrf Cptms movf Seconde,W sublw 60 BTFSS STATUS,Z goto IT_T2 incf Minute,F Clrf Seconde movf Minute,W sublw 60 BTFSS STATUS,Z goto IT_T3 INCF Heure,F BSF Drapeaux,2 ; moyenne horaire dispo Clrf Minute Goto IT_T4 IT_T1 ; differents sauts pour equilibrer la duree d'interruption goto $+1 Goto $+1 IT_T2 Goto $+1 GOTO $+1 IT_T3 Goto $+1 GOTO $+1 IT_T4 MOVLW 60 MOVWF TMR0 BCF INTCON,TOIF ;raz flag interrupt return IT_RB0 ; incremente compteu ; incf Nt1+1,F ; incremente LSB (compteur Tours de pedale) BTFSC STATUS,Z ; si debordement MSB incf Nt1,F ; BCF INTCON,INTF ;raz flag interrupt return ;============================================================================= ; Table message to display: kept right up front to avoid crossing 0xff boundary ;============================================================================= TABLE_ST ifdef misimDE ADDLW 0xFF ;-1 car PCL incrementé sur instruction MOVWF !!! endif MOVWF PCL MSG_S ; nop <- autre solution rajouter un nop RETLW 'V' RETLW '=' RETLW 0x00 MSG_M RETLW 'M' RETLW '=' RETLW 0x00 MSG_U RETLW 'T' RETLW '=' RETLW 0x00 MSG_N RETLW 'N' RETLW '=' RETLW 0x00 MSG_K RETLW 'K' RETLW '=' RETLW 0x00 ;************************************************************ ; Initialize processor registers ;*********************************************************** DEBUT ; POWER_ON Reset (Beginning of program) CLRF STATUS ; Do initialization, Select bank 0 CLRF INTCON ; Clear all int-flags, Disable inte rrupts CLRF PCLATH ; Keep in lower 2KByte CLRF PORTA ; ALL PORT outputs should output Lo w. CLRF PORTB ; Effacer registres RAM ; ------------ movlw 0x0c ; initialisation pointeur movwf FSR ; pointeur d'adressage indirect init1 clrf INDF ; effacer ram incf FSR,f ; pointer sur suivant btfss FSR,6 ; tester si fin zone atteinte (>=40) goto init1 ; non, boucler btfss FSR,4 ; tester si fin zone atteinte (>=50) goto init1 ; non, boucler bank1 MOVLW B'00001000' ; RA 4-2-1-0 outputs RA3 input MOVWF TRISA MOVLW 0x0F ; RB 7-6-5-4 outputs, RB 3-2-1-0 inputs MOVWF TRISB MOVLW B'11000111'; Option register setup: ;1 RB Pullups ;0 interrupt on rising edge RB0 ;0 TMR0 fed from internal clock ;0 incr TMR0 on rising edge RA4 ;0 Assign prescaler to TMR0 ;111 use 1:256 prescaling ratio TMR0 rate MOVWF OPTION_REG bank0 MOVLW B'00110000' ;Intcon Register: ;0 GIE Disable interrupts ;0 Disable EEIE EEwrite complete interrupt ;1 Enable TOIE TMR0 Oververflow Interrupt ;1 Enable INTE RBO Interrupt Enable ;0 Disable RBx Port change interrupt ;0 Clear TOIF interrupt flag for TMR0 overflow ;0 Clear INTF interrupt flag bit for RB0 ;0 Clear RBIF interrupt flag for RBx change MoVWF INTCON MOVLW 59 ; 50,17mS MOVWF TMR0 CALL LCD_Init ; Initialize LCDisplay ;============================ Pres bsf Drapeaux,3 ; affichage 00 a 99 2 digits BSF PORTA,4 ; allume led call LCD_Cls clrf btmp MOVLW LINE1 ; CALL LCD_Cde ; Set to first line CLRF btmp Pres1 moVF btmp,w CALL read_EE incf btmp,f ANDLW 0x0FF ; test sur (W) BTFSC STATUS, Z ; zero= fin de message ? GOTO Pres2 Call LCD_Putchar goto Pres1 Pres2 MOVLW LINE2 ; CALL LCD_Cde ; Set to first line movlw EE1-EE0 MOVWF btmp Pres3 movf btmp,w CALL read_EE incf btmp,f ANDLW 0x0FF ; test sur (W) BTFSC STATUS, Z ; zero= fin de message ? GOTO Pres4 Call LCD_Putchar goto Pres3 Pres4 call delay_2_5s call LCD_Clear1 MOVLW LINE1 ; CALL LCD_Cde ; Set to first line movlw EE2-EE0 MOVWF btmp Pres5 movf btmp,w CALL read_EE incf btmp,f ANDLW 0x0FF ; test sur (W) BTFSC STATUS, Z ; zero= fin de message ? GOTO Pres6 Call LCD_Putchar goto Pres5 Pres6 ;ifdef misimDE ;nop ;else CALL delay_2_5s ;endif call LCD_Clear2 call LCD_Clear1 ; bCf PORTA,4 ; allume led CLRF Seconde CLRF INTCON BSF INTCON,INTE BSF INTCON,TOIE ; autorise interruption Timer0 BSF INTCON,GIE ; arme intruuption generale ; CLRF PORTB CLRF PORTA CLRF COMND clrf kms CLRF Hectometre Boucle_ICI TraiteCde BTFSC PORTA,3 ; raz des compteurs ? CALL RazCompteurs MOVf PORTB,W ANDLW 0x0E movwf COMND BTFSS COMND,1 GOTO Trt1 INCF Nt1+1,F ; incremente LSB BTFSC STATUS,C ; si debordement MSB incf Nt1,F Trt1 BTFSS COMND,2 GOTO Trt2 INCF Nt2+1,F BTFSC STATUS,C ; si debordement MSB incf Nt2,F Trt2 BTFSS COMND,3 GOTO Boucle_LA INCF Nt3+1,F ; incremente LSB BTFSC STATUS,C ; si debordement MSB incf Nt3,F Boucle_LA bsf Drapeaux,3 ; affichage 00 a 99 2 digits MOVLW LINE1 CALL LCD_Cde ; Set cursor leftmost on line 1 movf Heure,W call bcd3 movLw 'H' call LCD_Putchar movf Minute,W call bcd3 movLw 'M' call LCD_Putchar movf Seconde,W call bcd3 ;comptage Hectometre call AfficheTDP movf Nt2,W movwf val1 movf Nt2+1,W movwf val1+1 movlw Tpd1/256 movwf val2 movlw (Tpd1-(Tpd1/256)*256) movwf val2+1 call comp_signed16 ; 43 tdp ? Hectometre franchit btfss STATUS,C ; Z=1 si mesure<=consigne btfss STATUS,Z ; Z=1 si mesure = consigne goto Suite1 clrf Nt2 clrf Nt2+1 incf Hectometre,F ; incremente LSB (compteur Kilometre) movlw 0x10 ;Led clignote / hecto metre XORWF PORTA,F Suite1 bCf Drapeaux,3 ; affichage 000 a 255 3 digits movf Nt3,W movwf val1 movf Nt3+1,W movwf val1+1 movlw Tpd2/256 movwf val2 movlw Tpd2-((Tpd2/256)*256) movwf val2+1 call comp_signed16 ;mesure ne pas changer l'ordre des commandes LCD_Cls movlw D'01' ; effacage de l'ecran call LCD_Cde goto delay_2_5ms ;-------------------- LCD_Clear1 ; effacage de la 1ere ligne movlw D'16' movwf LCDtmp1 movlw LINE1 ; 0x80 call LCD_Cde call delay_2_5ms LCDc111 movlw ' ' call LCD_Putchar decfsz LCDtmp1,f goto LCDc111 LCD_Line1 movlw LINE1 call LCD_Cde goto delay_2_5ms ;-------------- LCD_Clear2 ; effacage de la deuxieme ligne movlw D'16' movwf LCDtmp1 movlw LINE2 ; 0xC0 call LCD_Cde call delay_2_5ms LCDcl21 movlw ' ' call LCD_Putchar decfsz LCDtmp1,f goto LCDcl21 LCD_Line2 movlw LINE2 call LCD_Cde goto delay_2_5ms LCD_Home movlw D'02' call LCD_Cde goto delay_2_5ms LCD_Putchar BTFSS Drapeaux,2 goto LCD_P Call write_EEPROM return LCD_P bank0 ; rajout 7/03/03 movwf LCDtmp call delay_1ms movlw 0x0f andwf LCD_DATA,F movf LCDtmp,w andlw 0xF0 iorwf LCD_DATA,F ifdef misimDE bcf LCD_CTRL, LCD_RW nop endif bsf LCD_CTRL, LCD_RS nop bsf LCD_CTRL, LCD_E call delay_25us bcf LCD_CTRL, LCD_E call delay_25us movlw 0x0f andwf LCD_DATA,F swapf LCDtmp,W andlw 0xF0 iorwf LCD_DATA,F nop bsf LCD_CTRL, LCD_E call delay_25us bcf LCD_CTRL, LCD_E call delay_25us return LCD_Init bcf LCD_CTRL, LCD_E nop bcf LCD_CTRL, LCD_RS nop ifdef misimDE bcf LCD_CTRL, LCD_RW endif call delay_2_5ms movlw 0x0f andwf LCD_DATA,F movlw 0x030 ; Commande pour interface 4 bits iorwf LCD_DATA,F bank1 movlw 0x0F andwf LCD_DATA_TRIS,W movwf LCD_DATA_TRIS ; Port en sortie bank0 bsf LCD_CTRL, LCD_E nop bcf LCD_CTRL, LCD_E call delay_2_5ms bsf LCD_CTRL, LCD_E nop bcf LCD_CTRL, LCD_E call delay_2_5ms bsf LCD_CTRL, LCD_E nop bcf LCD_CTRL, LCD_E call delay_100ms ; tempo 100ms , remplace l'attente Wait_Busy de l'afficheur movlw 0x0f andwf LCD_DATA,F movlw 0x020 ; Commande pour interface 4 bits iorwf LCD_DATA,F bsf LCD_CTRL, LCD_E nop bcf LCD_CTRL, LCD_E movlw 0x028 ; Envoi de la commande Fonction 4-bit , Font,Nombre de lignes call LCD_Cde movlw 0x008 ; display off call LCD_Cde movlw 0x00C ; display on (0x00C sans curseur, 0x00E avec, 0x00F clign. ) call LCD_Cde movlw 0x006 LCD_Cde movwf LCDtmp ifdef misimDE call delay_100ms ; tempo 100ms , remplace l'attente Wait_Busy de l'afficheur endif movlw 0x0f andwf LCD_DATA,F movf LCDtmp,w andlw 0xF0 iorwf LCD_DATA,F ifdef misimDE bcf LCD_CTRL,LCD_RW nop endif bcf LCD_CTRL,LCD_RS nop bsf LCD_CTRL,LCD_E nop bcf LCD_CTRL,LCD_E movlw 0x0f andwf LCD_DATA,F swapf LCDtmp,W andlw 0xF0 iorwf LCD_DATA,F bsf LCD_CTRL,LCD_E nop bcf LCD_CTRL,LCD_E return ;----------------------- ;delais4M.inc pour Fquartz=4Mhz ;last update: 28 mars 2003 ;count1 count2 count3 en bank0 pour delay routines ;delay_RS special pour routine d'attente bit 4800 Bauds ;delay : 5(count3-1)+1282(count2-1)+327684(count1-1)+6 ;delay_25us delay_100us delay_200us ;delay_1ms delay2_5ms delay_10ms delay_100ms delay_500ms ;delay_1sec delay_10sec ;--------------------- ;special pour routine d'attente bit 4800 Bauds delay_RS MOVLW 67 ; .67 pour 4800 bauds MOVWF count1 DECFSZ count1,F GOTO $-1 Return ;------------------------ delay movlw 0x001 movwf count1 movlw 0x001 movwf count2 movlw 0x020 movwf count3 delay1 decfsz count3,f goto $-1 decfsz count2,f goto $-3 decfsz count1,f goto $-5 return ;-------------- delay_25us movlw 0x01 movwf count1 movlw 0x01 movwf count2 movlw 5 movwf count3 goto delay1 delay_100us movlw 0x01 movwf count1 movlw 0x01 movwf count2 movlw 20 movwf count3 goto delay1 delay_1ms movlw 0x01 movwf count1 movlw 0x01 movwf count2 movlw 200 movwf count3 goto delay1 delay_2_5ms ifdef misimDE movlw 0x01 movwf count1 movlw 0x01 movwf count2 movlw 5 movwf count3 goto delay1 endif movlw 0x01 movwf count1 movlw 0x02 movwf count2 movlw 243 movwf count3 goto delay1 delay_10ms movlw 0x01 movwf count1 movlw 8 movwf count2 movlw 205 movwf count3 goto delay1 delay_100ms movlw 0x01 movwf count1 movlw 79 movwf count2 movlw 0x01 movwf count3 goto delay1 delay_500ms movlw 2 movwf count1 movlw 135 movwf count2 movlw 106 movwf count3 goto delay1 delay_1s movlw 4 movwf count1 movlw 14 movwf count2 movlw 56 movwf count3 goto delay1 delay_2_5s movlw 8 movwf count1 movlw 161 movwf count2 movlw 218 movwf count3 goto delay1 delay_10s movlw 31 movwf count1 movlw 133 movwf count2 movlw 51 movwf count3 goto delay1 ;----------------------- ; variable pour convertion binaire --> BCD 16bits ;bcent EQU RAMstart+32 ;bdix EQU RAMstart+33 ;bun EQU RAMstart+34 ;btmp EQU RAMstart+35 ;btmp1 EQU RAMstart+36 ;val1 EQU RAMstart+37 ; variable pour stockage valeur 16 bits ;val2 EQU RAMstart+39 ;=============================================== bcd3 movwf btmp ; affichage octet --> decimal 2 ou 3 digits movlw '0' movwf bcent movwf bdix ;bcd31 movlw 100 ; subwf btmp,w ; bnc bcd32 ; movwf btmp ; incf bcent,f ; goto bcd31 bcd32 movlw 0x0A ; 10 subwf btmp,w BTFSS STATUS,C GOTO bcd33 movwf btmp incf bdix,f goto bcd32 bcd33 movlw '0' addwf btmp,w movwf bun movf bcent,W  bTfsS Drapeaux,3 ; 1=affichage 2 digits 0=3 digits call LCD_Putchar movf bdix,w call LCD_Putchar movf bun,w call LCD_Putchar return ; affichage octet --> decimal 5 digits , de 0 a 65535 ; avec blanc sur les chiffres non significatifs ....1 ...1 bcd5V ; bCf Drapeaux,0 movf val1,w movwf valx movf val1+1,w movwf valx+1 swapf val1,w iorlw 0xf0 movwf bmille addwf bmille,f addlw 0xE2 movwf bcent addlw 0x32 movwf bun movf val1,w andlw 0x0F addwf bcent,f addwf bcent,f addwf bun,f addlw 0xE9 movwf bdix addwf bdix,f addwf bdix,f swapf val1+1,w andlw 0x0F addwf bdix,f addwf bun,f rlf bdix,f rlf bun,f comf bun,f rlf bun,f movf val1+1,w andlw 0x0F addwf bun,f rlf bmille,f movlw 0x07 movwf bdixmil movlw 0x0A Lb1: addwf bun,f decf bdix,f btfss STATUS,C goto Lb1 Lb2: addwf bdix,f decf bcent,f btfss STATUS,C goto Lb2 Lb3: addwf bcent,f decf bmille,f btfss STATUS,C goto Lb3 Lb4: addwf bmille,f decf bdixmil,f btfss STATUS,C goto Lb4 movf bdixmil,w BTFSC STATUS,Z BTFSC Drapeaux,0 goto Lb40a movlw ' ' goto Lb40b Lb40a: bsf Drapeaux,0 addlw '0' Lb40b: call LCD_Putchar movf bmille,w BTFSC STATUS,Z BTFSc Drapeaux,0 goto Lb41a movlw ' ' goto Lb41b Lb41a: bsf Drapeaux,0 addlw '0' Lb41b: call LCD_Putchar movf bcent,w BTFSC STATUS,Z BTFSc Drapeaux,0 goto Lb42a movlw ' ' goto Lb42b Lb42a: bsf Drapeaux,0 addlw '0' Lb42b: call LCD_Putchar movf bdix,w BTFSC STATUS,Z BTFSc Drapeaux,0 goto Lb43a BTFSC Drapeaux,1 ; affichage ..0.0 kms Goto Lb43a movlw ' ' Goto Lb43b Lb43a: bsf Drapeaux,0 addlw '0' Lb43b: call LCD_Putchar BTFSS Drapeaux,1 ; affichage ...0.0 kms goto Lb44 ; si Drapeaux ......X. = 1 movlw '.' ; sinon ....0 call LCD_Putchar Lb44: movf bun,w addlw '0' call LCD_Putchar movlw ' ' call LCD_Putchar movf valx,w movwf val1 movf valx+1,w movwf val1+1 BCF Drapeaux,1 return ;------------------- ; voir 84_IRC5_.h pour environnment et variables ;************************************************* ;=========================================================== ; HEX_TO_ASC .. Converts a hex digit to three ASCII characters ; Enter with the hex digit in ASCII_O ; Exit with Hundreds ascii digit in ASCII_H, ; Tens ascii digit in ASCII_T, ; and Ones ascii digit in ASCII_O. ; The incoming byte is not preserved. ;=========================================================== HEX_TO_ASC MOVLW '0' ; Preload a zero into 10's & 100's MOVWF ASCII_T MOVWF ASCII_H DO_100s MOVLW D'100' SUBWF ASCII_O,w ; Subtract 100 to test size BNC DO_10s ; It's less than 100, so branch MOVWF ASCII_O ; It was bigger, so decrement it INCF ASCII_H,f ; Bump up the 100's digit GOTO DO_100s ; Loop again till < 100 DO_10s MOVLW D'10' SUBWF ASCII_O,w ; Subtract 10 to test size BNC ADJUST ; It's less than 10, so branch MOVWF ASCII_O ; It was bigger, so decrement it INCF ASCII_T,f ; Bump up the 10's digit GOTO DO_10s ; Loop again till < 10 ADJUST MOVLW '0' ; The # in ASCII_O is now < 10 ADDWF ASCII_O,f ; Turn it into an ASCII character BLANK_ZEROS MOVLW '0' XORWF ASCII_H,w ; Is the 100's char a 0? BTFSS STATUS,Z GOTO HEX_DONE ; No. MOVLW ' ' ; Yes, MOVWF ASCII_H ; So replace it with a space. MOVLW '0' XORWF ASCII_T,w ; Is the 10's char a 0? BTFSS STATUS,Z GOTO HEX_DONE ; No. MOVLW ' ' ; Yes, MOVWF ASCII_T ; So replace it with a space HEX_DONE RETURN ;******************************************************* read_EE bank0 movwf EEADR ; defini offset addresse bank1 ; 16F84 !!!! bsf EECON1,RD ; mode lecture bank0 ; 16F84 !!!! movf EEDATA,W ; recupere lecture return ;==================== write_EEPROM bank1 bsf EEdata,WREN ; Set the EEPROM write enable bit movlw 0x55 ; Write 0x55 and 0xAA to EEPROM movwf EEadr ; control register, as required movlw 0xAA ; for the write movwf EEadr ; bsf EEdata,WR ; Set WR to initiate write bit_check btfsc EEdata,WR ; Has the write completed? goto bit_check ; No, keep checking bcf EEdata,WREN ; Clear the EEPROM write enable bit bank0 incf EEadr,f ; Increment the EE write address return ; Return to the caller ORG EEPROM ;1234567890123456 EE0 DT "miSimDE 1.7.9",0 EE1 DT "Velo_12z.asm",0 EE2 DT "12 juin 2015",0 EE3 DT "0000.0",0 END