Jump to content
IGNORED

Out of the Pack - Controlling the Cassette Motor Control Bit on the A8


RSS Bot

Recommended Posts

The Cassette Motor Control(CMC) bit in the Port A Controller (PACTL ($D302)) address is going to be used as feed back from the Atari8 to the Arduino in the digital horn project. This bit controls the logic state of Pin 8 on the SIO port. This bit has been used to control the data cassette motor. If you're not using the bit to load data from the cassette it is free to be used for other purposes.

Put a music tape into a 410 and play 1 audio track through the Monitor or sound system. MIDIMAX uses it to turn itself on/off while accessing other devices in the SIO chain. Control a relay…why not?

MAPPING THE ATARI says to POKE 54018, 60 to turn the motor off and POKE 54018,52 to turn it on. Let's see, if (60-52 = 8) AND (8 is the decimal for Bit 3) then changing this bit turns on/off the CMC bit 3. This works until a program changes any of the other bits from their default value.

BASIC is not well equipped to do Boolean logic on bits. It can be done but can consume more time then I want to dedicate to the task. Machine language is adept at Boolean logic and can toggle CMC by using the EOR instruction. A BASIC USR call can toggle CMC with just 10 bytes.

EOR(exclusive OR)

The thing that makes EOR special is that when comparing 2 bits when both are True, the result is False.

EOR Logic Table
EOR| 0 | 1 |
0 | 0 | 1 |
1 | 1 | 0 |

Watch the logic:

60 = 00111100
8 = 00001000 EOR
52 = 00110100
8 = 00001000 EOR
60 = 00111100

Note that bit 3 (4th bit from the right) is on, off and on. The rest remained unaffected.

MAC/65 Assembly Language for the USR call looks like this.

10 ;USR CALL TO TOGGLE CASSETTE MOTOR
20 ;KEVIN PACKARD 09/2017
30 ;
40 ;X=USR(1536)
50 ;
0100 PACTL = $D302 ;bit 3 controls
0105 ; Cassette Motor
0110 ;
0120 *= $0600
0130 ;
0140 PLA
0150 LDA PACTL
0160 EOR #$08
0170 STA PACTL
0180 RTS
0190 .END


The code was assembled, the BYTES were converted to decimal, and then put into BASIC DATA statements. These were read into page 6 and run using A= USR(1536). The program could have been placed in a String and called at the string address. This still may get done if page 6 is required for something else.


The test.

All my Atari cassette drive belts slip so I decided to put an LED and 330ohm resistor between pin 8 and pin 4 for testing.




The BASIC program loads the code into Page 6. It then starts the loop to strobe the LED.

1 REM CASSETTE MOTOR CONTROL USR TEST
2 REM BY KEVIN PACKARD 9/2017
100 GOSUB 30000
110 X=USR(1536)
120 FOR X=1 TO 100:NEXT X
130 GOTO 110
29999 REM LOAD MOTOR CONTROL USR
30000 RESTORE 30060
30010 FOR X=1536 TO 1545
30020 READ A
30030 POKE X,A
30040 NEXT X
30050 RETURN
30060 DATA 104,173,2,211,73,8,141,2,211,96

The FOR-NEXT delay was used to slow the blinking. When removed, the LED blinked at about 64.4 hertz. When Direct Memory Access (DMA) was turned off (POKE 559,0) the rate jumped to 94 Hz. Slow but fast enough.



What next

I wrote this USR for use in an Atari8 BASIC MIDI Data Monitor for the DH100 digital horn project. This should help set the specification for the Arduino interface programing and provide a method of testing the interface.

Attached thumbnail(s)
  • blogentry-37655-0-45218900-1506021073_th
  • blogentry-37655-0-05427700-1506021076_th


http://atariage.com/forums/blog/572/entry-14197-controlling-the-cassette-motor-control-bit-on-the-a8/
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...