6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 2:44 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: 6551 dificulties
PostPosted: Sun Mar 26, 2017 7:31 am 
Offline

Joined: Sat Mar 11, 2017 1:56 am
Posts: 276
Location: Lynden, WA
Ok, my Rockwell ACIA was a dud. Got it off ebay, and I get bus contention on the D7 data bus line. unhook the ACIA from that line, computer works. I noticed that that pin is floating all over the place at power up. I think it got zapped.

So, until I get suitable replacements, its back to the WDC parts I have.

Ok,I have a running program that just counts from 0 to 255 and starts over, and displays the result in binary on some LED's using the VIA. Works just fine.

I thought a good first test of the ACIA would be to just transmit the same byte to it that I am sending to the VIA.

I'm getting nothing out of the TXD line (watching for activity with scope)

Scope confirms that address decoding is correct (CS0 HIGH, CS1 LOW, R/W LOW at the same time as 00 on the RS lines).

PH2 and Baud rate clock both present and clean.

DSR DCD and CTS are tied low
RxD DTR RTS and XTL0 N.C.
1.8432 oscillator can on XTL1

I have no activity on the TxD line at all. I feel there is enough delay in my code to make the WDC65c51 bug not an issue.

here is my code. Comments MAY be wrong. I've been trying things so long I'm not sure I've been faithfull at updating them.

Code:
   *=$8000
start:   
   LDX    #$FF
   TXS
   
   LDA    #%00011110    ;ACIA control reg set for 1 stop, 8 data, 9600 baud
   STA   $5001      ;reset ACIA
   STA   $5011      ;setup control reg
   LDA    #%00001011   ;no parity, no echo, no transmitter IRQs, no reciever IRQ, enable tranciever   
   STA   $5010      ;setup command reg
   
   
   
   
   LDA    #$FF   ;load accumulator with all ones for VIA DDRs
   STA    $6003   ;set PORTA DDRsto all ones
   
   LDA    #$00   ;start counter at 0
   STA    $200   ;counter is in begining of 2page

counter:
   LDA    $200   ;get counter value
   STA    $6001   ;display counter value on port A of VIA
   STA   $5000   ;send to ACIA
   CLC
   INC    $200   ;increment the counter
   LDX    #$7D   ;put 1/4 ms in X
   JSR   DELAY
   JMP counter   
   

DELAY:
   LDY  #$FF       ; Put the desired value in X before JSR'ing to DELAY.
d1: 
   DEY
        BNE  d1
        DEX


Top
 Profile  
Reply with quote  
 Post subject: Re: 6551 dificulties
PostPosted: Sun Mar 26, 2017 7:55 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
How are the register-select (RS) lines connected? I see addresses $5001 and $5011, which is easy to do, but it seems unlikely that that's what you wanted. If you have A0 going to RS0 and A1 going to RS1 and the base address is $5000, the control register will be at $5003, not $5011. The "11" for register selects in the data sheet is in binary, not hex. The same kind of thing applies to the command register, at address $5002, not $5010.

Also, make sure the chip selects are not qualified by Φ2. They have to be valid and stable before Φ2 rises, or the thing won't work.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: 6551 dificulties
PostPosted: Sun Mar 26, 2017 8:12 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
A few other notes, all minor:

  • You already have $FF in X (for the TXS), so if you want to store that value elsewhere, just do an STX, rather than LDA #$FF, STA.

  • LDA #0, STA can be replaced with the single instruction STZ (STore Zero). (I think you have a CMOS 6502, ie, 65C02, right?)

  • There's no need to do a CLC before the INC. It's not the same as ADC #1. INC, DEC, INY, DEY, INX, and DEX do not use the C flag as an input or affect it as an output. (Also, they are always hex, not decimal, regardless of the D flag, which doesn't change anything this time but there will be future uses where you'll want to keep it in mind.)

  • If you wanted to do it without variables, you could use Y in place of address $200, and have the delay routine do a PHY...PLY so it can count with Y without losing it.

  • Again with the CMOS 6502, you can shorten the JMP counter with BRA (Branch Relative Always) counter and save a byte.

  • The DELAY routine is not finished. (Ok, maybe that one's not so minor.)

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: 6551 dificulties
PostPosted: Sun Mar 26, 2017 5:17 pm 
Offline

Joined: Sat Mar 11, 2017 1:56 am
Posts: 276
Location: Lynden, WA
I'm not on the lab right now, but I'm pretty sure you nailed it with the addressing. The binary/hex mashup is obvious now!

On the other stuff, the delay works (I got it from you!) that's a cut and paste error.

My use of memory as my counter is because this program was originally a way to test SRAM.

My use of CLC is a remnant from trying to get some stuff to work right earlier. I later solved said problem in hardware. I was curious if the incrementing instructions used it though, and you cleared that up.

I do have a CMOS part. I only just got around to discovering the added instructions. All my books except the one you recommended seem to predate that part.

Also, your optimization tips will be handy. I've been "sticking to what I know" because all this is still just to test the hardware, but I'm gonna need to know these things eventually!

Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: 6551 dificulties
PostPosted: Sun Mar 26, 2017 6:20 pm 
Offline

Joined: Sat Mar 11, 2017 1:56 am
Posts: 276
Location: Lynden, WA
The addressing screwup was it. I'm getting data out now.

RS232 decoder on scope shows its the correct output.

Now just need the new batch of Rockwell parts to get here.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6551 dificulties
PostPosted: Sun Mar 26, 2017 7:14 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Sounds good. It's good to hear it's working now.

Quote:
My use of memory as my counter is because this program was originally a way to test SRAM.

The JSR/RTS tests the RAM too, since the return address is saved on the stack in page 1. PHY...PLY will also use the stack.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: 6551 dificulties
PostPosted: Sun Mar 26, 2017 7:39 pm 
Offline

Joined: Sat Mar 11, 2017 1:56 am
Posts: 276
Location: Lynden, WA
Makes sense.

How much delay does one need to get around the WDC65c51's bug? do you just figure your baud rate times how many bits (10 in my current case) as the absolute minimum time between transmissions, and add some arbitrary extra time just to be safe? I'm still working my way through the forum thread on the matter, and my Rockwell parts won't be here for a week.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6551 dificulties
PostPosted: Sun Mar 26, 2017 8:18 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Dan Moos wrote:
How much delay does one need to get around the WDC65c51's bug? do you just figure your baud rate times how many bits (10 in my current case) as the absolute minimum time between transmissions, and add some arbitrary extra time just to be safe?

I think the only time you might need to add is to have at least one full additional Φ2 cycle. The very first byte doesn't need any delay before you send the 2nd byte, because the transmit register is transferred to the shift register, and the 2nd byte can be loaded into the transmit register right away to wait there and be ready for when the first byte is done being shifted out. After the 2nd one of course you'll need to do the delay because there's nowhere else for the '51 to store data that's waiting in line. From the data sheet, it looks like if you're running at 1MHz and doing 9600,8,N,1, you would need 1043 cycles from one store to the next store to the ACIA's data register. Adding a few more to make you feel good would have a negligible effect on the amount of time needed to transfer a file or message. Again, if you don't want the computer to have to twiddle its thumbs in a delay loop while waiting, you can set up a timer interrupt on a VIA.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: 6551 dificulties
PostPosted: Sun Mar 26, 2017 8:32 pm 
Offline

Joined: Sat Mar 11, 2017 1:56 am
Posts: 276
Location: Lynden, WA
Yeah, I had just discovered the timer interrupt trick a few minutes ago reading the relevant forum thread. seems like the way to go.

Just so I'm understanding how that works, do you basically have the timer send an interrupt at intervals the same length as the delay we talked about, and have the program look for that instead of the stuck bit? I.E., is it still a delay, but just one that runs in the background?


Top
 Profile  
Reply with quote  
 Post subject: Re: 6551 dificulties
PostPosted: Sun Mar 26, 2017 8:50 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
It would probably be best to set it up in one-shot mode, so it generates one interrupt per write to the counter high byte. When the counter rolls over, it generates the interrupt and keeps counting, but the counter interrupt will be disabled after that until you write to the counter high byte again, which you'll do immediately after storing the new byte in the ACIA's data register, so the delay always ends at the right time.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: