6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 9:10 am

All times are UTC




Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sat May 08, 2021 3:49 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
Ah, thanks.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Sun May 16, 2021 2:51 pm 
Offline
User avatar

Joined: Tue Aug 11, 2020 3:45 am
Posts: 311
Location: A magnetic field
BigEd on Sat 1 May 2021 wrote:
frequencies in the range 8 or 12MHz to 16MHz.


For testing purposes, a Raspberry Pi's SPI circuitry works in the desired manner and in the desired frequency range. The original model divides 700MHz or so to 350MHz or so and then the SPI circuitry uses this to obtain frequencies up to 16MHz or so to access the SD/MicroSD boot volume. Current versions operate at 1.2GHz or so and may offer 3ns or similar granularity on each phase of a square wave.

It may be awkward to modify Raspbian, NetBSD or RiscOS for this purpose but it may be relatively easy to add this functionality to 8BIT's 65C02 Simulator on a bare metal Raspberry PI. Indeed, there is a certain symmetry to test the speed of a physical 6502 with a fast simulated 6502.

I have another partial solution. Add a register to a clock stretching circuit. This would set a minimum cycle time but otherwise does not disrupt clock stretching functionality. This may lack the desired granularity but it has the useful property that power-up reset to the latch sets the system to the most conservative cycle time. The minimum hardware requirement is a spare address strobe, one or more counter chips for clock stretching, one 74x161 counter chip to operate as a 4 bit latch (or 74x574 8 bit latch) and one or more 74x08 quad AND gates.

_________________
Modules | Processors | Boards | Boxes | Beep, Beep! I'm a sheep!


Top
 Profile  
Reply with quote  
PostPosted: Sun May 16, 2021 3:32 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Interesting thought. Using the SPI clock on a recent Pi, then, would be to take an even divisor off 400MHz, which means we can set a clock period on a 5ns granularity.

It might be the case - especially with bare-metal code - that we can use one of the PLLs to do even better. The video PLL for example might not be in use.

But, I notice the head post mentions the Si5351A - and thanks to @revaldinho, I now have one of the adafruit boards, as does he, and as does @hoglet. And it does indeed seem to be very flexible and fit for purpose. The only thing is, it must be configured after power on by I2C, so we need something or other (presently Arduino, or actually Teensyduino on a Teensy) to tell it what to do.


Last edited by BigEd on Sun May 16, 2021 4:02 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sun May 16, 2021 3:59 pm 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 352
We've been using the Si5351A for a few days now as a flexible clock source for Beeb816.

It's actually been working quite well.

Here are a few snaps.

It's currently just sitting on a breadboard being driven by a spare Teensy:
Attachment:
IMG_2286.JPG
IMG_2286.JPG [ 468.82 KiB | Viewed 634 times ]


This is the code that's running on the Teensy:
https://github.com/hoglet67/si5351stand ... dalone.ino

You can set the frequency using the push buttons (in 100KHz steps) or by sending a number over the USB serial port.

Here's the output at 32MHz:
Attachment:
IMG_2282.JPG
IMG_2282.JPG [ 470.63 KiB | Viewed 634 times ]


And at 100MHz:
Attachment:
IMG_2285.JPG
IMG_2285.JPG [ 506.59 KiB | Viewed 634 times ]


The jitter is about +/- 100ps, and this doesn't seem to vary much as the frequency changes.

You can also seem to be able to change the frequency without the clock glitching.

The edge time is ~1ns when the drive is configured to the maximum of 8mA.

Dave


Top
 Profile  
Reply with quote  
PostPosted: Sun May 16, 2021 4:59 pm 
Online
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
BigEd wrote:
Interesting thought. Using the SPI clock on a recent Pi, then, would be to take an even divisor off 400MHz, which means we can set a clock period on a 5ns granularity.


I have not investigated recent Pi (ie. the v4)'s SPI clock, but on the earlier ones it's not regular - it appears approximately like 8 cycles of high, low, then an extra half cycle of low. There's no glitch just that extra half cycle (approximately) Also you need to get the Pi to send data to make the clock wiggle - not a real issue but that will limit the time you can run the clock for.

This does not appear to have any effect on peripherals but might give arise to some irregularities when clocking CPUs..

However there is actually a programmable clock output on all Pi's, so use that instead.. You can select which internal oscillator drives the divider and the divide ratio although I don't have notes to hand about the actual range of frequencies but its been used to create FM radio signals in the past...

(just remember it's all 3.3v)

-Gordon

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


Top
 Profile  
Reply with quote  
PostPosted: Sun May 16, 2021 5:19 pm 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 352
drogon wrote:
However there is actually a programmable clock output on all Pi's, so use that instead.. You can select which internal oscillator drives the divider and the divide ratio although I don't have notes to hand about the actual range of frequencies but its been used to create FM radio signals in the past...

Are you referring to the General Purpose Clock outputs (GPCLK0-2):
Attachment:
pi_gpclk.PNG
pi_gpclk.PNG [ 189.18 KiB | Viewed 626 times ]

https://www.raspberrypi.org/app/uploads ... f#page=105

You can choose any of the PLLs as the clock source.

PLLC (the ARM clock) on a Pi Zero defaults to 1,000MHz.

This should result in a jitter of +/- 500ps, so about 5x worse than the SI5351A, but fine for many applications.

Dave


Top
 Profile  
Reply with quote  
PostPosted: Fri May 21, 2021 11:32 am 
Offline
User avatar

Joined: Tue Aug 11, 2020 3:45 am
Posts: 311
Location: A magnetic field
I thought that Raspberry Pi might be vaguely off topic. However, I assumed that 6502 hardware enthusiasts - and especially those of Acorn persuasion - might have overlooked functionality of their existing equipment. Regardless, the difficulty of high speed oscillators leaves us with a classic "Good, fast, cheap - choose any two." In this particular case, choose any two from:-

  • High speed oscillator or other fine frequency control.
  • Stable output.
  • Sane defaults.
  • Trivially programmed from its own host.

I presume Si5351A uses I2C and provides no preset pins or memory because this uses the absolute least resources or is otherwise the lowest manufacturing cost. I would dearly like Si5351A with, for example, increment/decrement pins and a range of defaults. Unfortunately, such a device would be ridiculously expensive due to economy of scale and people fudging solutions with cheaper variants.

I am amused and slightly exasperated that Raspberry Pi SPI drops ticks. They should have divided by another factor of two but it is good enough - and possibly preferable - for its primary purpose.

_________________
Modules | Processors | Boards | Boxes | Beep, Beep! I'm a sheep!


Top
 Profile  
Reply with quote  
PostPosted: Sat May 22, 2021 12:45 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
I suppose anything outside Si5351A os somewhat off topic, but I should have broadened the topic in the first place.

I would appreciate code examples for the Raspi - for a reasonable range of square wave output frequencies. Any language is fine. Thanks.

Sheep64, I dont think dividing the clock would help. It sounds like the SPI state machine takes some time off to flop the byte for output and the freshly shifted-in byte for input.

As for a self-configuring Si, a 3-cent controller would do the trick...Hardly a major expense, but you can do it yourself with your own favorite controller, and get exactly what you need. I doubt most users would agree on presets or step amounts...

Hoglet, what is the default frequency out of Si5351A upon power up and reset? Or is it silent until configured? Could a system start up with one and self-configure the Si to bump up the clock? I think Dr.Jefyll was wondering about that earlier.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Sat May 22, 2021 6:57 am 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 352
enso wrote:
Hoglet, what is the default frequency out of Si5351A upon power up and reset? Or is it silent until configured? Could a system start up with one and self-configure the Si to bump up the clock?

The initial device configuration is stored in a one-time-programmable NVRAM that is factory programmed.

The part number format/options are explained on page 4 of the datasheet:
https://www.silabs.com/documents/public ... pdf#page=4

My one is silent on startup, but it's possible other versions exist. I'll do some more research...

Unfortunately the programming algorithim is not public.

This post provides some more details:
https://forums.adafruit.com/viewtopic.p ... 02#p419390

Dave


Top
 Profile  
Reply with quote  
PostPosted: Sat May 22, 2021 8:22 am 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 352
This page lets you lookup the frequency of a given SI5351A part:
https://www.silabs.com/timing/lookup-customize

Here's an example that defaults to 24.576MHz on CLK0: Si5351A-B02075-GT
https://www.silabs.com/TimingUtility/ti ... -B02075-GT

(Click on the Data Sheet Addendum for further details on the configuration)

Mouser have these:
https://www.mouser.co.uk/ProductDetail/ ... KY5Q%3D%3D

They also have lots of other variants, but it's not straightforward to find a part of a given frequency.

Dave


Top
 Profile  
Reply with quote  
PostPosted: Sun May 23, 2021 3:34 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
That is most peculiar!

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 29 guests


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: