Using an I/O Port as a Serial Application
This section shows code to simulate serial port operation. This can be used
as a basis for the development of simple serial port applications such as
8-bit communication, non-parity, single stop bit applications. Here the
example is given as a project with the user left to decide which pins are send
and receive and the baudrate decided by the system frequency. Below are
the steps taken and other points to be noted.
•
Create a new file called DFSERIPT.INC in the directory \HT-IDE\IN-
CLUDE\Here must be included ...
–
Baudrateconst XXX. This value XXX can be taken from a table or
calculated (ignore the decimal point)
–
TXPIN ...... the defined transmit pin
–
RXPIN ...... the defined receive pin
•
The serial port program uses 4 RAM locations, 2 I/O pins and 49 program
memory locations. The TXPIN must be defined as an output and RXPIN
defined as an input.
•
Before Call or Receive, the RXPINs stop bit condition must be checked
Calling these two subroutines will change the condition of the carry flag.
•
When using Routines, the program must first declare them as follows:
EXTERN
TRANSMIT: NEAR
EXTERN
RECEIVE: NEAR
•
Below the main program serial.asm must be added.
The parameter baudrateconst is calculated from the baudrate as follows.
Baudrateconst = (Fsys/(baudrate*12))-3 (ignore the decimal point)
Note
The best value for baudrateconst is within a range of 7 to 256, the bigger the
value the smaller the error. The following table gives some direct values.
Refer to the table below:
Baudrate/Fsys
4MHz
2MHz
1MHz
9600
31
14
X
7200
43
20
8
4800
66
31
14
3600
89
43
20
2400
135
66
31
2000
163
80
38
1800
182
89
43
1200
X
135
66
Chapter 15 Input/Output Applications
203
Summary of Contents for HT-IDE
Page 11: ...P a r t I Integrated Development Environment Part I Integrated Development Environment 1 ...
Page 12: ...HT IDE User s Guide 2 ...
Page 20: ...Fig 1 6 Fig 1 7 HT IDE User s Guide 10 ...
Page 24: ...HT IDE User s Guide 14 ...
Page 70: ...HT IDE User s Guide 60 ...
Page 76: ...HT IDE User s Guide 66 ...
Page 92: ...HT IDE User s Guide 82 ...
Page 93: ...P a r t I I Development Language and Tools Part II Development Language and Tools 83 ...
Page 94: ...HT IDE User s Guide 84 ...
Page 148: ...HT IDE User s Guide 138 ...
Page 150: ...Fig 12 1 Fig 12 2 HT IDE User s Guide 140 ...
Page 154: ...HT IDE User s Guide 144 ...
Page 192: ...HT IDE User s Guide 182 ...
Page 194: ...HT IDE User s Guide 184 ...
Page 218: ...HT IDE User s Guide 208 ...
Page 235: ...P a r t V Appendix Part V Appendix 225 ...
Page 236: ...HT IDE User s Guide 226 ...
Page 250: ...HT IDE User s Guide 240 ...