AgonLight2 update: embedded Hello world in BBC basic

AgonLight2 is Z80 based retro computer running BBC Basic.

The first thing you do with embedded computer is to run the Hello World equivalent i.e. to blink LED.

AgonLight2 has 34 pin GPIO connector:

In this GPIO-1 connector we can see many different signals are coming both from Z80 and ESP32-D4 . In this demo we decide to connect LED to pin 17 which is GPIO_PC0 signal of ez80F92 processor.

I use Breadboard and some Jumper wires Female-Male to connect the LED anode (+) to GPIO-1.pin17 the LED cathode (-) is connected to 4.7 k OHM which then is connected to GPIO-1.pin3 GND.

With the above setup if PC0 is set high the LED with light ON. When the PC0 is set LOW the LED will go OFF.

So how do we access PC0 in BBC BASIC?

I admit I come from AppleSoft Basic so Z80 BBC Baisc is new for me.

Fortunately Quark Firmware is on GitHub so I can check the sources.

In BBCBasic.txt I nottice commands to access directly Z80 memory, these are GET and PUT commands.

In ez80F92 datasheet I read that GPIO ports are accessed through 4 registers:

PC_DR – data register at address 09E hex /158 dec an 8 bit register where every bit corresponds to port bit i.e. if I want to write in PC0 I have to modify bit0

PC_DDR – data direction register at address 09F hex / 159 dec and 8 bit register where every bit corresponds to port bit direction 1 means Input, 0 means output

I quickly check:


returns 255 i.e. all ports C are inputs by default

I change PC to output with the PUT command

PUT 159,254

then make PC0 HIGH with the command:

PUT 158,1

LED lights ON:


PUT 158,0

command switch LED off:

Now we only have to put some delay between the ON OFF commands.

I search for delay in Quark sources without success when I nottice that INKEY command scans for keystroke pressed for some time and returns -1 if not suceed.

Let’s check if INKEY can be used as delay 🙂


prints -1 after about 1 second, great then our fill code becomes like this:

the code runs and the LED slowly blinks as on the video clip above!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: