• Please review our updated Terms and Rules here

Small PET programming question

bitfixer

Veteran Member
Joined
Apr 6, 2011
Messages
679
Location
San Francisco, CA
Hi all,
Small programming question for the PET. The 'Diag Sense' line on the PET userport is connected to pin 9, PA7 on one of the 6520s. This line is an input by default, but the schematics I've seen indicate this line as bidirectional. Anyone know if it is possible to set this line as an output, and if so, how to write to it?
The purpose of this is that for a demo I'm working on, the CB2 line is used for handshaking while reading data in from the user port, and on the models with a speaker, this causes an annoying buzzing sound. The diag line and the CB2 line go to a nand gate and the output of that goes to the speaker, so if you ground the diag line, the buzzing stops. The workaround I had was to ground the diag line on the userport, but only after bootup, since the PET won't boot if you hold that line low at startup. Would be convenient if I could just set that line to output and write 0 to it.
Thanks for the help.
 
Hi Mike,
Something like this may work.

Set PA7 to Output

; Read the Control Register A and save to temp. location
LDA $E811
STA temp1 ; need to restore CRA later
; Clear bit 2 to enable read/write of Data Direction Reg
AND #$FB ; clear bit 2 without disturbing other bits
STA $E811 ; update CRA
; Update DDRA
LDA #$8F ; data for DDRA
STA $E810 ; set bit 7 in DDR to make it an output
; Set Register Operation back to Port A
LDA temp ; get original CRA data
STA E811 ; restore CRA to r/w of Port A
; Read Port A and save to temp2
LDA E810 ; read Port A
STA temp2 ; in case need to restore Port A later
; Write to Port A and clear bit 7 to disable speaker
AND #$7F ; clear bit 7 without disturbing others
STA $E810 ; write to Port A
 
Back
Top