;30 mars 2013 ; suite remark warning a la compilation ,par Milan Markas (Croatie) ; recompilé avec ; option : /x"$(BINDIR_)$(INFILEBASE).xrf" /aINHX8M ; inclus : errors,warning and messages ; auparavant avec l'option "errors only" ; option : /x"$(BINDIR_)$(INFILEBASE).xrf" /w2 /aINHX8M ; pour faire apparaitre les warning [202] et les corrigere ; ex: movlw 243 -> movlw 43H au lieu de movlw D'243' -> movlw F3h <= OK ; ;@@@ 16 mars 2013 ;version pour LCD 1 ligne de 2x8cars ; modif pour PB affichage 1Hz sans signal sur l'entree ; dans debut "comptage" supprimé la fausse impulsion ; bsf PORTA,2 ;toggle TMR0 pin ; bcf PORTA,2 ; ;1 mars 2013: remis mode 2 lignes LCD en ligne 490: ; movlw 0x028 ; 0b00101000 Fonction 4-bit , Font, Nombre de lignes=2 ;28/02/2013 ; remise en ordre pointeur debut 80H et C0H au lieu de 00H et 40H ;27/02/2013 ; version pour LCD 1 ligne de 2x8 car (et non 16 !) ; Ajust correction +0µS ; affiche 3 999 999 Hz pour 4MHZ automesure ; ; 25/02/2013 modif Titre 1ere ligne LCD ; 23/02/2013 ; Test sous MPLAB sim point d'arret sur ; debut ; 019F 3008 00739 movlw 8 ; 01A0 0686 00740 xorwf PORTB ; clignote Led a chaque boucle ; stimulus de RA4 ON/OFF pour remplacer la liaison RA2 vers RA4 via le NAND 74HCT32 ; 017B 0000 00688 nop ;<- stimulus RA4 ici pour test led avec MPLAB Sim ; Stimulus: SCL file "C:\_Mplab8\_Mesprojets_ASM\_Freq\Freqmeter_Simule_RA2.scl" generated successfully. ; label RA2pulse RA4 LOw 1cy High 2cy Begib at PC=017A ; rev 16/02/2013 Rajout led sur RB3 ; Rappel : POK508 + Bloc alim + IC-Progr 1.05 pour reprogrammer le 16F84 ;14/02/2013 ; montage sur CI et test : automesure sur Quartz 4Mhz -> 4.000.064 Hz ; mesure sur horloge 40MHz -> 40,0011 MHz ; mesure sur 76KHz -> 75999Hz ; rev 7/02/2013 pour pic16F84A ; 26/01/2012 ; quartz PIC : 4Mhz ; modif affichage et usage de 2 gammes ; affichage jusqu'a 7 digits poour F < 9.999.999 Hz ; add corrections = + 20 µS dans la boucle externe "gate" + 16µS en final ;resultats : ; REF Mesure Gamme erreur ;Q=4MHz 4000065 Hz FREQ -0,002% ;25Khz 25000 Hz FREQ 0,000% ;234375Hz 234374 Hz FREQ 0,000% ;Q=60 MHz 59.9993 Mhz VHF 0,001% ;Q=20 Mhz 19,9998 Mhz VHF 0,001% ; ;23/01/2012 ; Rajout diviseur UHF MB506 ( 1/256) => 2 gammes , choix via input RA.1 ; RA.1=1 gamme Freq 1 --- 9,999.999 Hz ; RA.1=0 gamme VHF 10.0000 MHz -- >999.9999 Mhz ; ; avec rajout +20µS dans la boucle de comptage qui passe de 20 a 40µS ; wct7_LCD4bits_Q4Mhz_a.asm ; pour F.input de 60Mhz -> MB506 / 256 => 234.375 Khz Theoriques ; resultats : ; Freq =233.91Khz gamme 1 ; test 60Mhz: VHF = 594.00 Khz (PB de virgule)soit 59.40 Mhz ; ; rajout +21µS dans la boucle de comptage ; wct7_LCD4bits_Q4Mhz_a.asm ; pour F.input de 60Mhz -> MB506 / 256 => 234.375 Khz Theoriques ; resultats : ; Freq =239.73Khz gamme 1 ; VHF = 606.68 Khz ; ;16/01/2012 rajout Freq devant la mesure .. mais =>digit saute en LSB de MHz ; a voir : lecture Hz + 1 ? bug ? ; update 12/01/2012 ; mode LCD 4 bits au lieu de 8 bits ; remplacement des adresses en dur dans le programme , par des labels ;Using TMR0 with External Clock ;paragraph 6.2 specsheet DS30430C page 29 ;Therefore, it is necessary for T0CKI to have a ;period of at least 4Tosc (plus a small RC delay) divided ;by the prescaler value. The only requirement on T0CKI ;high and low time is that they do not violate the ;minimum pulse width requirement of 10 ns. ; ;parameter 40 High pulse width 30nS ;parameter 41 Low pulse width 20nS ;parameter 42 periode (Tcy+40)/N N=prescaler ; La valeur du quartz intervient beaucoup sur la periode mini (42) ; si Q=4Mhz avec Tcy= 4/Fosc=> 1µS ; periode mini = (1000+40)/256= ~4nS soit 250Mhz ; si Q=20Mhz periode mini (200 + 40)/256 => < 1nS ! 1Ghz!? pas glop,il y a VIOL! ; En se basant sur les limites (40 et 41)etat H=30ns + etat L=20ns => periode 50nS ; => 20Mhz ! TRES PLAUSIBLE puisque reellement mesuré (avec quartz de 4Mhz) ; En se basant sur les limites absolues (antiviol!) de 10 + 10 ns=> 20nS ; => 50Mhz, ce qui est decrit dans la note ci-dessous ; note microchip AN592.pdf ;The PIC16C5X has one 8-bit timer (Timer0), which can be used with ;an 8-bit prescaler. The prescaler runs asynchronously, hence it can ;count a very high frequency. The minimum rise and fall times of the input ;frequency are speci?ed to be 10 ns, so the fastest clock rate the TMR0 ;can count is 50 MHz. ; 07 juin 2003 .. testé OK avec Gene a quartz et sur emetteur 27,125Mhz de Radiocommande ; affichage 7 digits mode LCD 8 bits data ; 1hz a 50MHz (theorique) comptage sur 24 bits ; resolution 1Hz ;http://www.piclist.com/techref/piclist/weedfreq/WCT6.htm ;************************************************************* ; FREQUENCY COUNTER ; Model : WTCNT ; Author : Terry J. Weeder ; Date :November 18, 1993 ; Version:1.0 ; WWW.WEEDTECH.COM Ported to 16f84 by Peter Cousens October 1998 ; lines 337 to 453 ..supprimees ;************************************************************* list ERRORLEVEL -302 Processor 16F84A #include <../common/p16F84A_.inc> ; Radix DEC EXPAND __CONFIG 0x3FF1 ; _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC ; --- Hardware --- ; bloc alim KA23D09..9V DC 500mA ; sort 13V a vide ..12,4V sur le frequencemetre ; Quartz 4Mhz encadre de 2x 33pF ; LCD 1x16 PIC16F84 ; 1 0V ; 2 +5V ; 3 R de 390 ohms au 0V ; 4 Enable RA0 pin 17 ; 5 R/W 0V RA1 pin 18 choix de gamme ; 6 RS RA2 pin 1 ; 7 D0 0V RB0 pin 6 not used ; 8 D1 0V RB1 pin 7 not used ; 9 D2 0V RB2 pin 8 not used ; 10 D3 0V RB3 pin 9 --- 750---A Led K ---0V ; 11 D4 RB4 pin 10 ; 12 D5 RB5 pin 11 ; 13 D6 RB6 pin 12 ; 14 D7 RB7 pin 13 ; conditionnement signal ;9 74HCT132 RA2 pin 1 ;12,13,2 74HCT132 RA3 pin 2 ;6 74HCT132 RA4 pin 3 input ;11,10 74HCT132 ;3,4 74HCT132 ;8,5 74HCT132 ;1 74HCT132 1Mohm +5V et 820K 0V C=1µF signal input ;14 74HCT132 +5V ;7 74HCT132 0V FREQ EQU .40000 ; Xtal frequency in kHz LCD_DATA EQU PORTB ; LCD DATA 11,12,13,14 bits 4,5,6,7 LCD_DATA_TRIS EQU TRISB ; LCD_CTRL EQU PORTA ; LCD CTRL 4,5,6 bits 0,1,2 LCD_RS EQU 2 ; LCD pin 4 : Ligne Selection Registres de l'afficheur ;LCD_RW EQU 1 ; LCD pin 5 reliée au 0V (not used) LCD_E EQU 0 ; LCD pin 6 : Ligne ENABLED controle de l'afficheur #define Gamme PORTA,1 ; Choix de gamme 1-20Mhz ou 20-1200MHz #define Led PORTB,3 ; RB3 --750--- Led--0V ind equ 0h TMR0 equ 1h pc equ 2h status equ 3h fsr equ 4h ;port_c equ 7h c equ 0h dc equ 1h z equ 2h pd equ 3h to equ 4h MSB equ 7h LSB equ 0h cnt equ 2h rs equ 2h rw equ 1h e equ 0h o equ 7h RP1 EQU H'0006' RP0 EQU H'0005' STATUS EQU H'0003' OPTION_REG EQU H'0081' TRISA EQU H'0085' TRISB EQU H'0086' EEPROM EQU 0x2100 ;#define TEST_LED ; strap les tempos pour acceler la simulation ;************* ; DATA bank0 ;************* cblock 0x0C gate cnt1 cnt2 cnt3 calc1 calc2 calc3 sum1 sum2 sum3 timer_value PosX ; registres pour les 7 digits c1 c2 c3 c4 c5 c6 c7 count1 count2 count3 count4 Pointer_Msg in_reg addcnt LCDtmp ; save data LCDtmpC ;save Cde LCDtmp1 Dcount1 Dcount2 Dcount3 gate2 dummy endc LastBank0 EQU dummy IF ( LastBank0 >= 0x4F ) ERROR "Attention debordement zone RAM " ENDIF org 0x00 goto start ; org 0x04 nop nop retfie ;**************** ; Tempos ;**************** delay_25us ifdef TEST_LED goto minidelay endif movlw 0x01 movwf Dcount1 movlw 0x01 movwf Dcount2 movlw 0x05 movwf Dcount3 goto delay1 delay_100us ifdef TEST_LED goto minidelay endif movlw 0x01 movwf Dcount1 movlw 0x01 movwf Dcount2 movlw 20 movwf Dcount3 goto delay1 delay_2_5ms ifdef TEST_LED goto minidelay endif movlw 0x01 movwf Dcount1 movlw 0x02 movwf Dcount2 movlw D'243' movwf Dcount3 goto delay1 delay_10ms ifdef TEST_LED goto minidelay endif movlw 0x01 movwf Dcount1 movlw 8 movwf Dcount2 movlw D'205' movwf Dcount3 goto delay1 delay_100ms ifdef TEST_LED goto minidelay endif movlw 0x01 movwf Dcount1 movlw D'79' movwf Dcount2 movlw 0x01 movwf Dcount3 goto delay1 delay_500ms ifdef TEST_LED goto minidelay endif movlw 2 movwf Dcount1 movlw D'135' movwf Dcount2 movlw D'106' movwf Dcount3 goto delay1 delay_3s ifdef TEST_LED goto minidelay endif movlw 10 movwf Dcount1 movlw D'40' movwf Dcount2 movlw D'200' movwf Dcount3 goto delay1 delay1 decfsz Dcount3,f goto $-1 decfsz Dcount2,f goto $-3 decfsz Dcount1,f goto $-5 return minidelay nop nop nop nop return ;********************** ; LCD ;*********************** LCD_Cls clrf PosX movlw D'01' ; effacage de l'ecran call LCD_Cde goto delay_2_5ms ;----------------- LCD_Clear1 ; effacage de la 1ere partie clrf PosX movlw D'8' movwf LCDtmp1 movlw 0x80 ; 1ere partie 2 lines of 16 cars call LCD_Cde call delay_2_5ms LCDc111 movlw ' ' call LCD_Putchar decfsz LCDtmp1,f goto LCDc111 LCD_Line1 movlw 0x80 ;LINE1 sur 2 lines of 16 cars call LCD_Cde clrf PosX goto delay_2_5ms ;-------------- LCD_Clear2 ; effacage de la deuxieme partie clrf PosX movlw D'8' movwf LCDtmp1 movlw 0xC0 ;2em ligne d'un 2x16 car call LCD_Cde call delay_2_5ms LCDcl21 movlw ' ' call LCD_Putchar decfsz LCDtmp1,f clrf PosX goto LCDcl21 LCD_Line2 movlw 0xC0 ;2em ligne call LCD_Cde clrf PosX goto delay_2_5ms LCD_Home movlw D'02' call LCD_Cde clrf PosX goto delay_2_5ms LCD_Putchar bank0 ; rajout 7/03/03 movwf LCDtmp movf PosX,W btfsc PosX,3 ;test si >=8 ??? andlw 0xF7 ; limite deplacement entre 0 et 7 addlw 0x80 ; 80h pour 1ere ligne de 16 car btfss PosX,3 goto Firsthalf addlw 0x40 ;@@@ 80h+40h=C0h 2em ligne 16 cars ou 2em partie pour 2x8 1L Firsthalf call LCD_Cde ; position curseur a PosX call delay_100us movf LCDtmp,W ; recupere data a afficher movlw 0x0f andwf LCD_DATA,F movf LCDtmp,w andlw 0xF0 iorwf LCD_DATA,F ; bcf LCD_CTRL, LCD_RW nop 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 incf PosX,f return LCD_Init bcf LCD_CTRL, LCD_E call delay_2_5ms bcf LCD_CTRL, LCD_RS call delay_2_5ms ; bcf LCD_CTRL, LCD_RW call delay_2_5ms movlw 0x0f andwf LCD_DATA,F movlw 0x030 ; Commande pour interface 4 bits,1 line, Font 5x8 iorwf LCD_DATA,F bank1 movlw 0x0F andwf LCD_DATA_TRIS,W movwf LCD_DATA_TRIS ; Port en sortie bank0 ; valide 3 fois l'envoi de LCD_DATA 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 ;Force le mode 4 Bits 0x02H sur quartet MSB du PortB ;Function SET Commande 0 0 1 DL N F X X avec RS=0 RW=0 ;Upper nibble interface 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 ;Function SET Commande 0 0 1 DL N F X X avec RS=0 RW=0 ;Definit la taille de l'interface (DL=0 pour mode 4 bits, DL=1 pour mode 8 bits), ;le nombre de lignes (NL=0 pour 1 ligne, N=1 pour 2 ou 4 lignes), ;et la taille des fontes (F=0 pour des cars 5x7, F=1 pour des cars 5x10). movlw 0x028 ; 0b00101000 Fonction 4-bit , Font, Nombre de lignes=2 ; movlw 0x020 ; Fonction 4-bit , Font, Nombre de lignes=1 call LCD_Cde ;Display on/off control 0 0 0 0 1 D C B ;affichage (D), curseur (C), clignotement du curseur (B). movlw 0x08 ; display off call LCD_Cde ;Entry mode setting ;Entry mode command " 0 0 0 0 0 1 ID S " ;ID =0 no cursor increment during read and write ;ID =1 cursor increment during read and write ;S =0 no display during read and write ;S =1 display shift movlw 0x0C ; display on (0x0C sans curseur, 0x00E avec , 0x00F clign. ) call LCD_Cde ;if cursor inc and no display shift movlw 0x06 ; LCD_Cde movwf LCDtmpC call delay_100ms ; call delay_100ms remplace l'attente Wait_Busy de l'afficheur movlw 0x0f andwf LCD_DATA,F movf LCDtmpC,w andlw 0xF0 iorwf LCD_DATA,F ; bcf LCD_CTRL,LCD_RW nop bcf LCD_CTRL,LCD_RS nop bsf LCD_CTRL,LCD_E nop bcf LCD_CTRL,LCD_E movlw 0x0f andwf LCD_DATA,F swapf LCDtmpC,W andlw 0xF0 iorwf LCD_DATA,F bsf LCD_CTRL,LCD_E nop bcf LCD_CTRL,LCD_E return sub bcf status,o ;clear overflow bit movf calc1,w ;subtract calc1 from cnt1 subwf cnt1,f btfsc status,c goto sb1 movlw 0x01 ;borrow from cnt2 if overflow subwf cnt2,f btfsc status,c goto sb1 subwf cnt3,f ;borrow from cnt3 if cnt2 overflow btfss status,c bsf status,o ;set overflow bit if result is negative sb1 movf calc2,w ;subtract calc2 from cnt2 subwf cnt2,f btfsc status,c goto sb2 movlw 0x01 ;borrow from cnt3 if cnt2 overflow subwf cnt3,f btfss status,c bsf status,o ;set overflow bit if result is negative sb2 movf calc3,w ;subtract calc3 from cnt3 subwf cnt3,f btfss status,c bsf status,o ;set overflow bit if result is negative retlw 0x00 ; ;--------------------------- add movf calc1,w ;add calc1 to cnt1 addwf cnt1,f btfss status,c goto ad1 incfsz cnt2,f ;add to cnt2 if cnt1 overflow goto ad1 incf cnt3 ,f ;add to cnt3 if cnt2 overflow ad1 movf calc2,w ;add calc2 to cnt2 addwf cnt2,f btfsc status,c incf cnt3,f ;add to cnt3 if cnt2 overflow movf calc3,w ;add calc3 to cnt3 addwf cnt3,f retlw 0x00 ; ;----------------------- cnvt movlw 0x07 ;7 digits in display movwf count1 movlw c1 ;set fsr for MSB in display movwf fsr movlw 0x2F ;one less that ASCII "0" cnvt0 movwf ind incf fsr ,f decfsz count1,f goto cnvt0 movlw 0x0F ;load "1,000,000" in calc1-3 movwf calc3 movlw 0x42 movwf calc2 movlw 0x40 movwf calc1 ;@@@ 16 mars 2013 bcf status,o ; rajout pour PB +1Hz cnvt1 call sub ;subtract number from count incf c1 ,f ;increment 1,000,000's register movlw 0x3A xorwf c1,w btfsc status,z goto overflow btfss status,o ;check if overflow goto cnvt1 call add ;add back last number movlw 0x01 ;load "100,000" in calc1-3 movwf calc3 movlw 0x86 movwf calc2 movlw 0xA0 movwf calc1 cnvt2 call sub ;subtract number from count incf c2 ,f ;increment 100,000's register btfss status,o ;check if overflow goto cnvt2 call add ;add back last number clrf calc3 ;load "10,000" in calc1-3 movlw 0x27 movwf calc2 movlw 0x10 movwf calc1 cnvt3 call sub ;subtract number from count incf c3,f ;increment 10,000's register btfss status,o ;check if overflow goto cnvt3 call add ;add back last number movlw 0x03 ;load "1,000" in calc1-3 movwf calc2 movlw 0xE8 movwf calc1 cnvt4 call sub ;subtract number from count incf c4,f ;increment 1,000's register btfss status,o ;check if overflow goto cnvt4 call add ;add back last number clrf calc2 ;load "100" in calc1-3 movlw 0x64 movwf calc1 cnvt5 call sub ;subtract number from count incf c5 ,f ;increment 100's register btfss status,o ;check if overflow goto cnvt5 call add ;add back number movlw 0x0A ;load "10" in calc1-3 movwf calc1 cnvt6 call sub ;subtract number from count incf c6 ,f ;increment 10's register btfss status,o ;check if overflow goto cnvt6 call add ;add back last number movf cnt1,w ;put remainder in 1's register addwf c7 ,f incf c7 ,f retlw 0x00 ; Comptage bank1 movlw b'00110111' ;0x37 TMR0 = ext, prescaler=1/256 movwf OPTION_REG bank0 bcf PORTA,3 bcf PORTA,2 clrf cnt3 clrf TMR0 clrf timer_value ;@@@ 16 mars 2013 pour PB affiche 1Hz @ zero frequence ; bsf PORTA,2 ;toggle TMR0 pin ; bcf PORTA,2 movf gate,w ;get gate time gate=0x14=20 20x250x20=100.000 cy =>100mS movwf count1 ;si gate= 0xC8 => 100x250x40=1.000.000 cy => 1 sec bsf PORTA,3 ;start count fr4 movlw 0xFA ; 250 was movf gate2,w movwf count2 goto fr6 fr5 goto $+1 ;2 goto $+1 ;4 goto $+1 ;6 goto $+1 ;8 goto $+1 ;10 goto $+1 ;12 goto $+1 ;14 goto $+1 ;16 goto $+1 ;18 goto $+1 ;20 goto $+1 ;22 goto $+1 ;24 goto $+1 ;26 fr6 ;test for TMR0 rollover movf TMR0,w ;27 subwf timer_value ,f ;28 btfss status,z ;29 goto fr7 ;31 nop goto fr8 fr7 btfsc status,c ;32 incf cnt3,f ;33 fr8 movwf timer_value ;34 nop ;35 nop ;36 nop ;37 decfsz count2,f ;38 goto fr5 ;40 goto $+1 ;ajustement ;42µS goto $+1 ;ajustement ;44 goto $+1 ;ajustement ;46 goto $+1 ;ajustement ;48 goto $+1 ;ajustement ;50 goto $+1 ;ajustement ;52 goto $+1 ;ajustement ;54 goto $+1 ;ajustement ;56 goto $+1 ;ajustement ;58 goto $+1 ;ajustement ;60µS ; nop decfsz count1,f ; gate goto fr4 ; ajustement final ; nop ;ajustement +1 ; nop ;ajustement +2 ; nop ;ajustement +3 ; nop ;ajustement +4 ; goto $+1 ;ajustement +6 ; goto $+1 ;ajustement +8 ; goto $+1 ;ajustement +10 ; goto $+1 ;ajustement +12 ; goto $+1 ;ajustement +14 ; goto $+1 ;ajustement +16 ; goto $+1 ;ajustement +18 ; goto $+1 ;ajustement +20 ; goto $+1 ;ajustement +22 ; goto $+1 ;ajustement +24 ; goto $+1 ;ajustement +26 ; goto $+1 ;ajustement +28 bcf PORTA,3 ;stop count movf TMR0,w ;get TMR0 count movwf cnt2 subwf timer_value,f ;test for TMR0 rollover btfss status,c goto fr9 btfss status,z incf cnt3,f fr9 clrf cnt1 ;set to get prescaler count fr10 decf cnt1,f bsf PORTA,2 ;toggle TMR0 pin nop ifdef TEST_LED nop nop nop nop ;<- stimulus RA4 ici pour test led avec MPLAB Sim endif bcf PORTA,2 movf TMR0,w ;test if TMR0 has changed xorwf cnt2,w btfsc status,z goto fr10 retlw 0x00 ; ;******************************************** ; main program start clrf PORTA ;instruction, write, enable low clrf PORTB bank1 movlw b'00010010' ; RA4 & RA1 as input others output movwf TRISA movlw b'00000000' ; all outputs movwf TRISB bank0 bsf PORTB,3 ; allume led call delay_500ms call LCD_Init ; en mode 4 bits call delay_500ms ;1er msg call LCD_Clear1 movlw 0 movwf Pointer_Msg Call AffNumMsgEeprom call delay_3s ; test fontionalite 2x8 car sur 2 Lignes pour simuler un 2x8 car 1 ligne ;looping ; movlw 4 ; movwf PosX ; movlw 'A' ; call LCD_Putchar ; call delay_3s ; movlw 'B' ; call LCD_Putchar ; call delay_3s ; movlw 'C' ; call LCD_Putchar ; call delay_3s ; ; movlw .8 ; movwf PosX ; movlw '1' ; call LCD_Putchar ; call delay_3s ; movlw '2' ; call LCD_Putchar ; call delay_3s ; movlw '3' ; call LCD_Putchar ; call delay_3s ; ; goto looping ;2em msg call LCD_Clear1 movlw 1 movwf Pointer_Msg Call AffNumMsgEeprom call delay_3s ;3em msg call LCD_Clear1 movlw 2 movwf Pointer_Msg Call AffNumMsgEeprom call delay_3s call LCD_Clear1 bcf PORTB,3 ; eteint led debut movlw 8 xorwf PORTB ; clignote Led a chaque boucle call delay_100ms hz movlw D'0' ; 2,56 sec gate '0 equivaut à 256 -1=>255 -1=>254....) si commutateur de gamme RA.1=0 btfsc Gamme ; test RA.1 movlw D'100' ; 1 sec si commutateur de game RA.1=1 movwf gate hz00 call Comptage call cnvt ;convert binary to BCD hz0 Call Entete movlw 4 ; apres "Freq " movwf PosX movlw 0x07 ;output first 7 characters movwf count1 movlw c1 ;MSD of freq movwf fsr hz1 movlw 0x30 ;test if "0" xorwf ind,w btfss status,z goto hz2 movlw ' ' ;0x20 ;change preceeding "0's" to "space" call LCD_Putchar incf fsr,f decfsz count1,f goto hz1 goto hz3 hz2 movf ind,w call LCD_Putchar incf fsr,f btfsc Gamme goto hz21 movlw 0x05 xorwf count1,w btfss status,z goto hz21 movlw '.' call LCD_Putchar hz21 decfsz count1,f goto hz2 hz3 movlw .11 movwf PosX movlw 0x20 ;"space" call LCD_Putchar btfsc Gamme goto hz4 movlw 'M' ;"M" call LCD_Putchar hz4 movlw 'H' ;0x48 ="H" call LCD_Putchar movlw 'z' call LCD_Putchar movlw ' ' ;"space" call LCD_Putchar btfss Gamme goto debut movlw ' ' ;"space" call LCD_Putchar goto debut ; overflow clrf PosX call LCD_Clear1 movlw 3 movwf Pointer_Msg Call AffNumMsgEeprom call delay_3s goto debut ; Entete clrf PosX btfss Gamme ; test position commut. goto Entete2 call LCD_Home movlw 'F' call LCD_Putchar movlw 'r' call LCD_Putchar movlw 'q' call LCD_Putchar return Entete2 call LCD_Home movlw 'V' call LCD_Putchar movlw 'H' call LCD_Putchar movlw 'F' call LCD_Putchar return ; affiche Num Msg en eeprom ; terminaison par caractere null ou taille maxi de 16 cars ;============================== AffNumMsgEeprom movf Pointer_Msg,w movwf cnt2 bcf STATUS,C rlf cnt2,f rlf cnt2,f rlf cnt2,f rlf cnt2,f ; pointeur = Num Msg * 16 clrf cnt3 ; le message commence en position 0 clrf PosX affMsg_ ; sortie si 16em car ou rencontre de zero movf cnt3,w addwf cnt2,w MOVWF EEADR bank1 BSF EECON1,RD ; bit 0 bank0 call delay_100us MOVF EEDATA,W XORLW 0 ; Is this the terminating char? BTFSC STATUS,Z GOTO EndAffNum call LCD_Putchar incf cnt3,f btfss cnt3,4 ; 16em car ? goto affMsg_ EndAffNum return org 0x2100 signature ;1234567890123456 DT "WCT8_LCD 2x8 1L " DT "1-10Mhz 10-999Mz" DT "Rev130330 Nocorr" DT "Overflow ." end ---------------------------------------------------------------------- Release build of project `C:\_Mplab8\_Mesprojets_ASM\_Freq\Freqencemetre.mcp' started. Language tool versions: MPASMWIN.exe v5.49, mplink.exe v4.47, mplib.exe v4.47 Sat Mar 30 14:42:47 2013 ---------------------------------------------------------------------- Clean: Deleting intermediary and output files. Clean: Deleted file "C:\_Mplab8\_Mesprojets_ASM\_Freq\wct8_LCD_16F84A_LCD2x81L_130330.o". Clean: Deleted file "C:\_Mplab8\_Mesprojets_ASM\_Freq\wct8_LCD_16F84A_LCD2x81L_130330.err". Clean: Deleted file "C:\_Mplab8\_Mesprojets_ASM\_Freq\wct8_LCD_16F84A_LCD2x81L_130330.hex". Clean: Deleted file "C:\_Mplab8\_Mesprojets_ASM\_Freq\wct8_LCD_16F84A_LCD2x81L_130330.lst". Clean: Deleted file "C:\_Mplab8\_Mesprojets_ASM\_Freq\wct8_LCD_16F84A_LCD2x81L_130330.xrf". Clean: Deleted file "C:\_Mplab8\_Mesprojets_ASM\_Freq\wct8_LCD_16F84A_LCD2x81L_130330.cof". Clean: Done. Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84A "wct8_LCD_16F84A_LCD2x81L_130330.asm" /l"wct8_LCD_16F84A_LCD2x81L_130330.lst" /e"wct8_LCD_16F84A_LCD2x81L_130330.err" /x"wct8_LCD_16F84A_LCD2x81L_130330.xrf" /aINHX8M Message[305] C:\_MPLAB8\_MESPROJETS_ASM\_FREQ\WCT8_LCD_16F84A_LCD2X81L_130330.ASM 871 : Using default destination of 1 (file). Executing: "C:\Program Files\Microchip\MPASM Suite\mplink.exe" /p16F84A /l"C:\Program Files\Microchip\MPLAB ASM30 Suite\lib" /k"C:\Program Files\Microchip\MPASM Suite\LKR" "wct8_LCD_16F84A_LCD2x81L_130330.o" /z__MPLAB_BUILD=1 /w /o"C:\_Mplab8\_Mesprojets_ASM\_Freq\wct8_LCD_16F84A_LCD2x81L_130330.cof" /x MPLINK 4.47, Linker Device Database Version 1.12 Copyright (c) 1998-2011 Microchip Technology Inc. Errors : 0 Loaded C:\_Mplab8\_Mesprojets_ASM\_Freq\wct8_LCD_16F84A_LCD2x81L_130330.cof. ---------------------------------------------------------------------- Release build of project `C:\_Mplab8\_Mesprojets_ASM\_Freq\Freqencemetre.mcp' succeeded. Language tool versions: MPASMWIN.exe v5.49, mplink.exe v4.47, mplib.exe v4.47 Sat Mar 30 14:42:48 2013 ---------------------------------------------------------------------- BUILD SUCCEEDED