Menu   Welcome on Na-Prod.com
 

Communication Port
For AFX/2
(French traduction)

I. Introduction
The comm port can transfer up to 115200bps synchronisly.

II. I/O Ports
I'll name an I/O port with PXXh and XX, the hexadécimal number of the port.
Notation : L=E read value=writen value
L= only read value is important
E= only writing value is important
L/E= the writing!=reading but the both are important
1. P0Ah : Keybort and Com port Status
Default : 0Ah L/E

7

6

5

4

3

2

1

0

Val

0

0

0

0

1

0

1

0

Bit 0 : Actvates the Comm Port Status.
bit 0 of P0Eh is on if a byte is received
Bit 1 : Can't be removed
Bit 2,4,5,7 : ?
Bit 3 : Sets the Keyboard status, if off the keyboard isn't available anymore until it's on
Bit 6 : Sets bit 6of P0Eh to he value.

2. P0Eh : Comm port status
default : 00h L

7

6

5

4

3

2

1

0

Val

0

0

0

0

0

0

0

0

Bit 0 : Shows if a byte has been correctly received.
Bit 1,2,3,4,5,7 : ?
Bit 6 : is at the P0Ah's bit 6 value.
Note: The utilisation of these 2 port are not important in communication and you can only use P45h.
3. P11h : Activates Port courant.
Default : 03h L=E

7

6

5

4

3

2

1

0

Val

0

0

0

0

0

0

1

1

Bit 5 : Activates the reception
Bit 6 : Activates the sending
Bit 0,1,2,3,4,7 : ?
4. P44h : Comm port configuration and receive buffer
default : 00h L/E

7

6

5

4

3

2

1

0

Val

0

0

0

0

0

0

0

0

In writing, activates the communication with the choosed speed

7

6

5

4

3

2

1

0

Val

0

1

0

1

0

1

0

0

Bits de 0 à 3 : Speed, number*4, ex :speed 4 = 4*4 = Ch
Bit 4 : Correct Communication
Bit 5 : Reception (3)
Bit 6 : Sending (5)
Bit de poids fort : Mode
Bits de poids faible : Speed
Note:if the bits 5&6 are on the comm port can comunicate synchronisly
Reading, gives the last byte received.
5. P45h : Shows the state of the comm port.
default : 00h L/E

Reading, state of the comm port.

7

6

5

4

3

2

1

0

Val

0

0

0

0

0

0

0

0

Bit 0 : A byte has been sent
Bit 1 : A byte has been received
Bit 2 : A byte is arrived while the last one was not read
Bit 3,4 : Errors
Bits 5,6,7 : ?

Writing, controls the correctnes of the communication.

7

6

5

4

3

2

1

0

Val

0

1

0

0

0

0

0

1

Normal Value 41h

6. P46h : Send buffer
Par défaut : ??h E

7. P47h : Speed Control.
Par défaut : ??h E

III. The speeds & values

Speed

0h

4h
8h

Ch

115200 bps
     
0Bh
76800 bps
     
11h
57800 bps
   
0Bh
17h
38400 bps
   
11h
21h
28800 bps
 
0Bh
17h
2Bh
19200 bps
 
11h
21h
41h
14400 bps
0Bh
17h
2Bh
5Bh
9600 bps
11h
21h
41h
7Fh
7200 bps
17h
2Bh
5Bh
 
4800 bps
21h
41h
7Fh
 
3600 bps
2Bh
5Bh
   
2400 bps
41h
7Fh
   
1800 bps
5Bh
     
1200 bps
7Fh
     

To initialise to the chossen speed, put the green value into P47h.
And put 70/74/78/7C in P44h.

Ex : To communicate to14400bps:
- 0Bh in P47h, 70h in P44h
or
- 17h in P47h, 74h in P44h
or
- 2Bh in P47h, 78h in P44h
or
- 5Bh in P47h, 7Ch in P44h

IV. Primary Initialisation

This initialisation put power into the com port.
The P11h controls the comm power. You must activate bits 5 & 6 of P11h.
At end you may off the bits 5 &6.

V. Comm Config
1. Sending

1.1 Theorie
1. Primary Initialisation
2. 00->P44h
3. Speed->P47h
4. Byte->P46h
5. 41h -> P45h and 70/74/78/7C ->P44h
6. Wait while bit 0 of P45h is off
7. Continue or go to 6 after puting byte into P46h
8. 00->P44h
9. bits 5 & 6 of P11h to zero

1.2. Assembly

;x86 Assembly
;Send byte 13h at 38400 bps
.part1:

in al,11h ;P11h->Al
or al,60h ;activates bits 5 & 6
out 11h,al ;Al-> P11h
.part2:
mov al,0h
out 44h,al ;00-> P44h
.part3:
mov al,41h;Correct Communication
out 45h,al

mov al,21h 
out 47h,al ;Speed-> P47h
.part4:
mov al,13h
out 46h,al
.part5:
mov al,7C ; 38400bps
out 44h,al
.part6:
in al,45h ;Al<- P45h
and al,1 ;bit 0 (1= 00 000 001b)
cmp al,1 ;compare with 1
jne .partie6 ; not egual to 1, return
.part7: 
.part8:
mov al,0h
out 44h,al 00->P44h
.part9 :
in al,11h ;Al<- P11h
and al,9Fh ;desactivates bits 5 & 6
out 11h,al ;Al->P11h
;End

2.Reception
2.1 Theorie
1. Primary initialisation
2. 00->P44h
3. Speed->P47h
4. 41h-> P45h and 70/74/78/7C ->P44h
5. Take P45h value
6. if bit 1 is on and bits 3 & 4 are off, continue or go to 5
7. Take Value of P44h
8. Analyse the byte
9. 00->P44h
10. Desactivate bits 5 & 6 of P11h

2.2 Assembly


;x86 Assembly
;Waits a Byte at 34800bps

.part1:
in al,11h 
or al,60h
out 11h,al
.part2:
mov al,0h
out 44h,al
.part3:

mov al,21h
out 47h,al 
.part4:
mov al,41h
out 45h,al

mov al,3C ;38400bps
out 44h,al
.part5:
in al,45h
.part6:
mov ah,al
and al,2 ; bit 1
cmp al,2
jne .part6n
mov al,ah
and al,18h ;bits 4 & 5
cmp al,0 ;
je noerror
in al,44h
jmp .part5
noerror:
.part7:
in al,44h 
.part8: 
.part9:
mov al,0h
out 44h,al
.part10:
in al,11h 
and al,9Fh 
out 11h,al
;End

 

VI. And the Calculator ?

These method are good because you have a good access to the keyboard.For receiving, the verification of the port must be the quickest possible.You can put the verification in the Timer Interrupt 1Ch which on pc is called 18,2 times per seconds and on the calc nearly 50 times per seconds.

VII. Note of the Methods

These method are correct because if you want to send a byte and wait for a byte, you can de these without reconfiguring the comm port.

VIII. End Word
More help :
Superna@ifrance.com



- Na-prod Casio Project -
Thanks to Whyp, BradN & 2072 for TOUCHE