chiark / gitweb /
undo broken deletion
[trains.git] / cebpic / send-serial.asm
1 ; pin 21 (per-pic-led, RD2/PSP2/C1IN) states: high H = green, low L = red, float Z = black
2
3         include         /usr/share/gputils/header/p18f458.inc
4         radix           dec
5
6 clock equ mclock
7         include         ../iwjpictest/clockvaries.inc
8
9         code
10 start
11 ; initial config
12         bcf     TXSTA,6,0       ; p181, set 8-bit mode
13         bsf     TXSTA,5,0       ; transmit enable
14         bcf     TXSTA,4,0       ; asynchronous mode
15         bsc_txsta_brgh          ; set high or low baud rate
16         bsf     RCSTA,7,0       ; serial port enable (p182)
17
18 ; set SPBRG to get correct baud rate
19         movlw_movwf_spbrg
20
21         call    initialiseascii
22
23 main
24         movff   00h,TXREG       ; move 00h to transmit buffer (ascii s)
25         call    waitfortsr
26         movff   01h,TXREG       ; move 01h to transmit buffer (ascii q)
27         call    waitfortsr
28         movff   02h,TXREG       ; move 02h to transmit buffer (ascii o)
29         call    waitfortsr
30         movff   02h,TXREG       ; move 02h to transmit buffer (ascii o)
31         call    waitfortsr
32         movff   03h,TXREG       ; move 03h to transmit buffer (ascii k)
33         call    waitfortsr
34         movff   04h,TXREG       ; move 04h to transmit buffer (ascii SPACE)
35         call    waitfortsr
36         goto    main
37
38         
39 waitfortsr
40         btfss   TXSTA,1,0       ; check whether TRMT is set (i.e. TSR is empty)
41         bra     waitfortsr
42         return
43
44
45 initialiseascii ; set up ascii letter bytes 
46
47 ; there must be a faster way to do this...
48
49         clrf    00h,0   ; clear data registers
50         clrf    01h,0
51         clrf    02h,0
52         clrf    03h,0
53         clrf    04h,0
54         
55         bsf     00h,6,0 ; set 00h to be ascii s
56         bsf     00h,5,0 
57         bsf     00h,4,0
58         bsf     00h,1,0
59         bsf     00h,0,0
60         
61         bsf     01h,6,0 ; set 01h to be ascii q
62         bsf     01h,5,0 
63         bsf     01h,4,0
64         bsf     01h,0,0
65
66         bsf     02h,6,0 ; set 01h to be ascii o
67         bsf     02h,5,0
68         bsf     02h,3,0
69         bsf     02h,2,0
70         bsf     02h,1,0
71         bsf     02h,0,0
72
73         bsf     03h,6,0 ; set 03h to be ascii k
74         bsf     03h,5,0
75         bsf     03h,3,0
76         bsf     03h,1,0
77         bsf     03h,0,0
78
79         bsf     04h,5,0 ; set 04h to be ascii _
80
81         return
82
83         end