Programming Parallel Port?

GFA, ASM, STOS, ...

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

AtariOwl
Atari freak
Atari freak
Posts: 55
Joined: Mon Nov 03, 2003 2:04 pm

Programming Parallel Port?

Postby AtariOwl » Mon Dec 05, 2016 12:07 am

Hello Guys

The project is progressing but i have hit something of an impasse.

I should like to control LEDs from the parallel port, but when i try to start, all the values switch high and stay there


Does anybody have any code to write different values out to the parallel port without any kind of response needed from the port?

Any help much appreciated

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2759
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Programming Parallel Port?

Postby AtariZoll » Mon Dec 05, 2016 12:32 pm

Writing to parallel port is 2 step process. First need to write parallel ports register select value, what is 15 to $FF8800, then value what you want to appear there to $FF8802. Byte writes.
What is written to port selector $FF8800 remains there until next write there. But you need to refresh it, because TOS writes there 14 in every V-blank for checking floppy disk change.
So, best way would be to first disable interrupts, then do writes, then reenable interrupts.
English language is like bad boss on workplace: it expecting from you to strictly follow all, numerous rules, but self bending rules as much likes :mrgreen:

User avatar
Cyprian
Atari God
Atari God
Posts: 1398
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Programming Parallel Port?

Postby Cyprian » Mon Dec 05, 2016 2:04 pm

did you switch YM2149 Port B to OUT?

Code: Select all

-------+-----+-----------------------------------------------------+----------
$FF8800|byte |Read data/Register select                            |R/W
       |     |7 Mixer Control                   BIT 7 6 5 4 3 2 1 0|
       |     |  Port B IN/OUT (1=Output) -----------' | | | | | | ||
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Aranym / Steem / Saint
http://260ste.appspot.com/

AtariOwl
Atari freak
Atari freak
Posts: 55
Joined: Mon Nov 03, 2003 2:04 pm

Re: Programming Parallel Port?

Postby AtariOwl » Mon Dec 05, 2016 11:02 pm

Hello Gentlemen

This is what i have been doing

1. Switch to SUPER and push a0,d0 onto the stack
PARSET equ $FF8800
PARDAT equ $FF8802

2

Code: Select all

   sub.l         a0,a0
   
      move.b      #15,d0         ; no they were both 15 but i tried both 15 and bit 7
      movep.b      d0,PARSET(a0)
      
      move.b      #15,d0
      movep.b      d0,PARDAT(a0


3. Return from SUPER and pop d0 and a0 off the stack

Then when i have been wanting to updat ethe data sent to the parallel port i have jb.een running this procedure again. I have no delays in my code... i have not been disabling interrupts

What happens is that the output on the parallel port is 0 until i call this the first time, then it sets all the output to 4.84v,seemingly no matter what i set 8802 to and this never changes again.


If i am understanding correctly, what is sent out SHOULD remain, but status register needs to be set again because of the VBL reset?


Also i have read conflicting info if Port B is selected by bit 7 or the value 15

Is super needed?
Last edited by AtariOwl on Tue Dec 06, 2016 1:34 pm, edited 1 time in total.

AtariOwl
Atari freak
Atari freak
Posts: 55
Joined: Mon Nov 03, 2003 2:04 pm

Re: Programming Parallel Port?

Postby AtariOwl » Tue Dec 06, 2016 11:50 am

When i look i see i was not sending .b but a .w

Which could well explain it since the low byte will be going to ff8801, d'oh

i'll try again at the weekend

User avatar
Cyprian
Atari God
Atari God
Posts: 1398
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Programming Parallel Port?

Postby Cyprian » Tue Dec 06, 2016 1:37 pm

try this code. I'm not sure whether it works but it should activate every even Centronics Data pin.

Code: Select all

   clr.l   -(SP)
   move.w   #$20,-(SP)
   trap   #1      ;   Super
   addq.l   #6,SP

   move.w   #$2700,SR   ;   Stop All Interrupts


   lea   $FFFF8800.w,A0   ;   YM Register
   lea   $FFFF8802.w,A1   ;   YM Data

   
   move.b   #7,(A0)      ;   Set 7th YM Register - Mixer control - I/O enable
   move.b   (A0),D0      ;   Read previous value
   bset.b   #7,D0      ;   Activate PortB Out
   move.b   D0,(A1)      ;   Write a new value

   move.b   #15,(A0)   ;   Set 15th YM Register - I/O PortB
   move.b   #$AA,(A1)   ;   Write a new value
   
Loop
   bra.b Loop



AtariOwl wrote:Also i have read conflicting info if Port B is selected by bit 7 or the value 15

should be the most significant bit in 7th YM register

"15" means "$0F":
- OFF: Channel A Tone / Channel B Tone / Channel C Tone / Channel A Noise
- ON: Channel B Noise / Channel C Noise / A IN / Port B IN

Code: Select all

$FF8800|byte |Read data/Register select                            |R/W
       |     |7 Mixer Control                   BIT 7 6 5 4 3 2 1 0|
       |     |  Port B IN/OUT (1=Output) -----------' | | | | | | ||
       |     |  Port A IN/OUT ------------------------' | | | | | ||
       |     |  Channel C Noise (1=Off) ----------------' | | | | ||
       |     |  Channel B Noise --------------------------' | | | ||
       |     |  Channel A Noise ----------------------------' | | ||
       |     |  Channel C Tone (0=On) ------------------------' | ||
       |     |  Channel B Tone ---------------------------------' ||
       |     |  Channel A Tone -----------------------------------'|
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Aranym / Steem / Saint
http://260ste.appspot.com/

AtariOwl
Atari freak
Atari freak
Posts: 55
Joined: Mon Nov 03, 2003 2:04 pm

Re: Programming Parallel Port?

Postby AtariOwl » Tue Dec 06, 2016 3:06 pm

Hi This looks good

Now


move.b #15,(A0) ; Set 15th YM Register - I/O PortB
move.b #$AA,(A1) ; Write a new value

This is clear and its what i think i was trying to do, i'm happy i understand this

What i don't understand is this


move.b #7,(A0) ; Set 7th YM Register - Mixer control - I/O enable
move.b (A0),D0 ; Read previous value
bset.b #7,D0 ; Activate PortB Out
move.b D0,(A1) ; Write a new value

I think this is where i got very confused

I'll try it
I think i must not have been initiating properly

Thank you

User avatar
Cyprian
Atari God
Atari God
Posts: 1398
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Programming Parallel Port?

Postby Cyprian » Tue Dec 06, 2016 3:42 pm

We inform YM that we have to read or modify YM Register 7:
move.b #7,(A0) ; Set 7th YM Register - Mixer control - I/O enable

Here we read current value of that register:
move.b (A0),D0 ; Read previous value

Here we set Bit number 7 - which is responsible for set Port B (Centronics) to output. We don't touch other bits responsible for Port A and Audio channels:
bset.b #7,D0 ; Activate PortB Out

Here we write a new value to Register 7:
move.b D0,(A1) ; Write a new value

is it ok? :)


if I'm not wrong, you have only once choose YM register:
move.b #15,(A0) ; Set 15th YM Register - I/O PortB

And now write needed values:
move.b #$AA,(A1) ; Write a new value
_wait_
move.b #$55,(A1) ; Write another value
_wait_
move.b #$12,(A1) ; Write another value
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Aranym / Steem / Saint
http://260ste.appspot.com/

AtariOwl
Atari freak
Atari freak
Posts: 55
Joined: Mon Nov 03, 2003 2:04 pm

Re: Programming Parallel Port?

Postby AtariOwl » Tue Dec 06, 2016 5:14 pm

That makes a lot of sense and explains my confusion over bit 7 and register 15

BUT

if i just want to modify the values sometimes... do i need to re initialise? if the program has gone off and done things inbetween? i would imagine yes?

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2759
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Programming Parallel Port?

Postby AtariZoll » Tue Dec 06, 2016 5:47 pm

There is no need to write in mixer register. It is set by TOS properly, and may only screw it - making floppy dead and like.
English language is like bad boss on workplace: it expecting from you to strictly follow all, numerous rules, but self bending rules as much likes :mrgreen:

User avatar
Cyprian
Atari God
Atari God
Posts: 1398
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Programming Parallel Port?

Postby Cyprian » Tue Dec 06, 2016 9:07 pm

AtariZoll wrote:There is no need to write in mixer register. It is set by TOS properly, and may only screw it - making floppy dead and like.

are you sure that "bset.b #7,D0" could disturb floppy?


AtariOwl wrote:if i just want to modify the values sometimes... do i need to re initialise? if the program has gone off and done things inbetween? i would imagine yes?


in this case every time you have to choose register 15 first and then write needed value to PortB:
move.b #15,(A0) ; Set 15th YM Register - I/O PortB
move.b #$AA,(A1) ; Write a new value

.....

move.b #15,(A0) ; Set 15th YM Register - I/O PortB
move.b #$55,(A1) ; Write another value

.....

move.b #15,(A0) ; Set 15th YM Register - I/O PortB
move.b #$12,(A1) ; Write another value
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Aranym / Steem / Saint
http://260ste.appspot.com/

AtariOwl
Atari freak
Atari freak
Posts: 55
Joined: Mon Nov 03, 2003 2:04 pm

Re: Programming Parallel Port?

Postby AtariOwl » Wed Dec 07, 2016 12:14 am

the bset didnt work

i changed
move.b (a0),d0
bset.b #7,d0

to

move.b #128,d0
or (a0),d0

and it worked


do we believe i don't need to do

Code: Select all

move.b   #7,(A0)      ;   Set 7th YM Register - Mixer control - I/O enable
   move.b   (A0),D0      ;   Read previous value
   bset.b   #7,D0      ;   Activate PortB Out
   move.b   D0,(A1)      ;   Write a new value


or just leave off the first line?
i dont want to stop the floppy

how would i renable interrupts?

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2759
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Programming Parallel Port?

Postby AtariZoll » Wed Dec 07, 2016 6:15 am

In ASM it would be:

Code: Select all


   move.w sr,-(sp)
   move.w   #$2700,sr
   move.b   #15,$FFFF8800.w
   move.b ToWrite(pc),$FFFF8802.w
   move.w (sp)+,sr


Value to write is at ToWrite. If not close to this snippet use absolute addressing (without (pc) ).
English language is like bad boss on workplace: it expecting from you to strictly follow all, numerous rules, but self bending rules as much likes :mrgreen:

AtariOwl
Atari freak
Atari freak
Posts: 55
Joined: Mon Nov 03, 2003 2:04 pm

Re: Programming Parallel Port?

Postby AtariOwl » Wed Dec 07, 2016 8:16 am

I see the interrupts are bits 8-10 of the Status Register and pushing popping the SR .. of course, i must have been tired last night

:)

Thank you


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 1 guest