6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Sep 27, 2024 4:07 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Jun 03, 2020 1:13 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1467
Location: Scotland
Possibly stretching the realms of 6502.org, but I've been playing with an LCD display for the past few days. They seem quite popular in the Ben Eater world and subsequent builds by many people following his stuff, so I thought I'd add one to my Ruby816 board.

I have the advantage now of a fully functioning BCPL system though, so back-porting all my existing LCD drivers for Pi, Arduino, etc. which are in C to BCPL was relatively easy.

One thing that BCPL does have is a "stream" IO library - so in the C/Unix world you'd open a device (e.g. serial TTY) and refer to it by a file-handle, in the BCPL world you open a device, then select that device for output (or input, etc.) then just use the same write/read commands to it without needing to pass the "handle" round. Each way has pros and cons, but that's the way BCPL did it before Unix, so that's what I've stuck to.

Attachment:
IMG_20200528_175244_DRO.jpg
IMG_20200528_175244_DRO.jpg [ 492.55 KiB | Viewed 767 times ]


I did a little video - there's a snippet of demo code in there too:

https://www.youtube.com/watch?v=mexTCJ8d25w

Cheers,

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 03, 2020 3:42 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Nice - thanks for talking us through the facilities. Some questions...
- the red LED heartbeat is presumably interrupt driven in the Ruby OS?
- the blue LED seems to show waiting-for-input?
- is the LCD cursor flashing autonomous or a Ruby thing?
- is it taking about half a second to scroll a line on the LCD - is that due to the speed of bit-banging the I/O? Could it be faster if you took time to optimise or is it as fast as the LCD can go?


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 03, 2020 4:52 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1467
Location: Scotland
BigEd wrote:
Nice - thanks for talking us through the facilities. Some questions...
- the red LED heartbeat is presumably interrupt driven in the Ruby OS?


That's connected to the CB2 output on the VIA. The VIA generates a 1000Hz interrupt to the CPU via T1. This maintains the Acorn MOS style 100Hz ticker and a separate system 1000Hz ticker (aka 'millis()' in other systems). And attached to this is a balanced PWM algorithm to blink the LED in a pulse/fade heartbeat fashion. It wastes a few CPU cycles, but I like it. I've been using that on my Arduino/ATmega projects for years and I figured that if it was OK to lose a few CPU there in a C routine, I can afford it here in '816 asm ...

It's also pretty and makes people ask how I did it :-)

Quote:
- the blue LED seems to show waiting-for-input?


That's currently inverted, but it's connected to the BE line (via a spare GAL output) When Blue is ON, then CPU is stalled. So in this configuration off is good in that the '816 is doing 'work'. So you see it blinking when terminal and file IO happens (but not pure LCD output) . The other red LED isn't significant right now it's an output from the GAL I was using as a 'scope trigger when testing. It's intended to be on for IO access (ie. the VIA) but it's mostly off as it ends up being a 16th of a microsecond pulse which you can't really see unless doing a lot of back to back IO operations with the VIA.

Quote:
- is the LCD cursor flashing autonomous or a Ruby thing?


That's a function of the LCD. Most people disable the cursor which is why you never usually see it (it's the default to be off too) - but it can be static (and underline), or a flashing block.

Quote:
- is it taking about half a second to scroll a line on the LCD - is that due to the speed of bit-banging the I/O? Could it be faster if you took time to optimise or is it as fast as the LCD can go?


Yes, I could optimise it - one way would be to read the busy signal back from the VIA rather than just wait for 1mS after each command - the display is also being driven in 4-bit mode, so there's a few extra cycles wasted there. I could code it in ASM too, but I don't see much point here. I could be more clever and issue a clear screen then only print the characters that are not spaces, but I'm not sure it's worth the complexity.

Here is the scroll code:

Code:
AND lcdScroll () BE
{
  LET x, y = cursorX, cursorY

// Move buffer up

  FOR x = 0 TO (ROWS-1) * COLS DO
    buffer%x := buffer%(x+COLS)

// Blank the bottom line

  FOR x = COLS * (ROWS-1) TO ROWS * COLS - 1 DO
    buffer%x := ' '

// Display it all

  FOR r = 0 TO ROWS-1 DO
  {
    lcdXY (0, r)
    FOR x = 0 TO COLS - 1 DO
      lcdSendData (buffer%(x + r * COLS))
  }

// Restore x,y

  cursorX := x
  cursorY := y
  lcdUpdateXY ()
}


One thing on my to-do list is to rewrite some of the BCPL library code in ASM - there is a block-move function for instance. That would speed up the move loop if I needed to.

Cheers,

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 04, 2020 2:32 pm 
Offline

Joined: Sat Dec 12, 2015 7:48 pm
Posts: 143
Location: Lake Tahoe
Gordon-

I just want to add my voice to the list saying how impressive Ruby 816 is. As a system, it really punches above it's weight. Adding the LCD seamlessly is a testament to the thought you put into it. Of course I am a huge fan of your 32 bit BCPL VM, doing exactly what a VM should do: hiding the idiosyncrasies of the underlying architecture. And being able to compile on the metal makes it a real computer system, not just an embedded device.

Dave...


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 04, 2020 2:45 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1467
Location: Scotland
resman wrote:
Gordon-

I just want to add my voice to the list saying how impressive Ruby 816 is. As a system, it really punches above it's weight. Adding the LCD seamlessly is a testament to the thought you put into it. Of course I am a huge fan of your 32 bit BCPL VM, doing exactly what a VM should do: hiding the idiosyncrasies of the underlying architecture. And being able to compile on the metal makes it a real computer system, not just an embedded device.

Dave...


Hi Dave,

Thanks for that. I did the LCD really because I was having a bit of a brain-fug for a few days, so needed something to take my mind off things and seeing that others (e.g the Ben Eater designs) were using one I stuck one on.

Trouble is, now, it's putting all sorts of silly ides into my head - that spare 8-bit port on the VIA could be used for a keyboard. I could write a little BASIC in BCPL, I could ....

Currently working on a revised PCB - there are a few wirs on the back where I've changed the IRQ routing and handling, so tidying that up, moving a few components slightly and planning backplane system for it, so I can plug in other cards and eventually a dedicated video card, gpio cards and so on. My ideas are sort of like an Apple II with slots but the software ideals of the BBC Micro. I might just expand the memory to 1MB too - although I can compile the BCPL compiler as it stands with 512KB, while it's not something I'll ever do regularly (takes too long!) it would be nice to have a bit of wiggle room when I finish off the multi-tasking side of it all.

Cheers,

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron