OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [xilinx_diligent_s3board/] [software/] [ta_uart/] [fll.s] - Blame information for rev 191

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 olivier.gi
#include "hardware.h"
2
.text
3
.global fllInit                         ; SW FLL to init DCO/SMCLK -frequency
4
        .type   fllInit, @function
5
fllInit:
6
        mov.b   #BCSCTL1_FLL, &BCSCTL1  ; Init basic clock control reg 1
7
        mov.b   #BCSCTL2_FLL, &BCSCTL2  ; Init basic clock control reg 2
8
        mov     #TACTL_FLL, &TACTL      ; SMCLK is TA-clock / Timer stopped
9
        bis     #MC1, &TACTL            ; Start timer: Continuos Mode
10
        mov     #CCTL2_FLL, &CCTL2      ; Init CCR2 and Clear capture flag
11
 
12
.Lwait0:bit     #CCIFG, &CCTL2          ; Test/Wait for capture flag
13
        jz      .Lwait0                 ; May be used with INT / LPM0 later ?
14
        mov     &CCR2, r15              ; Store CCR2 init-value
15
        bic     #CCIFG, &CCTL2          ; Clear capture flag
16
.Lwait1:bit     #CCIFG, &CCTL2          ; Test/Wait for capture flag
17
        jz      .Lwait1                 ; May be used with INT / LPM0 later ?
18
        bic     #CCIFG, &CCTL2          ; Clear capture flag
19
        mov.b   &BCSCTL1, r14           ; Store current Rsel value
20
        bic.b   #0x0f8, r14             ; Mask for Rsel bits
21
        mov.b   &DCOCTL, r13            ; Store current DCO value
22
 
23
.LfllUP:cmp.b   #DCOCTL_MAX, r13        ; Needs Rsel to be increased ?
24
        jne     .LfllDN                 ; No
25
        cmp.b   #7, r14                 ; Is max Rsel already selected ?
26
        jge     .LfllER                 ; Yes, Rsel can not be increased
27
        inc.b   &BCSCTL1                ; Increase Rsel
28
        jmp     .LfllRx                 ; Test DCO again
29
 
30
.LfllDN:cmp.b   #DCOCTL_MIN, r13        ; Needs Rsel to be decreased ?
31
        jne     .LfllCP                 ; No
32
        cmp.b   #0, r14                 ; Is min Rsel already selected ?
33
        jeq     .LfllER                 ; Yes, Rsel can not be increased
34
        dec.b   &BCSCTL1                ; Decrease Rsel
35 143 olivier.gi
.LfllRx:
36
        mov.b   #60h, &DCOCTL           ; Center DCO (may be optimized later ?)
37 2 olivier.gi
        jmp     .Lwait0                 ; Test DCO again
38
.LfllCP:
39
        mov     &CCR2, r12              ; Read captured value
40
        sub     r15, r12                ; Subtract last captured value
41
        mov     &CCR2, r15              ; Store CCR2 value for next pass
42
        cmp     #DCO_FSET, r12          ; DCO_FSET= SMCLK/(32768/4)
43
        jl      .LfllI                  ;
44
        jeq     .LfllOK                 ;
45
.LfllD: dec.b   &DCOCTL                 ; Decrement value
46
        jmp     .Lwait0                 ;
47
.LfllI: inc.b   &DCOCTL                 ; Increment value
48
        jmp     .Lwait0                 ;
49
 
50
.LfllER:                                ; error, currently ingnored
51
.LfllOK:clr     &CCTL2                  ; stop CCR2
52
        ret                             ;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.