

;Programme de synth� 70cm T7F de Victor F1BIU, version 1.0 du 20/08/98
;utilisant un pic 16f84 pour un pll MB1504 couvrant 400.000Mhz � 450.000Mhz
;Pas de 12.5Khz avec oscillateur de r�f�rence � 20.95Mhz.
;VCO tx couvrant de 200Mhz � 225Mhz.
;VCO rx de 189.3Mhz � 214.3Mhz pour une fi � 21.4Mhz, battement infradyne.
;L'affichage correspond � la fr�quence tx et rx � l'antenne.
;Passage de rx � tx par la broche ptt.
;oscillateur du pic par un circuit rc.


                DEVICE  PIC16F84,RC_OSC,WDT_OFF,PWRT_OFF,PROTECT_OFF

                id     '1BIU'

                org     0Ch

flag_butee_h    DS      1
flag_butee_b    DS      1
Digit0          DS      1
Digit1          DS      1
Digit2          DS      1
Digit3          DS      1
Digit4          DS      1
Digit5          DS      1
Digit6          DS      1
Digit7          DS      1
Digit8          DS      1
Digit9          DS      1
Digit10         DS      1
Digit11         DS      1
Digit12         DS      1
Digit13         DS      1
Digit14         DS      1
decal           DS      1

nb_clocks       DS      1
Count0          DS      1
Count1          DS      1
Count2          DS      1
temp            DS      1
temp1           DS      1
temp2           DS      1
pa              DS      1

prediv_ref0     DS      1
prediv_ref1     DS      1
_A              DS      1
Nlsb            DS      1
Nmsb            DS      1


RS              equ   RB.1       ;br 7 pic 0 = instruction, 1 = donn�es
RW              equ   RB.2       ;br 8 pic 0 = �crire, 1 = lire
E               equ   RB.3       ;br 9 pic 0 = non valide, 1 = enable

freq_plus       equ   RA.0  ;broche 17 du pic, r de 5.6k de rappel � 5v
freq_moins      equ   RA.1  ;broche 18 du pic, r de 5.6k de rappel � 5v      
vitesse         equ   RA.2  ;broche  1 du pic, r de 5.6k de rappel � 5v      
memoire         equ   RA.3  ;broche  2 du pic, r de 5.6k de rappel � 5v      
ptt             equ   RA.4  ;broche  3 ptt, 0 =fr�quence TX, 1 =fr�quence RX                  


data             =    RB.2     ;sortie datas,  broche 8 du pic.
clock            =    RB.1     ;sortie clock,  broche 7 du pic.
enable           =    RB.0     ;sortie enable, broche 6 du pic.
pa2              =    pa.0

;base quartz 20.95Mhz, pas de 12.5Khz

;vco tx =(fr�q tx)/2
;pour but�e basse tx 200.000Mhz (affichage  400.0000Mhz)  _A = 00h, N=500, Nmsb =01h, Nlsb =F4h
;pour but�e haute tx 225.000Mhz (affichage  450.0000Mhz)  _A = 20h, N=562, Nmsb =02h, Nlsb =32h

;vco rx = (fr�q rx - 21.4Mhz)/2
;pour but�e basse rx 189.3000Mhz (affichage  400.0000Mhz)  _A = 10h, N= 473, Nmsb =01h, Nlsb =D9h
;pour but�e haute rx 214.3000Mhz (affichage  450.0000Mhz)  _A = 30h, N= 535, Nmsb =02h, Nlsb =17h


    eeorg  0
    eedata 001h,0D9h,010h,004h,000h,000h,000h,000h,000h,000h  ;rx 189.3Mhz
    eedata 001h,0F4h,000h,004h,000h,000h,000h,000h,000h,000h  ;tx 200 Mhz




                org    0
Start           
                mov    !RA,#00011111b  ;RA0 � RA4 = entr�es                              
                mov    !RB,#00000000b  ;RB0 � RB7 = sortie.   
                mov    RB,#000h        ;les sorties � 0 au d�but.                                      
                mov    count0,#0
                mov    count1,#0
                mov    digit0,#' '
                mov    digit1,#' '
                mov    digit2,#4
                mov    digit5,#'.'
                mov    digit10,#'M'
                mov    digit11,#'h'
                mov    digit12,#'z'
                mov    digit13,#' '
                mov    prediv_ref0,#00011000b  ;3352 pour pas de 12.5Khz, lsb
                mov    prediv_ref1,#00110100b  ;suite msb osc r�f = 20.95Mhz
                                               ;mot de 6 bits, 2 lsb ignor�s.
                call   envoi_vers_pll_ref

                jnb    ptt, :aff_tx

:aff_rx         mov    digit14,#'R'
                jmp    :sui

:aff_tx         mov    digit14,#'T'
                mov decal,#10
                call  lect_memoire
                call envoi_vers_pll_div_princ
                jmp :sui2


:sui            mov decal,#0
                call  lect_memoire
                call  envoi_vers_pll_div_princ           


:sui2            call  tempo_lente
                 call  init_lcd
                 jnb   ptt,:tx1 

:rx1             mov decal,#0
                 call  lect_memoire
                 call  envoi_vers_pll_div_princ
                 mov   digit14,#'R'
                 call  tempo_lente
                 call  envoi_vers_lcd
                 
:rx2             jnb   ptt, :tx1
                 jnb   memoire,    :memrx
                 jnb   freq_plus,  :incr_rx
                 jnb   freq_moins, :decr_rx                 
                 jmp   :rx2


:tx1              mov   decal,#10
                  call  lect_memoire   
                  call  envoi_vers_pll_div_princ
                  mov   digit14,#'T'
                  call  tempo_lente
                  call  envoi_vers_lcd



:tx2              jb    ptt, :rx1
                  jnb   memoire,    :memtx
                  jnb   freq_plus,  :incr_tx
                  jnb   freq_moins, :decr_tx
                  jmp   :tx2


:memrx           mov decal, #0
                 call ecrit_memoire
                 jmp   :rx2



:memtx           mov decal,#10
                 call ecrit_memoire
                 jmp   :tx2


:decr_rx
                call   decrementation_pour_pll_rx
                call   envoi_vers_pll_div_princ
                call   decrementation_pour_lcd
                call   envoi_vers_lcd
                jmp    :rx2


               
                
:incr_rx        
                 call   incrementation_pour_pll_rx
                 call   envoi_vers_pll_div_princ
                 call   incrementation_pour_lcd
                 call   envoi_vers_lcd
                 jmp    :rx2

:decr_tx         call   decrementation_pour_pll_tx
                 call   envoi_vers_pll_div_princ
                 call   decrementation_pour_lcd
                 call   envoi_vers_lcd
                 jmp    :tx2



                
:incr_tx
                 call   incrementation_pour_pll_tx
                 call   envoi_vers_pll_div_princ
                 call   incrementation_pour_lcd
                 call   envoi_vers_lcd
                 jmp    :tx2


;---------------------------------------------------------------------------


;---------------------------------------------------------------------------
lect_memoire

                mov    eeadr,decal     ;lecture Nmsb
                setb   status.5
                setb   eecon1.0
                clrb   status.5
                mov    Nmsb,eedata

                inc    eeadr        ;lecture Nlsb
                setb   status.5
                setb   eecon1.0
                clrb   status.5
                mov    Nlsb,eedata

                inc    eeadr         ;lecture _A, compteur swalow
                setb   status.5
                setb   eecon1.0
                clrb   status.5
                mov    _A,eedata

                inc    eeadr        ;lecture 2eme digit lcd 100Mhz
                setb   status.5
                setb   eecon1.0
                clrb   status.5
                mov    digit2,eedata

                inc    eeadr        ;lecture 3eme digit lcd 10Mhz
                setb   status.5
                setb   eecon1.0
                clrb   status.5
                mov    digit3,eedata

                inc    eeadr        ;lecture 4eme digit lcd 1Mhz                  
                setb   status.5
                setb   eecon1.0
                clrb   status.5
                mov    digit4,eedata

                inc    eeadr        ;lecture 6eme digit lcd 100Khz
                setb   status.5
                setb   eecon1.0
                clrb   status.5
                mov    digit6,eedata

                inc    eeadr        ;lecture 7eme digit lcd 10Khz                  
                setb   status.5
                setb   eecon1.0
                clrb   status.5
                mov    digit7,eedata

                inc    eeadr        ;lecture 8eme digit lcd 1Khz
                setb   status.5
                setb   eecon1.0
                clrb   status.5
                mov    digit8,eedata

                inc    eeadr        ;lecture 9eme digit lcd 0.5Khz
                setb   status.5
                setb   eecon1.0
                clrb   status.5
                mov    digit9,eedata

                ret

;---------------------------------------------------------------------------

;---------------------------------------------------------------------------


;----------------------------------------------------------------------------

ecrit_memoire
                 mov    eeadr,decal ;�criture adresse 0 octet Nmsb
                 mov    eedata,Nmsb
                 call   valid_ecrit

                 inc    eeadr         ;�criture adresse 1 octet Nlsb
                 mov    eedata,Nlsb
                 call   valid_ecrit

                 inc    eeadr         ;�criture adresse 2 octet _A, swalow
                 mov    eedata,_A
                 call   valid_ecrit

                 inc    eeadr         ;�criture adresse 3  digit2 100Mhz
                 mov    eedata,digit2
                 call   valid_ecrit

                 inc    eeadr         ;�criture adresse 4 digit3   10Mhz
                 mov    eedata,digit3
                 call   valid_ecrit

                 inc    eeadr         ;�criture adresse 5  digit4   1Mhz
                 mov    eedata,digit4
                 call   valid_ecrit

                 inc    eeadr         ;�criture adresse 6  digit6  100Khz
                 mov    eedata,digit6
                 call   valid_ecrit

                 inc    eeadr         ;�criture adresse 7  digit7    10Khz
                 mov    eedata,digit7
                 call   valid_ecrit

                 inc    eeadr         ;�criture adresse 8  digit8     1Khz
                 mov    eedata,digit8
                 call   valid_ecrit

                 inc    eeadr         ;�criture adresse 9  digit9    0.5Khz
                 mov    eedata,digit9
                 call   valid_ecrit

                 ret


valid_ecrit      setb   status.5        ;set rp0 = page 1  des registres.
                 setb   eecon1.2        ;wren = 1 = write enable
                 mov    eecon2,#055h    ;s�cu contre �criture accidentelle.
                 mov    eecon2,#0AAh    ;s�cu, suite.
                 setb   eecon1.1        ;wr=1 = write
:bou0            jnb    eecon1.4,:bou0  ;eeif = 1 = donn�e �crite.
                 clrb   eecon1.4        ;eeif remis � 0.
                 clrb   status.5        ;reset rp0 = page 0 des registres.
                 ret
                 
;---------------------------------------------------------------------------

incrementation_pour_pll_rx

                mov    flag_butee_h,#0
                jnb    vitesse,:vite_incr   ;test bouton vitesse
                call   tempo_lente
                call   tempo_lente
                jmp    :suite1
:vite_incr      call   tempo_rapide

:suite1         cje     Nmsb,#02h,:test_Nlsb     
                jmp    :suite2

:test_Nlsb      cje     Nlsb,#17h,:test_A
                jmp     :suite2
:test_A         cje     _A,#30h, :butee_h     ;but�e haute.
                jmp    :suite2

:butee_h        mov    _A,#30h
                mov    Nlsb,#17h
                mov    Nmsb,#02h
                mov    flag_butee_h,#1
                jmp    :fin_inc

:suite2         inc      _A
                jb     _A.6,:inc_Nlsb    ;A>63?
                jmp    :fin_inc
:inc_Nlsb       mov    _A,#0
                inc     Nlsb
                cje     Nlsb,#0, :inc_Nmsb
                jmp    :fin_inc
:inc_Nmsb       inc     Nmsb 
:fin_inc        ret


;---------------------------------------------------------------------------
incrementation_pour_pll_tx

                mov    flag_butee_h,#0
                jnb    vitesse,:vite_incrtx   ;test bouton vitesse
                call   tempo_lente
                call   tempo_lente 
                jmp    :suite1tx
:vite_incrtx    call   tempo_rapide

:suite1tx       cje     Nmsb,#02h,:test_Nlsbtx      
                jmp    :suite2tx

:test_Nlsbtx    cje     Nlsb,#32h,:test_Atx
                jmp     :suite2tx
:test_Atx       cje     _A,#20h, :butee_htx     ;but�e haute.
                jmp    :suite2tx

:butee_htx      mov    _A,#20h
                mov    Nlsb,#32h
                mov    Nmsb,#02h
                mov    flag_butee_h,#1
                jmp    :fin_inctx

:suite2tx       inc      _A
                jb     _A.6,:inc_Nlsbtx    ;A>63?
                jmp    :fin_inctx
:inc_Nlsbtx     mov    _A,#0
                inc     Nlsb
                cje     Nlsb,#0, :inc_Nmsbtx
                jmp    :fin_inctx
:inc_Nmsbtx     inc     Nmsb 
:fin_inctx      ret
;---------------------------------------------------------------------------

decrementation_pour_pll_rx                        

                mov    flag_butee_b,#0
                jnb    vitesse,:vite_decr   ;test bouton vitesse
                call   tempo_lente
                call   tempo_lente
                jmp    :suite3
:vite_decr      call   tempo_rapide

:suite3         cje     Nmsb,#01h,:test_Nlsb                           
                jmp    :suite4

:test_Nlsb      cje     Nlsb,#0D9h,:test_A2
                jmp     :suite4
:test_A2        cje     _A,#10h,:butee_b     ;but�e basse
                jmp     :suite4

:butee_b        mov    _A,#10h
                mov    Nlsb,#0D9h
                mov    Nmsb,#01h
                mov    flag_butee_b,#1
                jmp    :fin_dec

:suite4         dec      _A
                jb     _A.7,:dec_Nlsb    ; si bit 7 de _A = 1, donc < 0.
                jmp    :fin_dec
:dec_Nlsb       mov    _A,#63
                dec     Nlsb
                cje     Nlsb,#0FFh,:dec_Nmsb
                jmp     :fin_dec
:dec_Nmsb       dec Nmsb
:fin_dec        ret

;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
decrementation_pour_pll_tx                        

                mov    flag_butee_b,#0
                jnb    vitesse,:vite_decrtx   ;test bouton vitesse
                call   tempo_lente
                call   tempo_lente
                jmp    :suite3tx
:vite_decrtx    call   tempo_rapide

:suite3tx       cje     Nmsb,#01h,:test_Nlsbtx                           
                jmp    :suite4tx

:test_Nlsbtx    cje     Nlsb,#0F4h,:test_A2tx
                jmp     :suite4tx
:test_A2tx      cje     _A,#00h,:butee_btx   ;but�e basse
                jmp     :suite4tx

:butee_btx      mov    _A,#00h
                mov    Nlsb,#0F4h
                mov    Nmsb,#01h
                mov    flag_butee_b,#1
                jmp    :fin_dectx

:suite4tx       dec      _A
                jb     _A.7,:dec_Nlsbtx  ; si bit 7 de _A = 1, donc < 0.
                jmp    :fin_dectx
:dec_Nlsbtx     mov    _A,#63
                dec     Nlsb
                cje     Nlsb,#0FFh,:dec_Nmsbtx
                jmp     :fin_dectx
:dec_Nmsbtx     dec Nmsb
:fin_dectx      ret

;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
incrementation_pour_lcd

                 cjne    flag_butee_h,#1,:S1
                 mov     digit1,#' '
                 mov     digit2,#4           ;affiche 450.0000Mhz
                 mov     digit3,#5
                 mov     digit4,#0
                 mov     digit6,#0
                 mov     digit7,#0
                 mov     digit8,#0
                 mov     digit9,#0
                 ret

:S1              cjne    digit7,#0, :S01
                 mov     digit7,#1
                 mov     digit8,#2
                 mov     digit9,#5
                 ret
:S01             cjne    digit7,#1,:S2
                 mov     digit7,#2
                 mov     digit8,#5
                 mov     digit9,#0
                 ret
:S2              cjne    digit7,#2,:S3
                 mov     digit7,#3
                 mov     digit8,#7
                 mov     digit9,#5
                 ret
:S3              cjne    digit7,#3,:S4
                 mov     digit7,#5
                 mov     digit8,#0
                 mov     digit9,#0
                 ret
:S4              cjne    digit7,#5,:S5
                 mov     digit7,#6
                 mov     digit8,#2
                 mov     digit9,#5
                 ret
:S5              cjne    digit7,#6,:S6
                 mov     digit7,#7
                 mov     digit8,#5
                 mov     digit9,#0
                 ret

:S6              cjne    digit7,#7,:S7
                 mov     digit7,#8
                 mov     digit8,#7
                 mov     digit9,#5
                 ret

:S7              cjne    digit7,#8,:fin_inc_lcd
                 mov     digit7,#0
                 mov     digit8,#0
                 mov     digit9,#0
                 inc     digit6
                 cjne    digit6,#10,:fin_inc_lcd
                 mov     digit6,#0
                 inc     digit4
                 cjne    digit4,#10,:fin_inc_lcd
                 mov     digit4,#0
                 inc     digit3
                 cjne    digit3,#6,:fin_inc_lcd
                 mov     digit3,#5

:fin_inc_lcd     ret

;----------------------------------------------------------------------------

;----------------------------------------------------------------------------

decrementation_pour_lcd

                 cjne    flag_butee_b,#1,:S22
                 mov     digit1,#' '
                 mov     digit2,#4           ;affiche 400.0000Mhz
                 mov     digit3,#0
                 mov     digit4,#0
                 mov     digit6,#0
                 mov     digit7,#0
                 mov     digit8,#0
                 mov     digit9,#0
                 ret

:S22             cjne    digit7,#8,:S33
                 mov     digit7,#7
                 mov     digit8,#5
                 mov     digit9,#0
                 ret
:S33             cjne    digit7,#7,:S44
                 mov     digit7,#6
                 mov     digit8,#2
                 mov     digit9,#5
                 ret
:S44             cjne    digit7,#6,:S55
                 mov     digit7,#5
                 mov     digit8,#0
                 mov     digit9,#0
                 ret
:S55             cjne    digit7,#5,:S66
                 mov     digit7,#3
                 mov     digit8,#7
                 mov     digit9,#5
                 ret
:S66             cjne    digit7,#3,:S77
                 mov     digit7,#2
                 mov     digit8,#5
                 mov     digit9,#0
                 ret
:S77             cjne    digit7,#2,:S88
                 mov     digit7,#1
                 mov     digit8,#2
                 mov     digit9,#5
                 ret
:S88             cjne    digit7,#1,:S11
                 mov     digit7,#0
                 mov     digit8,#0
                 mov     digit9,#0
                 ret
:S11             cjne    digit7,#0,:fin_dec_lcdd
                 mov     digit7,#8
                 mov     digit8,#7
                 mov     digit9,#5
                 dec     digit6
                 cjne    digit6,#255,:fin_dec_lcdd
                 mov     digit6,#9
                 dec     digit4
                 cjne    digit4,#255,:fin_dec_lcdd
                 mov     digit4,#9
                 dec     digit3
                 cjne    digit3,#255,:fin_dec_lcdd
                 mov     digit3,#0
:fin_dec_lcdd    ret

;-----------------------------------------------------------------------------
;initialisation lcd 4 bits une ligne.

init_lcd
                mov     rb,#0
                mov     !rb,#0h
                call    wait
                clrb    RS           ;mode instruction
                call    wait     
                mov     RB,#030h     ;init
                nop
                setb    E
                call    wait
                call    wait
                clrb    E

                clrb    RS           ;mode instruction
                nop
                nop
                mov     RB,#020h     ;4 bits
                nop
                nop
                setb    E
                call    wait
                clrb    E
                nop
                nop

                clrb    RS                                    
                nop                          
                mov     temp2,#28h                    
                call    blip_E               
                nop                          

                clrb    RS           ;mode instruction
                nop
                mov     temp2,#08h   ;effacement affichage au d�but.
                call    blip_E
                nop
                clrb    RS           ;mode instruction
                nop
                mov     temp2,#06h
                nop
                call    blip_E
                nop
                clrb    RS           ;mode instruction
                nop
                mov     temp2,#0Ch
                nop
                call    blip_E
                nop
                clrb    RW           ;mode �criture
                nop
                clrb    RS           ;mode instruction
                nop
                mov     temp2, #10000010b   ;position 2 de l'afficheur
                nop
                call	blip_E
                nop
                setb    RS        ;mode caract�res.
                nop
                ret
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;routine �crit caract. dans le lcd, pa2 =tampon de RS, temp2 pour le caract.

blip_E
                movb    pa2, RS                                             
                clrb    RS              ;passage en mode instruction
                nop
                setb    RW              ;RW en lecture
                nop
                mov     !rb,#0F0h       ;msb en entr�e, lsb sortie
                nop
:loop           setb    E               ;Enable du LCD.
                nop
                mov     temp, RB        ;le contenu de RB vers temp
                nop
                clrb    E               ;Disable du LCD.
                nop
                nop
                setb    E               ;2 fois pour mode 4 bits.
                nop
                nop
                clrb    E
                snb     temp.7          ;LCD occup�?
                jmp     :loop           ;oui, retour :loop
                nop
                movb    RS, pa2         ;Non, envoi data ou instruction.
                nop
                clrb    RW              ;mode �criture
                nop
                mov     !rb, #0h        ;tout le port RB en sortie.
                nop
                mov     temp1,temp2     ;masquage du lsb et swap
                nop
                and     RB,#0Fh         ;pour ne pas perturber les lignes
                nop
                and     temp2,#0F0h     ;de contr�le du pll.
                nop
                or      RB,temp2        ;envoi msb d'abord.
                nop
                setb	E
		nop
		clrb	E
                nop
                swap    temp1
                nop
                and     RB,#0Fh
                nop
                and     temp1,#0F0h
                nop
                or      RB,temp1       ;envoi lsb ensuite.
                nop
                setb   E
                nop
                clrb   E
                nop
                ret
;-----------------------------------------------------------------------------


;-----------------------------------------------------------------------------
envoi_vers_lcd

               clrb    RS        ;mode instruction
               mov     temp2, #10000000b; position 1ere ligne de l'afficheur
               call    blip_E

               setb      RS             ;mode caract�res

               mov       temp2, #' '                                      
               call      blip_E

               mov       temp2, #' '
               call      blip_E

               mov       w, digit2
               add       w,#030h
               mov       temp2,w
               call      blip_E

               mov       w, digit3
               add       w,#030h
               mov       temp2,w
               call      blip_E

               mov       w, digit4
               add       w,#030h
               mov       temp2,w
               call      blip_E


               mov       temp2, digit5    ;affichage virgule
               call      blip_E

               mov       w, digit6
               add       w,#030h
               mov       temp2,w
               call      blip_E


               mov       w, digit7
               add       w,#030h
               mov       temp2,w
               call      blip_E

               clrb    RS        ;mode instruction
               mov     temp2, #11000000b ;position 9eme caract�re
               call    blip_E            
               setb    RS        ;mode caract�res

               mov       w, digit8
               add       w,#030h
               mov       temp2,w
               call      blip_E


               mov       w, digit9
               add       w,#030h
               mov       temp2,w
               call      blip_E

               mov       temp2, digit10    ;M
               call      blip_E

               mov       temp2, digit11    ;h
               call      blip_E

               mov       temp2, digit12    ;z
               call      blip_E

               mov       temp2, #' '
               call      blip_E

               mov       temp2, digit14
               call      blip_E

               mov       temp2, #'X'
               call      blip_E

               ret


;---------------------------------------------------------------------------
;envoi taux de division r�f�rence
envoi_vers_pll_ref
                clrb    data             ;sw = 0, prediv =64
                nop
                setb    clock
                nop
                clrb    clock
                nop

                mov nb_clocks,#6
                mov     temp,prediv_ref1  ;envoi 6bits msb pr�div r�f�rence 
:rotationA      movb    data,temp.7
                setb    clock
                nop
                clrb    clock
                nop
                rl temp
                djnz   nb_clocks,:rotationA

                mov nb_clocks,#8
                mov     temp,prediv_ref0  ;envoi 8bits lsb pr�div r�f�rence 
:rotationB      movb    data,temp.7
                setb    clock
                nop
                clrb    clock
                nop
                rl temp
                djnz   nb_clocks,:rotationB
                nop
                nop
                setb    data             ;envoi bit C de contr�le � 1
                nop
                setb    clock
                nop
                clrb    clock
                nop               
                setb     enable         ;envoi de l'enable apr�s les 16 bits.
                nop
                nop
                clrb    enable
                nop
                nop
                clrb    data          ; les 3 fils du pll retombent a 0.
                nop
                nop
                ret

 ;-------------------------------------------------------------------------
 ;-------------------------------------------------------------------------
 ;envoi taux de division principale

envoi_vers_pll_div_princ
                mov nb_clocks,#3
                mov     temp,Nmsb     ;envoi 3bits poids faible du msb
:rotationD      movb    data,temp.2   ;5 bits msb ignor�s
                setb    clock
                nop
                clrb    clock
                nop
                rl temp
                djnz   nb_clocks,:rotationD


                mov nb_clocks,#8
                mov     temp,Nlsb    ;envoi 8bits lsb division principale
:rotationE      movb    data,temp.7
                setb    clock
                nop
                clrb    clock
                nop
                rl temp
                djnz   nb_clocks,:rotationE


                mov nb_clocks,#7
                mov     temp,_A     ;envoi 7bits pr�division modulus
:rotationF      movb    data,temp.7
                setb    clock
                nop
                clrb    clock
                nop
                rl temp
                djnz   nb_clocks,:rotationF

                clrb    data             ;envoi bit C de contr�le � 0 
                setb    clock
                nop
                clrb    clock
                nop
                clrb    data
                nop               
                setb    enable        ;envoi de l'enable apr�s les 19 bits.
                nop
                nop                                   
                clrb    enable
                nop
                clrb    data          ; les 3 fils du pll retombent a 0.
                nop
                nop
                ret

;---------------------------------------------------------------------------


;-----------------------------------------------------------------------------
wait            
                mov     temp1,#160
:exter          mov     temp2,#200         ;tempo de 24mS
:inter          djnz    temp2,:inter
                djnz    temp1,:exter
                ret
;-----------------------------------------------------------------------------

;---------------------------------------------------------------------------
tempo_lente      
                 mov     Count1,#255
:lop3            mov     Count0,#255       ;environ 1 seconde pour 25Khz.
:Loop3           djnz    Count0,:Loop3                                       
                 djnz    Count1,:Lop3                                                 
                 ret

;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
tempo_rapide                 
                 mov     Count1,#14      
:lop4            mov     Count0,#50        ;environ 1 seconde pour 1Mhz
:Loop4           djnz    Count0,:Loop4                                                                       
                 djnz    Count1,:Lop4                                                                        
                 ret
                
;---------------------------------------------------------------------------

