Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at


hpr3807 :: PeePaw builds a computer

Brian starts the process of building an 8 bit retro computer

<< First, < Previous, , Latest >>

Hosted by Brian in Ohio on 2023-03-07 is flagged as Clean and is released under a CC-BY-SA license.
retro computing, forth, arduino. 3.
The show is available on the Internet Archive at: https://archive.org/details/hpr3807

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:34:00

general.

  1. intro
    • who is peepaw?
      Me!
    • why a retro computer?
      help a kid understand computers
    • why z80?
      cheap, available, cheap
  2. the plan
  3. getting started, the nop test
  4. the nop tester, in software
  5. the code walk through, start from the bottom up note: ( -- ) are stack effect comments, back slashes are plain comments
    • constants
    • variable
    • @ ! mset mclr mtst
    • set up external interrupt, int4, arduino board pin4
\ the source code
\ declare some constants and variable as labels
variable Compare
variable Count

$100 constant PINH      \ these labels come from the atmega2560 datasheet
$101 constant DDRH
$102 constant PORTH
$a0 constant TCCR4A
$a1 constant TCCR4B
$a8 constant OCR4A
$2c constant PINE
$2d constant DDRE
$2e constant PORTE
$6a constant EICRB
$3d constant EIMSK

: ext4.irq ( -- ) Count @ 1+ Count ! ;i  \ the frequency counter

: logicprobe-init ( -- )
    1249 Compare ! \ 100 hz
    %0000.1000 DDRH mset \ h3 output
    %0100.0000 TCCR4A c!  \ toggle d6, ph3 on compare match
    0000.1011 %TCCR4B c!  \ set ctc mode, clk/64
    Compare @ OCR4A !  \ set compare value
    %0 DDRE c! \ e input
    0001.0000 PORTE mset \ pullup on e4
    %0000.0010 %EICRB mset \ falling edge
    ['] ext4.irq #6 int!
;

\ helper words

: start-clock ( -- )  %0100.0000 TCCR4A c! %0000.1011 TCCR4B c! ;    \ the bit manipulation does what the word says
: stop-clock ( -- )   %0000.0000 TCCR4A c!  %0000.0000 TCCR4B c! ;
: set-frequency ( n -- )  OCR4A ! ;    \ set compare value
: pin-high ( -- )  %0000.1000 PORTH mset ;
: pin-low ( -- )    %0000.1000 PORTH mclr ;
: open-gate ( -- )   0 Count ! %0001.0000 EIMSK mset ;
: close-gate ( -- )   %0001.0000 EIMSK mclr ;

: process-data ( -- )
  Count @ 1- Count !       \ clean up value in Count
  Count @ dup 0 > if       \ is Count greater than 0, if so its pulsing
     cr ." freq=" 10 * .
  else                     \ otherwise its not so is it high or low?
      drop
      %0000.1000 PINH mtst
      if
         ." high"
       else
          ." low"
      then then
 ;

 : wait ( -- ) 100 ms ;

 : sample-pin ( -- ) open-gate wait close-gate process-data ;  \ the 'logic probe'
  1. test
    Arduino
    Arduino

    • clock, using 16 bit timer4, its output is on pin6, running at 100hz
    • need to be able to start and stop the clock, and set the output pin high or low
    • sample-pin is the word that does the work
    • ouput from the serial terminal exercising the logic probe ( comments add after the fact):
    E FlashForth 5 ATmega2560 13.06.2022
    
    ok<#,ram>
    logicprobe-init ok<#,ram>    (start up the logic probe)
    sample-pin                   (sample the pin)
    freq=100 ok<#,ram>           ( its oscilating at 100hz)
    stop-clock ok<#,ram>
    sample-pin low ok<#,ram>     ( after stopping the clock the pin is low)
    pin-high ok<#,ram>
    sample-pin
    high ok<#,ram>               ( now its high)
    125 set-frequency ok<#,ram>
    start-clock ok<#,ram>
    sample-pin
    freq=1000 ok<#,ram>          ( after changing the frequency its 1000hz)
  2. next time

    • repurpose the 16bit clock and use it to drive the z80, we'll hook up the data port of the z80 to the arduino mega and use the logic probe to see if the z80 is working

Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2023-02-26 17:17:33 by Mechatroniac

.

Good to see someone else doing Arduino stuff.

However your code is not sketch code and will not compile in the arduino IDE. You mention forth?

What software are you using to compile?

Comment #2 posted on 2023-02-26 17:40:16 by Mechatroniac

.

https://sourceforge.net/projects/flashforth/

Comment #3 posted on 2023-03-08 23:13:40 by brian-in-ohio

forth shows

You could listen to hpr 3477 and hpr 3537 they explain running forth on arduino boards. I'm using flashforth an explanation on this excellent implimintation of this forth can be found at flashforth.com. This is not a sketch, its a forth that runs on the board and allows interactive control of the microcontroller.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
What is the HOST_ID for the host of this show?
What does HPR mean to you?