LIST P=PIC16f628 #include __CONFIG _BODEN_OFF & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_OFF & _INTRC_OSC_NOCLKOUT ;envoi des mesures de durée (pour mesurer resistance a l'aide condo #DEFINE VERSION "1" ;MASSE -- CONDO -- RESISTANCE -- VCC ; | ; RA3 (entrée du comparateur) #include ;movlf movff movE movwe save_env load_env incEeadr CBLOCK 0x22 ; 94 byte ;Local fonctions local1:1 local2:1 local3:1 local4:1 local6:1 local7:1 booleen:1 Vitesse:1 Tempo3:1 poidFort:1 poidFaible:1 ENDC #DEFINE TX_RS232 PORTB,2 #DEFINE LED_S PORTB,3 #DEFINE LED_OK PORTB,5 #DEFINE LED_CMP PORTA,7 #DEFINE BOUTON PORTB,4 ;LOCAL FONCTION #DEFINE Tempo local1 #DEFINE NbrBit local1 #DEFINE Tempo2 local2 #DEFINE _data__c2c_putchar local3 #define Chargé booleen,0 ;MACRO __c2c_rs232_delay macro LOCAL label_0010 movlw D'30' movwf Tempo2 label_0010 decfsz Tempo2, F goto label_0010 endm ;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯; ; DEBUT DU PROGRAMME ; ;_______________________________; org H'0' ;Vecteur de reset goto On_Reset org H'4' ;Vecteur d'interruptions On_Interrupt save_env bsf LED_CMP btfsc CMCON,C1OUT goto Annuler_int bcf T1CON,TMR1ON ;eyteint timer movf TMR1H,W call EnvoiHexa ;envoi donnés movf TMR1L,W call EnvoiHexa movlw "\r" call EnvoiChar bsf Chargé bsf T1CON,TMR1ON ;rallume timer BANKSEL PIE1 ;arreter int sur comparateur bcf PIE1,CMIE BANKSEL PORTA Annuler_int bcf PIR1,CMIF bcf LED_CMP load_env retfie On_Reset BANKSEL TRISB movlf H'FF',TRISB movwf TRISA bcf TX_RS232 bcf LED_S bcf LED_OK bcf LED_CMP movlf B'11000000',INTCON movlf B'00000100',OPTION_REG ;1:128b 110 BANKSEL PORTA movlf H'07',CMCON ; Comparateurs eteints clrf PORTA clrf PORTB bcf TX_RS232 ;----------------------------------------------------------- movlf d'128',Vitesse ;init comparateur movlf B'00001010',CMCON ;init timer 1 movlf B'00000001',T1CON ;init vref module BANKSEL VRCON movlf b'11101111',VRCON BANKSEL PORTA movlw "T" call EnvoiChar movlw "°" call EnvoiChar movlw VERSION call EnvoiChar movlw "\r" call EnvoiChar movlw "\n" call EnvoiChar Decharger_Condo bcf PORTA,3 ;met 0v sur le port BANKSEL TRISA bcf TRISA,3 BANKSEL PORTA movlf h'1',Tempo2 call Attente BANKSEL TRISA bsf TRISA,3 BANKSEL PORTA Charge_Condo clrf TMR1L Clrf TMR1H bcf PIR1,CMIF BANKSEL PIE1 bsf PIE1,CMIE BANKSEL PORTA Attendre_Charger btfss Chargé goto Attendre_Charger bcf Chargé goto Decharger_Condo ;--------------------------------------------- Attente ;Attente () { movlf H'1',Tempo3 clrf Tempo Attent11 incfsz Tempo,F goto Attent11 decfsz Tempo2,F goto Attent11 decfsz Tempo3,f goto Attent11 return ;EnvoiChaine (in FSR,in Taille) EnvoiChar movwf _data__c2c_putchar movlw D'9' movwf NbrBit bsf TX_RS232 nop nop BitSuiv __c2c_rs232_delay bcf STATUS, RP0 bcf STATUS, RP1 decfsz NbrBit, F goto EnvoiBit bcf TX_RS232 __c2c_rs232_delay return EnvoiBit bcf STATUS, RP0 bcf STATUS, RP1 rrf _data__c2c_putchar, F btfss STATUS, C goto Envoi0 bcf TX_RS232 goto BitSuiv Envoi0 bcf STATUS, RP0 bcf STATUS, RP1 bsf TX_RS232 goto BitSuiv ;---------- EnvoiHexa movwf poidFort movwf poidFaible swapf poidFort,f movlw H'0F' andwf poidFort,f andwf poidFaible,f movlw H'30' addwf poidFort,f addwf poidFaible,f movlw H'3A' bifsw poidFort,pFlettre test_pf movlw H'3A' bifsw poidFaible,pflettre envoi_ movf poidFort,w call EnvoiChar movf poidFaible,w call EnvoiChar movlw " " call EnvoiChar return pFlettre movlw d'7' addwf poidFort,f goto test_pf pflettre movlw d'7' addwf poidFaible,f goto envoi_ END