6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Mon Oct 07, 2024 2:20 am

All times are UTC




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Sep 04, 2013 10:31 pm 
Offline

Joined: Mon Apr 16, 2007 6:04 am
Posts: 155
Location: Auckland, New Zealand
Hello, I am making a new general purpose 6502 machine. The idea is to build a machine I can use to enter and run all the programs from the 80s Usborne books around at that time (that I fondly remember and am busy buying on eBay when I see them). Books like "Computer Space Games" and "Computer Battle Games" and so on. All simple little games really.

The machine has a 6502 running at 1MHz, 16K of RAM, 32k of ROM and various IO. On the main board is a 6522 VIA I am using for the keyboard and other things (speaker/bleeper, stopping the processor using the Woz circuit when a debug bit is set), an 8 bit latch with LEDs attached (blinken lights - useful for debugging) and a 6551 CIA which I am using to do my video display. For that I am using a Atmel based video generator from Batsocks: http://www.batsocks.co.uk/products/Other/TellyMate%20TTL%20Kit.htm

I was going to use my own Arduino based system I have previously used in an Arduino port of the Taipan! game but the Batsocks one uses a better processor and give me a higher resolution but still works in the same way as my Arduino one.

It uses TTL serial so I have it connected to the 6551 to drive it. The actual machine will have further I/O added later as additional boards. The Batsocks outputs a composite video signal that I have going to a little LCD monitor.

The issue I have is when I send data to the display it is all garbled. But in an odd way. Upper/lower case characters are sometimes outputted fine. Numbers and symbols are not.

So I am trying to output: "ORWELL V0.1 ABCDEFGHITJKLMONOPQRSTUVWXYZ 0123456789 abcdefg"
But I get: "OÒ×ELL Ö°.± ABCDEFGHIÔJKLMONOÐÑÒÓÔÕÖ×ØÙÚ °±²³´µ¶·¸¹ abcdefg"

Yes, I have a typos in the alphabet! ORWELL is the name of the machine by the way since it's a good name for a machine that's meant to be from 1984!

At first I thought it was a baud rate issue or something to do with the crystal (and 22pF cap). I replaced the crystal with a can oscillator and it didn't help.
The baud rates are correct. I can change the rate and I still get the same sort of garbled display if the receiving end is set to the same rate. I am using 8 N 1 by the way.

If I drive the display module from a different serial source (an Arduino) it displays fine.

I rigged up a MAX232 and piped the serial output from the CIA into my PC serial port (and old PC with a real port since I use the same one to run the ROM burner though it's real parallel port). The output I get on the PC matches that on my little screen. So I know the serial I am getting out is garbled. The string looks correct in the code I am burning to the ROM.

But I can't figure out why? On the CIA I have /CTS wired to ground. I haven't done anything with the other pins. I think I have it configured to be no parity, no echo, no interrupts.
one thing I did notice this morning is the /IRQ line seems to be low with the odd positive pulse. That seems odd? I have no interrupt handler in the code yet. The code I am using is below.

The machine is at the very early stages so this is just some code to make things work for testing. If just counts up on the LEDs on the I/O port, toggles the pins on the VIA back and forth and outputs the string. Sorry for the messed up comments formatting.

Code:
interrupt   = $FFFE        ; Interrupt vector.

IO         = $6000        ; Top of I/O space. 8 bit buffer.

via1        = $5000        ; VIA 1 I/O.
via1_b      = via1 + $0    ; VIA port b.
via1_a      = via1 + $1    ; VIA port a.
via1_bdir   = via1 + $2    ; VIA port b direction 1 = output.
via1_adir   = via1 + $3    ; VIA port a direction 1 = output.
via1_pcr    = via1 + $C    ; VIA peripheral control register.
via1_ier    = via1 + $E    ; VIA interrupt enable register.

cia1        = $4800        ; CIA 1 I/O.
cia1_d      = cia1 + $0    ; CIA data register.
cia1_s      = cia1 + $1    ; CIA reset/status register.
cia1_cm     = cia1 + $2    ; CIA command register.
cia1_ct     = cia1 + $3    ; CIA control register.


count       = $3FFF        ; Counter.

    .ORG rom_start

    ;Initilisation.
    LDA #$00         ; Load ACC with 0.
    STA count        ; Set the counter.

    ; Set VIA1 port up.
    LDA #$FF            ; Load ACC with b11111111.
    STA via1_adir        ; Set VIA port a all output.

    ; Set up serial output.
    LDA #$1F                 ; Set up for 19200/8/1.
    ;LDA #$1E                ; Set up for 9600/8/1.
    ;LDA #$1C                ; Set up for 4800/8/1.
    ;LDA #$1A                ; Set up for 2400/8/1.

    STA cia1_ct          ; Write to CIA control register.
    LDA #$0B             ; Set up N parity/echo off/rx int off/dtr active .
    STA cia1_cm         ; Write to CIA command register.

; Simply loop around incrementing the counter and twiddling bits on the VIA and sending serial data.
loop

    INC count        ; Simply increment the counter.
    LDA count        ; Load the counter.
    STA IO            ; Write to the IO port.

    LDA #$55         ; Data b01010101.
    STA via1_a       ; Push it to the VIA port a.

    LDA #$AA         ; Data b10101010.
    STA via1_a       ; Push it to the VIA port a.


    LDA string1     ; Load the length of the string into the accumulator.
    BEQ done        ; Check if it is zero length.
    LDY #$0         ; Set index to the first character.

output_string1
    LDA string1 + $1, Y    ; Load up the next character.
    JSR send_serial        ; Send the character.
    INY                    ; Increment.
    CPY string1            ; Have we copied them all?
    BNE output_string1     ; No so keep going.
done   
   JMP loop

; Strings.
string1    .STR "ORWELL V0.1 ABCDEFGHITJKLMONOPQRSTUVWXYZ 0123456789 abcdefg"

; Serial send subroutine. Bung the byte to send in A.
send_serial
    PHA                     ; Save accumulator.
cia1_Wait_TX
    LDA cia1_s             ; Read CIA staus register.
    AND #$10                ; Check if the TX buffer is empty.
    BEQ cia1_Wait_TX        ; Wait if not.
    PLA                      ; Restore accumulator.
    STA cia1_d              ; Send to CIA data register.
    RTS                     ; Return.

    .ORG reset
    .WORD rom_start


There must be something blatantly wrong I am doing but I can't see it!

Any thoughts of advice? What I was going to try next is putting the same data byte I am sending to the CIA to my debug LEDs to see what it looks like and also trying to capture the sending of the byte sent from the serial output to see what that is.

Thanks!

Simon


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 11:38 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8521
Location: Southern California
It looks like you have a problem with the data line connections to the ACIA, but I can't quite figure it out. First I was looking for maybe a couple of bits switched, and then it looked like a problem with D5 and D7 but testing that further didn't pan out either. I might not be looking at the same character chart you're using though. How's the construction?

BTW, for terminology, the CIA (6526 Complex Interface Adapter) is not the same as the ACIA (6551 Asynchronous Communications Interface Adapter). You're using the ACIA, not the CIA.

_________________
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: Wed Sep 04, 2013 11:51 pm 
Offline

Joined: Mon Apr 16, 2007 6:04 am
Posts: 155
Location: Auckland, New Zealand
GARTHWILSON wrote:
It looks like you have a problem with the data line connections to the ACIA, but I can't quite figure it out. First I was looking for maybe a couple of bits switched, and then it looked like a problem with D5 and D7 but testing that further didn't pan out either. I might not be looking at the same character chart you're using though. How's the construction?

BTW, for terminology, the CIA (6526 Complex Interface Adapter) is not the same as the ACIA (6551 Asynchronous Communications Interface Adapter). You're using the ACIA, not the CIA.


Construction is dodgy breadboards and wires everywhere I'm afraid. I am busy drawing up the circuits in Eagle (which I am learning as I go) and will have boards made eventually. I did check the data wiring as well and it seems correct although I am taking D6 and D7 from a different part of the breadboard though since I ran out of holes but we're only talking a difference of a few cm and I am using the same length wires everywhere. At the slow speed I am going I wouldn't think that matters anyway?

I'll try mirroring each byte to my debug output and also maybe add in a wait for keypress between bytes so I can see what each byte actually is. Will do that tonight once I am home.

The little character/video generator uses Code page 437 (http://en.wikipedia.org/wiki/Code_page_437) but you can upload other sets to it. I am hoping to do that on the machine when it's done so I can do a character based graphics mode. I did check early on it did actually have the right character set loaded which I confirmed by hooking it up to an Arduino and that worked fine.

Simon

_________________
My 6502 related blog: http://www.asciimation.co.nz/bb/category/6502-computer


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 12:45 am 
Offline

Joined: Sat Oct 20, 2012 8:41 pm
Posts: 87
Location: San Diego
Quote:
So I am trying to output: "ORWELL V0.1 ABCDEFGHITJKLMONOPQRSTUVWXYZ 0123456789 abcdefg"
But I get: "OÒ×ELL Ö°.± ABCDEFGHIÔJKLMONOÐÑÒÓÔÕÖ×ØÙÚ °±²³´µ¶·¸¹ abcdefg"

Looks like chars A thru O are correct but starting at P it gets off track. Since O is $4F and P is $50 that means you have some problems with some combinations of bits 4,5,6 or 7. For a test in software you could mask bit 7 low to see only standard chars and narrow it down from there.


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 1:09 am 
Offline

Joined: Mon Apr 16, 2007 6:04 am
Posts: 155
Location: Auckland, New Zealand
The data bus must be mostly correct since writing data to anything else works fine. I will try buzzing through the actual pins on the IC though. Perhaps I have a faulty wire? Or a shorted breadboard? I once bought one that turned out to have two rows shorted internally. That was a real bugger to find and caused all sorts of headaches.

Simon

_________________
My 6502 related blog: http://www.asciimation.co.nz/bb/category/6502-computer


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 4:50 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8415
Location: Midwestern USA
Simon wrote:
The data bus must be mostly correct since writing data to anything else works fine. I will try buzzing through the actual pins on the IC though. Perhaps I have a faulty wire? Or a shorted breadboard? I once bought one that turned out to have two rows shorted internally. That was a real bugger to find and caused all sorts of headaches.

Simon

The answer is hiding behind that occasional IRQ. 8) Hint: the 6551 doesn't have a transmit FIFO like more advanced UARTs, such as the 16550 and 26C92. If the MPU writes to the transmitter before the previous byte has been shifted out you may get an error. Verify that the transmitter is ready to accept a byte before you give it one.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 4:53 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8521
Location: Southern California
He's doing that in his cia1_Wait_TX loop.

_________________
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: Thu Sep 05, 2013 4:54 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1738
Location: Sacramento, CA
The data bit 7 going to your 6551 is mirroring data bit 4. In other word, anytime bit 4 is low, bit 7 is low. This appears to print your sample text correctly. Any character with bit 4 high, results in bit 7 being high also. These are the corrupted characters and they are not the DOS extended ASCII, but the ANSI Extended (Windows) characters.

I used the graphics on this page:
http://www.cplusplus.com/doc/ascii/

to map the printed characters. Any HEX value 3x results in Bx being printed (33 prints B3). Likewise, any 5x results in Dx (53 prints D3).

Hopefully just a wiring issue.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 5:31 am 
Offline

Joined: Mon Apr 16, 2007 6:04 am
Posts: 155
Location: Auckland, New Zealand
8BIT wrote:
The data bit 7 going to your 6551 is mirroring data bit 4. In other word, anytime bit 4 is low, bit 7 is low. This appears to print your sample text correctly. Any character with bit 4 high, results in bit 7 being high also. These are the corrupted characters and they are not the DOS extended ASCII, but the ANSI Extended (Windows) characters.

I used the graphics on this page:
http://www.cplusplus.com/doc/ascii/

to map the printed characters. Any HEX value 3x results in Bx being printed (33 prints B3). Likewise, any 5x results in Dx (53 prints D3).

Hopefully just a wiring issue.

Daryl


BINGO! That was it. Thank you so much. I could see on the scope easily D7 and D4 were mirrored when I looked. I checked the wiring and yes, I had an error. I swear I checked all the wiring! But I missed that one. I am using a 74HC373 as an output buffer and the pin arrangement is convoluted. I should switch to a 573 with input all on one side and output on the other. Less likely to cock that up!

Right, onward to keyboard input next.

Thanks again!

Simon

_________________
My 6502 related blog: http://www.asciimation.co.nz/bb/category/6502-computer


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 12:13 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1738
Location: Sacramento, CA
You're welcome. I'm glad it was an easy fix!

Daryl


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 3:18 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8415
Location: Midwestern USA
GARTHWILSON wrote:
He's doing that in his cia1_Wait_TX loop.

I was trying to read the code but due to failing eyesight (more about that in another post) I can no longer see text with light contrast. So I was thinking when Simon mentioned that he wasn't interrupt-driving the transmitter that perhaps he wasn't polling it as well.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 3:19 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8415
Location: Midwestern USA
Simon wrote:
I should switch to a 573 with input all on one side and output on the other. Less likely to cock that up!

Also, better to use 74AC logic...

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 7:51 pm 
Offline

Joined: Mon Apr 16, 2007 6:04 am
Posts: 155
Location: Auckland, New Zealand
BigDumbDinosaur wrote:
Simon wrote:
I should switch to a 573 with input all on one side and output on the other. Less likely to cock that up!

Also, better to use 74AC logic...

Oh, why is that? I get confused about the differences between all the logic families sometimes. Wikipedia in this case just says AC is better. Faster, less power?

The video is working great now. Started working on the matrix keyboard last night but didn't get too far yet (I have an TI-99/4A matrix keyboard and am trying the Oric circuit to hook it to the VIA. I want to get the core of the machine built onto a proper board soon so wiring problems should go away. The core board will just have keyboard input and video out as well as processor, RAM, ROM, etc. Later I will add other board for things like serial, printer, advanced sound and so on. I am keeping the system speed slow (1Mhz) so there should be issues linking such board with ribbons I hope.

Simon

_________________
My 6502 related blog: http://www.asciimation.co.nz/bb/category/6502-computer


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 8:14 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8521
Location: Southern California
74AC is about three times as fast as 74HC. It shouldn't matter at 1MHz with slow parts though, and with poor construction, faster slew rates may even cause more trouble. Use 74AC when you have a denser, faster design. 74ABT is even nicer, but unfortunately most of the parts are not available, especially in DIPs.

_________________
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 Sep 06, 2013 1:24 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8415
Location: Midwestern USA
Simon wrote:
BigDumbDinosaur wrote:
Simon wrote:
I should switch to a 573 with input all on one side and output on the other. Less likely to cock that up!

Also, better to use 74AC logic...

Oh, why is that? I get confused about the differences between all the logic families sometimes. Wikipedia in this case just says AC is better. Faster, less power?

Aside from the much shorter prop time, as Garth noted, 74AC has better fanout. The only thing to watch out for, as Garth also noted, is the fast switching speed may cause some ringing. You're not likely to run into this on a properly laid-out PCB, but might with wire-wrap and most likely will with perf board construction. I built my POC unit with 74AC and it's able to boot at 15 MHz if no I/O is expected (I/O devices can't handler that speed).

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

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