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 139

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

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

powered by: WebSVN 2.1.0

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