Line 1... |
Line 1... |
|
|
#include "hardware.h"
|
#include "hardware.h"
|
|
|
;variables
|
;variables
|
.data
|
.data
|
.comm rxdata,1,1 ;char var
|
; .comm rxdata,1,1 ;char var
|
.comm rxshift,1,1 ;char var
|
.comm rxshift,1,1 ;char var
|
.comm rxbit,2,2 ;short var, aligned
|
.comm rxbit,2,2 ;short var, aligned
|
|
|
.text
|
.text
|
|
|
vector_0x0012:
|
|
;interrupt(TIMERA0_VECTOR) ;register interrupt vector
|
;interrupt(TIMERA0_VECTOR) ;register interrupt vector
|
;interrupt handler to receive as Timer_A UART
|
;interrupt handler to receive as Timer_A UART
|
.global ccr0 ;place a label afterwards so
|
.global ccr0 ;place a label afterwards so
|
ccr0: ;that it is used in the listing
|
ccr0: ;that it is used in the listing
|
add &rxbit, r0
|
add &rxbit, r0
|
Line 28... |
Line 27... |
.Lrxlastbit: ;last bit, handle byte
|
.Lrxlastbit: ;last bit, handle byte
|
bit #SCCI, &CCTL0 ;read last bit
|
bit #SCCI, &CCTL0 ;read last bit
|
rrc.b &rxshift ;and save it
|
rrc.b &rxshift ;and save it
|
clr &rxbit ;reset state
|
clr &rxbit ;reset state
|
mov #CCIE|CAP|CM_2|CCIS_1|SCS, &CCTL0 ;restore capture mode
|
mov #CCIE|CAP|CM_2|CCIS_1|SCS, &CCTL0 ;restore capture mode
|
mov.b &rxshift, &rxdata ;copy received data
|
; mov.b &rxshift, &rxdata ;copy received data
|
bic #CPUOFF|OSCOFF|SCG0|SCG1, 0(r1) ;exit all lowpower modes
|
; bic #CPUOFF|OSCOFF|SCG0|SCG1, 0(r1) ;exit all lowpower modes
|
;here you might do other things too, like setting a flag
|
;here you might do other things too, like setting a flag
|
;that the wakeup comes from the Timer_A UART. however
|
;that the wakeup comes from the Timer_A UART. however
|
;it should not take longer than one bit time, otherwise
|
;it should not take longer than one bit time, otherwise
|
;charcetrs will be lost.
|
;charcetrs will be lost.
|
reti
|
; reti
|
|
mov.b &rxshift, r15 ;return received data
|
|
ret
|
|
|
.Lrxstart: ;startbit, init
|
.Lrxstart: ;startbit, init
|
clr &rxshift ;clear input buffer
|
clr &rxshift ;clear input buffer
|
add #(BAUD/2), &CCR0 ;startbit + 1.5 bits -> first bit
|
add #(BAUD/2), &CCR0 ;startbit + 1.5 bits -> first bit
|
mov #CCIE|CCIS_1|SCS, &CCTL0;set compare mode, sample bits
|
mov #CCIE|CCIS_1|SCS, &CCTL0;set compare mode, sample bits
|
Line 48... |
Line 49... |
bit #SCCI, &CCTL0 ;measure databit
|
bit #SCCI, &CCTL0 ;measure databit
|
rrc.b &rxshift ;rotate in databit
|
rrc.b &rxshift ;rotate in databit
|
|
|
.Lrxex: add #BAUD, &CCR0 ;one bit delay
|
.Lrxex: add #BAUD, &CCR0 ;one bit delay
|
incd &rxbit ;setup next state
|
incd &rxbit ;setup next state
|
reti
|
; reti
|
|
mov #0xffff, r15 ;return 0xffff
|
|
ret
|
|
|
; void serPutc(char)
|
; void serPutc(char)
|
;use an other Capture/Compare than for receiving (full duplex).
|
;use an other Capture/Compare than for receiving (full duplex).
|
;this one is without interrupts and OUTMOD, because only
|
;this one is without interrupts and OUTMOD, because only
|
;this way P1.1 can be used. P1.1 is prefered because the
|
;this way P1.1 can be used. P1.1 is prefered because the
|