Close
0%
0%

MHF-002 (Mega Home FORTH)

ATmega2560 based SBC with VGA, PS/2 and SD cards - meant to run FORTH now and serve as graphic card later.

Public Chat
Similar projects worth following
0 followers
This 10 cm x 10 cm PCB will serve as Single Board Computer now, to develope software for display VGA/RCA based 40x25 character screen (and maybe later 320x200 graphics), managing PS/2 keyboard, SD card, USB Serial communication (with RTS/CTS flow controll) and maybe also other SPI and I2C periferials (like RTC). It will use external RAM and while developing it will also use FORTH as main system/language. Finally it will serve as graphic and I/O card for 8bit computer based on HD6309 processor. This is second PCB (so MHF-002), with more than 75 improvements over previous PCB (called MHF-001). PCBway.com generously sponsored manufacturing both those boards. Their work is flawless, easy to use, easy to solder/desolder and repeatedly resolder chips while testing different configuration and software options. Those improvements are result of actually using the MHF-001 board and adress discovered flaws in my design. Even with lot of reworks no trace nor pad was damaged during the tests

Current status:

MHF-001 proved, that VGA signal can be generated clean and stable. Due bad PORTs assignment was characters little distorted, this should be fixed on this new card. Also I failed to solder the external RAM perfectly, due footprints oriented for machine work, not hand soldering, so it sometime worked, sometime not and preesig it by hand improved the chace for right results. New version have much longer pads on footprints, which I can solder reliably.

More similar improvements was discovered over time, but basicaly I was able somehow confirm all wanted features. 

Software needs be rewritten for new port usage and for better functionality. It is just matter of time and effort.

FORTH helped very much, as it allows interactivelly program the atmega over keyboard or serial line, without recompiling and uploading everything from start for any and every action wanted.  Interactivity simply rules :)

Main idea for this card is to share 128kB RAM with the HD6309 computer, where it will be mapped to one or two 8kB windows and let the CPU fill commands and data in on its own pace, then map the RAM to MCU (ATmega) and read (and execute) everything on its own pace. This will enable high throuhtput at cost of little latency added and paralel work of both systems.

Generating of VGA signal needs like 90% of time on MCU and it runs in Interrupt routine, to provide needed regularity. The rest of time is used for everything else. CPU is not bothered with such details and runs all the time at full speed.

I do work on this project from begining of 2024 (so nearly two years) and it goes forward slowly, but surly. Now I estimate like another year is needed to explore this card and turn to building the CPU part.

  • VGA

    Gilhad5 days ago 0 comments

    VGA need Vertical Sync (at start of each screen), Horizontal Sync (at start of each line) and Signal (inside the line, it is the pixels).

    Vertical Sync is generated by timer on pin PE4 (every 16.64 mS ~ 60 Hz)

    Horizontal Sync is generated by timer on pin PB6 (every 32 uS)

    VGA signal is generated in interrupt on timer overflow (every 32 uS = each 512  clock ticks)

    Here are some osciloscope snaps, the magenta line is VSync, yellow line is HSync and green is Signal (sorry for wrong naming in picture)

    (4 screens at 60Hz)(1 line with pixels, 32uS)


    The main idea came from Squeezing Water from Stone 3: Arduino Nano + 1(!) Logic IC = Computer with VGA and PS/2 from slu4coder - short macro in assembler take character from videoram, take its definition from Flash, puts it as byte to port (PF here) and let 74HC166 to clock it out as 8 pixels. The macro take 8 clock ticks and is repeated 40x to output full line.
    Each line is shown 2x so the visible area is 320x400 pixels, but is managed as 320x200 points (25 text lines) for readability and data size (character set takes 256 chars x 8 lines per character = 2kB of Flash.)

    The numbers are: 32uS x 16MHz = 512 ticks. 40 characters x 8 ticks = 320 ticks, 512 - 320 = 192 ticks for everything else. When interrupt happens and interrupts are allowed (SEI) the MCU will finish instruction first, then serve the interrupt. This waiting for instruction end may take 1-3 ticks itself, so the interrupt may happen not really regularry and is necesery to adjust for that (macro check in my code). Also it needs to save registers, compute all adresses and offsets and manage possible PS/2 during the line. That may take approx 150 ticks together, leaving like 42 ticks between lines for user code to run in (means 8% speed only).

    Then there are the black borders above and below the displayed image (only lines 60 .. 460 are visible), where the user program is mainly executed (which give like 20% of MCU power). It is not much, but a lot of work can be done anyway.

    I set not only the Vertical Sync, but also the Horizontal sync to timers, so it does not depend on code exuting, which solved problem where VGA monitor sometimes went blank for few seconds (because some other interrupt or CLI..SEI section moved HSync pulse out of place and monitor get "confused and blank"). Now long uniterruptable section just make small glitch on screen, where pixels are horizontally moved for a frame (1/60 sec).

    I also added 74HC157 IC to select foreground/background colors according to 74HC166 output, so now it is possible set foreground/background color for each line separately (I set it for all 16 lines of character the same now). The colors are set on port PH now at the start of visible line.

    I also added VGA_ENABLE signal to cut off all pixels output in blank areas, so the ports (PF and PH) can be used for something else (I use PF for PS/2 input, leaving PH for user programs).

    I also plan to make hooks on end of each visual line for "mini interrupts" and on end of last visible line (for "run at frame pause" synchronisation of larger blocks, like SD card) to run in interrupt context.

    On user level the change of variable frames can be used for synchronisation of larger blocks or for timing events.

  • How it started

    Gilhad7 days ago 0 comments

    Many years ago I bought  Omen Kilo (SBC with HD6309) and start to play with it. It worked, but did not anything visible (does it even run?), just communicated over Serial. 

    So I invented and constructed card for 8 serial channels and called it Expanduino (pages in Czech only and incomplete), as it was Arduino based.

    It worked somehow, but was mechanically unreliable, slow and did not allowed for more extensions.

    So I decided to make my own design from the start and make it simply extensible, so it culd have everything a computer needs - output to some monitor, input from keyboard, filesystem to store and load data and programs, ports and so on and so on. This was not SBC anymore.

    I also found Composite video from Arduino UNO from ceptimus and Squeezing Water from Stone 3: Arduino Nano + 1(!) Logic IC = Computer with VGA and PS/2 from slu4coder which looked like solution for the video output. I use their ideas (and many others) and reworked it to system, which can switch between VGA and RCA even on runtime. This looked as good foundantion for videocard I wanted.

    First public presentation was on 2024 Maker Faire in Prague, in form of Computer at price for dinner as proof of concept.

    I then expanded it to FORTH driven breadboard computer NanoHomeFORTH and started work on even better version with more RAM and power.

    I called the project MegaHomeFORTH, as it was based on Arduino Mega, but then I discovered, that the most importaint pin (16MHz clock) is not accessible on Arduino Mega, nor on Arduino Mega Pro, so I went to make my own board, where it will be all included.

    On that time the PCBway reached to me and told me, that the project prom Maker Faire catched their interest and that they will sponsor me with PCB for it, should I make the plans. I offered the new project instead, as it made more sense for me and they agreed. It took me 2 months to came with the first version MHF-001 and they manufactured the board for it.

    The PCB was nice, simple to use, soldering there was easy for normal parts, but I had problems with the MCU and the RAM as the footprints I used was for machine soldering, but I had to solder this with my hands and eyes. MCU went well after lot of effort, but I could not solder the RAM reliably even after many attempts. It sometime worked, sometime not and sometime helped to press it with fingers. The pads for its pins was too small for me to make it reliable. The PCB itself managed well even when I repeatedly solder and desolder the pins, the problem was my handwork. Anyway it prove the concept, the RAM worked well sometimes.

    Also other parts worked, it generated nice VGA signal with color lines, it generated RCA signal too, it read PS/2 keyboard and it even was able to read SD card while doing all the previous at the same time (I was using some Arduino library, where I hacked the millis() mechanism, as I used the interrupt for other purposes, I read one byte at time at each frame to do not collide with the VGA, so it got speed 50 char/sec, but it proved the concept).

    I also published it as project there.

    There was problems with USB connector, mainly because small footprint, it was torned from the PCB more time due my manipulation and was not as reliable as I wanted, but the desing did not allowed for other connection to MCU (except for ISP programming), so new concept for that was included to the new step too.

    So I took another 2 moths to redesign it, added more features, made more logical configuration, and improved everything I could and now I am here, with MHF-002, which have more circuits on it, new module for USB, debug NeoPixel LEDS and so on and so on, which PCBway also offered to manufacture for free as sponsoring - and it is just manufactured as I write this lines :)

    Here is 3D model, how it will look fully assembled:

    I am looking for bring real photo soon :)

View all 2 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates