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

Subversion Repositories openmsp430

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

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

Line No. Rev Author Line
1 143 olivier.gi
 
2 2 olivier.gi
#include "hardware.h"
3
 
4
;variables
5
.data
6 153 olivier.gi
;        .comm   rxdata,1,1              ;char var
7 2 olivier.gi
        .comm   rxshift,1,1             ;char var
8
        .comm   rxbit,2,2               ;short var, aligned
9
 
10
.text
11
 
12 143 olivier.gi
;interrupt(TIMERA0_VECTOR)               ;register interrupt vector
13 2 olivier.gi
;interrupt handler to receive as Timer_A UART
14
.global ccr0                            ;place a label afterwards so
15
ccr0:                                   ;that it is used in the listing
16 143 olivier.gi
        add     &rxbit, r0
17 2 olivier.gi
        jmp     .Lrxstart               ;start bit
18
        jmp     .Lrxdatabit             ;D0
19
        jmp     .Lrxdatabit             ;D1
20
        jmp     .Lrxdatabit             ;D2
21
        jmp     .Lrxdatabit             ;D3
22
        jmp     .Lrxdatabit             ;D4
23
        jmp     .Lrxdatabit             ;D5
24
        jmp     .Lrxdatabit             ;D6
25
;        jmp     .Lrxlastbit             ;D7 that one is following anyway
26
 
27
.Lrxlastbit:                            ;last bit, handle byte
28
        bit     #SCCI, &CCTL0           ;read last bit
29 143 olivier.gi
        rrc.b   &rxshift                 ;and save it
30
        clr     &rxbit                   ;reset state
31 2 olivier.gi
        mov     #CCIE|CAP|CM_2|CCIS_1|SCS, &CCTL0   ;restore capture mode
32 153 olivier.gi
;        mov.b   &rxshift, &rxdata         ;copy received data
33
;        bic     #CPUOFF|OSCOFF|SCG0|SCG1, 0(r1) ;exit all lowpower modes
34 2 olivier.gi
        ;here you might do other things too, like setting a flag
35
        ;that the wakeup comes from the Timer_A UART. however
36
        ;it should not take longer than one bit time, otherwise
37
        ;charcetrs will be lost.
38 153 olivier.gi
;        reti
39
        mov.b   &rxshift, r15           ;return received data
40
        ret
41 2 olivier.gi
 
42
.Lrxstart:                              ;startbit, init
43 143 olivier.gi
        clr     &rxshift                 ;clear input buffer
44 2 olivier.gi
        add     #(BAUD/2), &CCR0        ;startbit + 1.5 bits -> first bit
45
        mov     #CCIE|CCIS_1|SCS, &CCTL0;set compare mode, sample bits
46
        jmp     .Lrxex                  ;set state,...
47
 
48
.Lrxdatabit:                            ;save databit
49
        bit     #SCCI, &CCTL0           ;measure databit
50 143 olivier.gi
        rrc.b   &rxshift                 ;rotate in databit
51 2 olivier.gi
 
52
.Lrxex: add     #BAUD, &CCR0            ;one bit delay
53 153 olivier.gi
        incd    &rxbit                  ;setup next state
54
;        reti
55
        mov     #0xffff, r15            ;return 0xffff
56
        ret
57 2 olivier.gi
 
58
; void serPutc(char)
59
;use an other Capture/Compare than for receiving (full duplex).
60
;this one is without interrupts and OUTMOD, because only
61
;this way P1.1 can be used. P1.1 is prefered because the
62
;BSL is on that pin too.
63
.global putchar
64
        .type putchar, @function
65
putchar:                                ;send a byte
66
        mov     #0, &CCTL1              ;select compare mode
67
        mov     #10, r13                ;ten bits: Start, 8 Data, Stop
68
        rla     r15                     ;shift in start bit (0)
69
        bis     #0x0200, r15            ;set tenth bit (1), thats the stop bit
70
        mov     &TAR, &CCR1             ;set up start time
71
.Lt1lp: add     #BAUD, &CCR1            ;set up for one bit
72
        rrc     r15                     ;shift data trough carry
73
        jc      .Lt1                    ;test carry bit
74
.Lt0:   bic.b   #TX, &P1OUT             ;generate pulse
75
        jmp     .Ltc                    ;
76
.Lt1:   bis.b   #TX, &P1OUT             ;just use the same amount of time as for a zero
77
        jmp     .Ltc                    ;
78
.Ltc:   bit     #CCIFG, &CCTL1          ;wait for compare
79
        jz      .Ltc                    ;loop until the bit is set
80
        bic     #CCIFG, &CCTL1          ;clear for next loop
81
        dec     r13                     ;decrement bit counter
82
        jnz     .Lt1lp                  ;loop until all bits are transmitted
83
        ret

powered by: WebSVN 2.1.0

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