RSS Bot Posted September 21, 2017 Share Posted September 21, 2017 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 = 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 TableEOR| 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 |Watch the logic:60 = 00111100 8 = 00001000 EOR52 = 00110100 8 = 00001000 EOR60 = 00111100Note 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 MOTOR20 ;KEVIN PACKARD 09/201730 ;40 ;X=USR(1536)50 ;0100 PACTL = $D302 ;bit 3 controls0105 ; Cassette Motor0110 ;0120 *= $06000130 ;0140 PLA0150 LDA PACTL0160 EOR #$080170 STA PACTL0180 RTS0190 .ENDThe 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 TEST2 REM BY KEVIN PACKARD 9/2017100 GOSUB 30000110 X=USR(1536)120 FOR X=1 TO 100:NEXT X130 GOTO 11029999 REM LOAD MOTOR CONTROL USR30000 RESTORE 3006030010 FOR X=1536 TO 154530020 READ A30030 POKE X,A30040 NEXT X30050 RETURN30060 DATA 104,173,2,211,73,8,141,2,211,96The 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 nextI 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) http://atariage.com/forums/blog/572/entry-14197-controlling-the-cassette-motor-control-bit-on-the-a8/ Link to comment Share on other sites More sharing options...
Recommended Posts