Arduino Nano - simulate 1MHz pulse

Hello! Just a quick question: I am planning on using RS-232 ACIAs to send serial data to a 65c02 computer. Any (older) RS-232 chip supports no more than 2 MHz clock speeds per serial pulse and the newest chips only support up to 14MHz. In this instance, should I use a PWM pin to simulate the 1MHz clock required by the RS-232 chip? And what is the best way to ensure the Arduino waits until the PWM pin is done with its clock signal before moving on to the next step/bit?

Thanks everyone!

How about using the analog port to look at the PWM?

Are you actually going to use a MOS Technology 6551 Asynchronous Communications Interface Adapter (ACIA)?!?

(It has a built-in baud rate generator so what are you talking about doing with 1 MHz clock?)

I guess I could read the analog port as the square wave changes from the PMW and react based on that?

I had planned on using 6551: Major Brands : IC 6551 Asynchronous Communication Interface Adapter DIP 28-pin : ICs & Semiconductors since it's from Jameco when I order more parts for various things.

I think, and I may be very wrong, the ACIA needs a phi2 input (1-2MHz) to actually put a byte into its internal bus from a computer on D0-D7, then it is transferred between ACIAs via the actual baud rate on the serial transmit pin. Not entirely sure about this, though.

A complete "6502 computer" can accept RS232 serial data generated by any typical system, so why do you think you need more than one ACIA chip?

@Johnwasser: The ACIA chip requires the PHI2 clock for data transfers between the chip and a 650x processor. It must be the same PHI2 clock used by the processor.

Please tell us more about your 6502 computer.

The current way I have it set up it I have an Arduino sending serialized data to a VIA that the 65c02 reads from. The way I have the VIA setup, I have to rotate the actual serial bit (several times) that comes in and then reconstruct the byte in the 65c02's RAM. I was hoping I could use two ACIAs to accept the serial data and reconstruct the byte and then send the byte itself back to the 65c02 - hardware faster than software, I'm hoping, and I can set the baud rate so I don't have to deal with the Arduino sending bits up to 16x faster than the current speed of my 65c02.

I'm new at this, so it might be completely wrong!

Sounds like a Rube Goldberg type of solution to me. I would use one ACIA as it is intended to be used: a serial interface for the 65C02, and be done with it.

Oh I think I see what you're saying! - Use the ACIA attached to the 65c02 and just send data to its receive pin directly from the Arduino?


Cool! Yeah, good idea - I always miss the forest for the trees with these types of things. Would I have to slow down the Arduino sending data out, though? I don't know if 16MHz is too fast to send data for that ACIA chip to receive.

The Arduino can send serial data at any standard speed, from 300 to 115200 Baud (serial bits per second), using its built in ACIA (called a UART). The 16 MHz clock is for the Arduino CPU.

What you described before, apparently reading a port pin on your 65C22 VIA, is called "bit banged RS232" and is perfectly acceptable for the tiny amount of data you would be transferring.

Gotcha! Okay, perfect. I guess didn't realize the Serial.begin function is used also for sending data in and out of the Arduino on pin 1 and 2 - I've only ever used it as the serial monitor. Never even occurred to me... That makes perfect sense to me, now!

Okay, cool. I've heard about bit banging, but never read a technical description of what it was exactly. Just wanted to branch out after getting that (mostly) complete and interface with "correct hardware" - an external ACIA attached to the 65c02 data line.

Seems you will learn a lot from this project.

Do you have previous 6502 exposure?

My first own computer was an Apple II+, back in the days.
And recently I got a 6502 based system, but have not played with it yet.

Software serial can be used with most other pins on the Arduino, giving you a second but somewhat limited serial port.

Arduino pins TX and RX (normally 1 and 0) are usually reserved for bootloading and for the serial monitor.

@jremington Good to know. I just looked up the SoftwareSerial library and its associated code - I will definitely go that route, going forward. Thanks for the tips! A huge, huge help!!

@Whandall Not much 6502 experience, at all. I've always wanted to learn Assembly, even in college. Unfortunately my college sucked and we barely did any programming, even as a Comp Sci major. I found Ben Eater on YouTube and started with his videos to make a CPU from scratch. After messing around with that, I moved onto his videos about the 6502 hardware and software. Been making some modifications a la C64 to make it more usable, more RAM, adding in the serial bit banging (for now!), will add in the Ben Eater graphics card here sooner or later and go from there hopefully!

I was bitten by the 65C0x bug while living and working in Munich in the 1980s. The technical magazine MC had a special issue that described the "EMUF", a complete 65C04 computer with just a few chips. I had a lot of fun with that board, and still have both that issue of MC and EMUF, somewhere.

I'm following Ben Eaters videos too, they are very good.
My first exposure to a 6502 was a KIM-1,
at the university, which was brand new at the time.
I still have the parts of the Apple II+ (only lost the case) but they are not assembled,
and probably need some restoration.

This is another channel that I can recommend:

This guy is running a hardware turing machine to emulate a 6502 system running packman.

@jremington That's pretty cool! Yeah, I wish 65xx stuff was a little more prevalent/easier to get access to. Would be nice to just go down the street and pick up parts, rather than having to order stuff online and wait for it to ship, and hope you didn't forget something. :smiley:

@Whandall Oh wow, that's pretty cool! I was born in the early 90s, so anything that is 65xx - I think the first computer I used was probably Win98. Haha! Thanks for the other YouTube links! Always looking for more resources.

Just an extra tidbit…
The larger arduinos, often have more than one hardware serial port (e.g. MEGA 1280/2560 have 4, 1284 has two).

These will allow you to use the Serial Monitor as intended, while you connect your custom serial interface on one of the ‘extra’ ports.

If you’re a real masochist, you could use a SoftwareSerial port on the smaller Arduinos, but can paint yourself into a corner really quickly!

Cool! Thanks for the tip! Yeah, if SoftwareSerial gives me trouble I will look at getting one of the larger ones. Thanks again!!