Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pic 16 2.36 KB | None | 0 0
  1. ; *********************************
  2. ; Pizzolato Luca
  3. ; 2Bini Microcontroleur 2
  4. ; *********************************
  5.  
  6.  
  7. ;Dividende
  8. ;Diviseur
  9.        
  10. Status  EQU 03
  11. PORTB   EQU 06
  12. PORTA   EQU 05
  13. Tmr0    EQU 01
  14.  
  15.        
  16.  
  17. cpt02   EQU 0c
  18. cpt01   EQU 0d
  19. Chiffre EQU 0E
  20. Quotient EQU 0f
  21. Dividende EQU 1A
  22. Reste   EQU 1B 
  23. Apparition EQU 1C
  24. ChiffrePre  EQU 1D
  25.        
  26.  
  27.  
  28.        
  29.         MOVLW   B'11001000'
  30.         Option
  31.  
  32.         MOVLW   0           ; config du portB
  33.         TRIS    PORTB       ;
  34.         CLRF    PORTB
  35.         MOVWF   ChiffrePre
  36.  
  37.         MOVLW   B'00011'    ; config du portA
  38.         TRIS    PORTA       ;
  39.         CLRF    PORTA
  40.  
  41.  
  42. ; eteindre l'afficheur mettre une valeur supperieur a 9
  43.  
  44.         MOVLW b'00001111'
  45.         movwf PORTB
  46.  
  47. ; test sur les boutons
  48. Debut
  49. TESTAPP BTFSC PORTA,0
  50.         GOTO  TESTAPP
  51.        
  52.         Call Tempo
  53.  
  54.  
  55. TESTREL BTFSS PORTA,0
  56.         GOTO TESTREL
  57.  
  58.  
  59. ; recupérer la valeur du timer et faire la division
  60.  
  61.  
  62.  
  63.         MOVF Tmr0,0
  64.         CALL Div
  65.         MOVLw d'5'
  66.         ADDWf Reste,0
  67.         movwf Apparition
  68.        
  69. Lancer      Call Tempo
  70.        
  71.        
  72.     ;    eteindre l'afficheur mettre une valeur supperieur a 9
  73.  
  74.         MOVLW b'00001111'
  75.         movwf PORTB
  76.        
  77.         Call Tempo
  78.         Call Tempo
  79.    
  80.  
  81. Gen     Movf Tmr0,0
  82.         CALL Div
  83.         MOVF Reste,0
  84.         INCF Reste,1
  85.  
  86.  
  87. ;       MOVF Reste,0
  88. ;       SUBWF ChiffrePre,0
  89. ;       BTFSC   Status, 2
  90. ;       Goto Gen
  91.        
  92.  
  93.  
  94.  
  95.         MOVF Reste,0
  96.         MOVWF PORTB
  97.  
  98.                
  99.         MOVF Reste,0
  100.         MOVWF ChiffrePre
  101.  
  102.  
  103.         DECFSZ Apparition,1
  104.         Goto Lancer
  105.         Goto Debut
  106.  
  107.  
  108.  
  109.  
  110.         MOVF Tmr0,0
  111.         MOVWF Chiffre
  112.         movf Chiffre,0
  113.         Call  Debut
  114.         Movwf Chiffre
  115.         movf Chiffre,0
  116.         movwf PORTB
  117.  
  118.  
  119.  
  120. ; Sous routine pour prendre le Mod6 du timer
  121.  
  122.  
  123. Div     MOVWF Dividende
  124.         CLRF  Quotient
  125.  
  126.  
  127. Moins   MOVLW d'6'              ; mettre 6 dans W
  128.         SUBWF Dividende,0       ; Pour ne pas modifier dividende 184-6 En gros pour faire le test Divid> diviseur
  129.  
  130.                                 ; tester pour voir si la soustraction est ok ==> bit de carry
  131.                                 ; si tout va bien le bit carry est a 1                                                                                                                                                                                
  132.         BTFSS Status,0
  133.         GOTO  Suite
  134.         MOVWF Dividende
  135.         INCF Quotient
  136.         GOTO Moins
  137.  
  138. Suite   MOVF Dividende,0
  139.         MOVWF Reste
  140.         MOVF Reste,0
  141.         Return
  142.  
  143.  
  144.  
  145.  
  146. ; Sous routine de la tempo pour l'anti rebond du bouton
  147.  
  148. Tempo   MOVLW d'255'
  149.         MOVWF cpt02
  150. LOOP2   MOVLW d'255'
  151.         MOVWF cpt01
  152. LOOP1   DECFSZ cpt01
  153.         GOTO LOOP1
  154.         DECFSZ cpt02
  155.         GOTO LOOP2
  156.         Return
  157.  
  158.  
  159.  
  160.  
  161.  
  162.         end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement