6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 15, 2024 10:15 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: 6551 ACIA test program
PostPosted: Fri Jul 19, 2019 9:05 pm 
Offline

Joined: Sun Mar 05, 2017 4:31 pm
Posts: 36
Hey all!
This is my second attempt at building a 6502 based computer. My last attempt was not very succesful so I still consider myself very much a newby.

At the moment my computer consists of a 65c02 CPU, 32k ROM (AT28C256) and a 6551 ACIA.
I am using the memory map recommended in the primer found on 6502.org.
Before hooking up the ACIA I performed a NOP test by filling the rom with EA and pointing the cpu to the start of the rom, letting it count through all the adresses to confirm my rom was hooked up correctly.
Then I added the ACIA to my build, and this is where i'm at now.
To recieve this serial data I have an ftdi friend (https://learn.adafruit.com/ftdi-friend/overview) which supports rts and cts, so i hooked up those to my serial header accordingly (crossing over the signals). I did the same for the data lines. The other handshaking lines dtr, dsr and dcd I pulled low.

Before adding more to my computer I would like to test what I have built. I think the best way to do this is to write a simple program to the rom that initializes the ACIA, and transmits some text over serial, 'Hello world' for example :D .
I am just starting out learning 6502 assembly, so I'm a bit lost as where to start. I understand I need to write to the byte to the control register of the ACIA to initialize it, and then I need to write the byte for each letter of my message to the transmit register.

So my question then: Can anyone point me to a good source to learn more about programming the acia. Or can anyone help me in writing the code I described.
Thanks :P

Edit: I added a picture :)
Attachment:
File comment: picture of my progress
6502SBC.png
6502SBC.png [ 498.57 KiB | Viewed 1958 times ]


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 19, 2019 10:18 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1385
sepseel wrote:
Hey all!
This is my second attempt at building a 6502 based computer. My last attempt was not very succesful so I still consider myself very much a newby.

At the moment my computer consists of a 65c02 CPU, 32k ROM (AT28C256) and a 6551 ACIA.
I am using the memory map recommended in the primer found on 6502.org.
Before hooking up the ACIA I performed a NOP test by filling the rom with EA and pointing the cpu to the start of the rom, letting it count through all the adresses to confirm my rom was hooked up correctly.
Then I added the ACIA to my build, and this is where i'm at now.
To recieve this serial data I have an ftdi friend (https://learn.adafruit.com/ftdi-friend/overview) which supports rts and cts, so i hooked up those to my serial header accordingly (crossing over the signals). I did the same for the data lines. The other handshaking lines dtr, dsr and dcd I pulled low.

Before adding more to my computer I would like to test what I have built. I think the best way to do this is to write a simple program to the rom that initializes the ACIA, and transmits some text over serial, 'Hello world' for example :D .
I am just starting out learning 6502 assembly, so I'm a bit lost as where to start. I understand I need to write to the byte to the control register of the ACIA to initialize it, and then I need to write the byte for each letter of my message to the transmit register.

So my question then: Can anyone point me to a good source to learn more about programming the acia. Or can anyone help me in writing the code I described.
Thanks :P

Edit: I added a picture :)
Attachment:
The attachment 6502SBC.png is no longer available



You're welcome to try my Micromon monitor code. It will initialize and setup a full duplex interrupt-driven and buffered BIOS for the 6551. The monitor has enough features to be quite useful. It's also small... about 1.75KB in total.

Attachment:
MicroMon.asm [75.95 KiB]
Downloaded 347 times

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 19, 2019 10:20 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
sepseel wrote:
Before adding more to my computer I would like to test what I have built. I think the best way to do this is to write a simple program to the ROM that initializes the ACIA, and transmits some text over serial, 'Hello world' for example :D .
I am just starting out learning 6502 assembly, so I'm a bit lost as where to start. I understand I need to write to the byte to the control register of the ACIA to initialize it,

You'll need to write to the command register also.

Quote:
and then I need to write the byte for each letter of my message to the transmit register.

So my question then: Can anyone point me to a good source to learn more about programming the ACIA. Or can anyone help me in writing the code I described.

Like most I/O ICs, there are kind of a lot of parts to it, but none of them are particularly complicated. Just get familiar with the data sheet's info. This is from my 6502 interrupts primer:
Code:
SETUP_ACIA:
        STZ  ACIA_STAT   ; Reset ACIA by storing 0 in its status register.

        LDA  #00011110B  ; Set for 1 stop bit, 8 data bits, 9600 bps by
        STA  ACIA_CTRL   ; storing the number in the control register.

        LDA  #00001001B  ; No parity or rcv echo, RTS true, receive IRQ but no
        STA  ACIA_COMM   ; transmit IRQ, set DTR true.  Store in command register.

        RTS
 ;-------------

but you might want to modify that for a different bit rate for example. I was using it at 115.2kpbs this week for a work project.

My RS-232 primer has a few paragraphs about 30% of the way down the page about a bug in the WDC W65C51N, discovered by forum member floobydust (who posted above while I was writing), in that the transmit-register-empty bit is stuck in the "on" state, meaning you can't use it to see when it's safe to hand the ACIA another byte to transmit. There's a link there to the topic, and to forum member GaBuZoMeu's excellent work-around which uses PB6 of a 65c22 VIA. My workaround used a VIA timer, but his is better.

_________________
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  
PostPosted: Fri Jul 19, 2019 11:37 pm 
Offline

Joined: Sun Mar 05, 2017 4:31 pm
Posts: 36
Hey, thanks for the responses!

[quote GARTHWILSON]
My RS-232 primer has a few paragraphs about 30% of the way down the page about a bug in the WDC W65C51N, discovered by forum member floobydust (who posted above while I was writing), in that the transmit-register-empty bit is stuck in the "on" state, meaning you can't use it to see when it's safe to hand the ACIA another byte to transmit. There's a link there to the topic, and to forum member GaBuZoMeu's excellent work-around which uses PB6 of a 65c22 VIA. My workaround used a VIA timer, but his is better.
[/quote]


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 19, 2019 11:37 pm 
Offline

Joined: Sun Mar 05, 2017 4:31 pm
Posts: 36
Hey, thanks for the responses!

Quote:
My RS-232 primer has a few paragraphs about 30% of the way down the page about a bug in the WDC W65C51N, discovered by forum member floobydust (who posted above while I was writing), in that the transmit-register-empty bit is stuck in the "on" state, meaning you can't use it to see when it's safe to hand the ACIA another byte to transmit. There's a link there to the topic, and to forum member GaBuZoMeu's excellent work-around which uses PB6 of a 65c22 VIA. My workaround used a VIA timer, but his is better.

I read about that in your primer, but i am using the R6551AP, does this chip have the same bug?


Quote:
This is from my 6502 interrupts primer:

I feel like i should go and read that one too... oops

After posting this i also came across this article which i found very helpfull: https://www.atarimagazines.com/compute/ ... 1_ACIA.php,
I'm going to try to adapt the code there to try on my machine.
With the help of the tables in that article i found that for an 8 bit word with one stop bit and no parity at a baud rate of 9600, the command register needs to have either $C2 or $82, and the control register needs $1E, is this correct?

(I was having a hard time with the post editor as you can tell :lol: )


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 20, 2019 12:53 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
sepseel wrote:
I read about that in your primer, but i am using the R6551AP, does this chip have the same bug?

No; WDC's is the only one with the bug of the transmit-register-empty bit being stuck. Bill Mensch told me it worked fine in simulation before it went to silicon, but there was a race condition the simulation software didn't catch. (WDC uses a popular silicon simulation software that apparently many chip makers use.)

On only issue I know about regarding your R6551 is what I put in the RS-232 primer:

    A note should be made here regarding CTS and the 6551. An applications note I have here for the Synertek NMOS 6551, as well as the '87 Rockwell data book's NMOS 6551 pages say that transmission of an already-started frame will stop immediately when CTS is taken false, the byte will be lost, and the TD line will go to marking. I consider this to be either a serious bug, or an idiotic part of the original NMOS design. The same Rockwell book says that the CMOS 65c51 will finish the already-started byte before halting transmission after CTS goes false. (IOW, they corrected that problem when they did the CMOS design.) The other data sheets I have only say CTS must be true for the ACIA to transmit, without giving details of what happens when CTS is taken false in the middle of a frame. My expectation then is that regardless of brand, the CMOS ones generally will finish the frame whereas the NMOS ones won't. If it matters in your use, you will want to experiment with the particular brand of 6551 you have in order to make sure your program operates it correctly so as not to lose data. If the NMOS 6551 is interrupted during a frame transmission, the program will have to give it the same byte again to transmit when CTS goes true. I have used a couple of different brands of 65c51 (ie, CMOS) for decades and never had that trouble with it. In fact, everything I've ever done with the 65c51 worked on first try, except when I lacked a capacitor in the crystal circuit. (If you're using just a crystal and not a separate oscillator, the crystal goes from pin 6 to pin 7 of the DIP, but you need a 22pF capacitor from pin 6 to ground.) The only thing I don't like about the 65c51 is that a couple of the controls are merged into the same control bit, where it would be nice to be able to control them separately instead. (Caveat: I have not used WDC's 65c51 which has a different transmit bug mentioned six paragraphs up.)


Quote:
Quote:
This is from my 6502 interrupts primer:

I feel like i should go and read that one too... oops

After posting this i also came across this article which i found very helpful: https://www.atarimagazines.com/compute/ ... 1_ACIA.php,
I'm going to try to adapt the code there to try on my machine.
With the help of the tables in that article i found that for an 8 bit word with one stop bit and no parity at a baud rate of 9600, the command register needs to have either $C2 or $82, and the control register needs $1E, is this correct?

That's good for the control register, but do look at the various options for the command register in the data sheet. You'll probably want something like 09.

_________________
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  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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: