STM32 ARM Cortex M4 Apple-1 replica

13 posts / 0 new
Last post
Offline
Last seen: 1 year 6 days ago
Joined: Nov 30 2014 - 19:10
Posts: 35
STM32 ARM Cortex M4 Apple-1 replica

Ladies and Gentlemen,

let me introduce the final Mark1 of my Apple-1 replica, based on the STM32 ARM Cortex M4 microcontroller. As I explained in my other post about the emulator that is running on the STM32 board, this replica is inspired by the movie "The pirates of Silicon Valley". The prototype of the Apple -1 designed and built by Wozniak (Joey Slotnick) was enclosed in a wooden case, like the monitor Smile

There are many scenes where this prototype appears, but the most fun scene is when Woz presented this prototype to his boss at HP... You should watch that movie. But for now here it is my personal model.

The mother board is a STM32F401 Discovery, powered by an ARM Cortex M4 microcontroller at 84Mhz. It has 256KB of Flash and 64KB of SRAM. The board generates a composite video signal and uses a simple 2 bits DAC for the output to the monitor. The keyboard was borrowed by a vintage Macintosh 128K, the M0110, and it is interfaced to the mother board through an Arduino mini pro that translates the scancodes into serial ASCII characters.

The monitor is a simple vintage portable b/n TV put into a wooden case. This TV set has a video input, directly connected to the video output of the mother board.

THANKS TO ALL FOR THE PRECIOUS INFORMATION IN THIS SITE!

IMAGE(http://www.applefritter.com/files/Apple-1_STM32_Replica_001_0.jpg)

gsmcten's picture
Offline
Last seen: 6 years 5 months ago
Joined: Oct 4 2005 - 18:52
Posts: 2629
Re: STM32 ARM Cortex M4 Apple-1 replica

Very Nice!
Now all you have to do is give
it a nice coat of polyurethane
in a dazzling color. lol

Steven Smile

CWJ_Wilko's picture
Offline
Last seen: 3 months 1 week ago
Joined: Jun 2 2015 - 23:38
Posts: 289
Re: STM32 ARM Cortex M4 Apple-1 replica

Wonderful job - makes me want to take another crack at a replica.

Offline
Last seen: 1 year 6 days ago
Joined: Nov 30 2014 - 19:10
Posts: 35
Re: STM32 ARM Cortex M4 Apple-1 replica

Thank you guys, now it's time to try to add the support for the ACI. Tricky part. I would like to add a real-time write/read for the tape, but I have to redesign a bit part of the emulation flow. But this is the most fun part Smile

Offline
Last seen: 3 hours 6 min ago
Joined: Jun 5 2008 - 07:26
Posts: 478
Re: STM32 ARM Cortex M4 Apple-1 replica

One way to read cassette data from an emulator, is to have a separate real time task that runs off a periodic interupt and oversamples incoming data. This task can create a database with timing and data information embedded within as it samples a physical tape. If you want, you can make this file a standard format, such as AIFF, so you can play it back with any music player. The main emulator code must keep some kind of timing information (clock) that is instruction accurate. Using this clock, you can write code to index to the correct point in the database to read the correct input bit. The index into the file is based on the amount of time since the cassette recorder was started, subtracting off any time that it was paused or stopped.

Writing is a bit easier than reading, I'll leave that to your imagination.

This approach is probably easier than trying to make an emulator that executes instructions exactly in time with the real world, though there are advantages to that approach, especially if you are going to add other types of physical interfaces.

regards,
Mike Willegal

Offline
Last seen: 1 year 6 days ago
Joined: Nov 30 2014 - 19:10
Posts: 35
Re: STM32 ARM Cortex M4 Apple-1 replica

Hi Mike,

thank you for your reply. Yes I did something like that in my SEGA SC-3000 emulator, but it was done in Actionscript for FLASH. I was able to Load and Save data from/to a file. I would like to find a way to do this without using a files and store/read data directly to/from the tape.

I am testing several ways, of course it's a bit tricky because in the Apple-1 ACI everything was done via software. So the CPU timings and cycles are very important. Currently the STM32F401 board has a clock of 84MHz, and apparently it's a lot faster than a real Apple-1. I have 1 timer for the PAL/NTSC video generator and another timer that handles data coming from the keyboard.

The 6502 is run each frame for the specific number of cycles for a frame. This way works good for the execution of normal programs because it's synchronized to the video output and it can keep the clock speed (or at least it's approximately close). But when the CPU has to count cycles to create delays timings are imprecise.

So I have to count cycles during the execution of the instructions, and synchronize somehow the hardware to output data. Anyway, I know that this approach is very difficult but I would like to see if it's possible. Maybe I can try to port the emulator on a better MCu like the STM32F429 clocked at 180MHz.

Offline
Last seen: 1 year 6 days ago
Joined: Nov 30 2014 - 19:10
Posts: 35
Re: STM32 ARM Cortex M4 Apple-1 replica, ACI first test

Hi,

First I started to test the Output from the computer to the tape. I was able to obtain a reasonable signal coming out from an "OUTPUT" GPIO so I did a simple test.

I stored sixteen bytes in the memory from $0 to $F like this...
0: 0 1 2 3 4 5 6 7 8 9 A B C D E F

Then I started the ACI firmware ( C100R ) and then I saved those bytes to the tape with...
0.FW

I recorded the signal with Audacity, a sound editor, and exported the file as a PCM, 44100Hz, 16Bit Wav format. Is there somebody who can test this on the real hardware or an hardware replica?

By loading this with...
0.FR

it should read sixteen bytes from $0 to $F like above. Currently I tried to load this Wav file into MAME and it loads perfectly, but it's not the real hardware of course...

Thanks.

LINK: Test Wav 0.F

Offline
Last seen: 1 month 55 min ago
Joined: Oct 9 2011 - 12:54
Posts: 1353
Re: STM32 ARM Cortex M4 Apple-1 replica, ACI first test

OK, tested on a real Apple-1 with a real Apple-1 ACI which means no improvements for reliability (i.e better cap on the ACI, different ICs or additional decoupling caps on the main board). I loaded using an iPhone 6 (not S)

I took a picture of the screen, if you want I can email it to you, but it looked good.

basically this is the screen...

C100R
0.FR
\

0000: 00 01 02 03 04 05 06 07
0008: 08 09 0A 0B 0C 0D 0E 0F
@

Offline
Last seen: 1 year 6 days ago
Joined: Nov 30 2014 - 19:10
Posts: 35
Re: STM32 ARM Cortex M4 Apple-1 replica, ACI first test

Hi Corey986,

thank you so much for your help!

YES! that is the correct result! So The output waveform from my emulator should be good, and hopefully even on a tape should save correctly. Now I am working on the reading feature and i am doing not too bad. THere are problems in finding the right audio level... Sometimes bits are not read correctly, so I am on this.

But, may I ask you, if you can, to record something similar my example to an audio file and send it to me? I would like to try to load it here and see if it works Smile

So excited about this Apple-1 emulator Smile As soon as it's done I will record a demo video.

Offline
Last seen: 1 month 55 min ago
Joined: Oct 9 2011 - 12:54
Posts: 1353
Re: STM32 ARM Cortex M4 Apple-1 replica, ACI first test

Do you want me to send you a copy of Apple-1 basic I just made using real hardware in a wav file? PM me

Offline
Last seen: 1 year 6 days ago
Joined: Nov 30 2014 - 19:10
Posts: 35
Re: STM32 ARM Cortex M4 Apple-1 replica

Thank you for your help! Biggrin

Offline
Last seen: 1 year 6 days ago
Joined: Nov 30 2014 - 19:10
Posts: 35
Re: STM32 ARM Cortex M4 Apple-1 replica

Hi to All,

finally I upgraded my Apple-1 Replica with the support of cassettes. I built a tiny circuit that cleans the incoming audio signal and acts as a zero-crossing detector like the original one. The circuit is a bit different than the original ACI but it uses the same LM311 with a different configuration of resistors, a RC filter to bypass high frequencies of the oscillations during sign change, and the LED indicator.

It's possible to save and load data, but I still have the problem of the emulation speed that doesn't match perfectly the original hardware. Thus I can only load data saved from my emulator. I think I have to use a faster board, but anyway I am getting there Smile I had also used a trick to better generate the output the audio signal. Unfortunately the interrupt routine of the video stage delays a bit the emulation of the 6502 because of the video rendering routine. So the resulting saved waveform is irregular. While the emulator is saving or loading data it turns off the rendering engine and just shows lines according to the output signal toggling. This is not really the behaviour of the real Apple-1 but it's retroish Smile

I also added a mini piezo speaker so it's possible to hear the typical noise of data flowing Smile

Here there are new photos Smile

IMAGE(http://www.applefritter.com/files/Apple-1_Replica_ARM-Cortex_Inside.jpg)

IMAGE(http://www.applefritter.com/files/Apple-1_Replica_ARM-Cortex_Top.jpg)

IMAGE(http://www.applefritter.com/files/Apple-1_Replica_ARM-Cortex_Rear-panel.jpg)

IMAGE(http://www.applefritter.com/files/Apple-1_Replica_ARM-Cortex_Loading-0.jpg)

IMAGE(http://www.applefritter.com/files/Apple-1_Replica_ARM-Cortex_Loading-1.jpg)

Offline
Last seen: 1 year 6 days ago
Joined: Nov 30 2014 - 19:10
Posts: 35
STM32 Apple-1 Replica at Embedded World 2019
Thanks to #ST for hosting me into their booth at #EmbeddedWorld 2019, from the 26th to the 28th of February 2019 in Nuremberg Messer, Germany. Visit us in Hall 4A – booth 138, I will be there with my STM32 Apple-1 Replica and I will introduce my new ArcadeIT! System. I am proud and honored to be hosted by ST Microelectronics with my projects powered by #STM32 #microcontrollers.​​​​​​​

 

Log in or register to post comments