Shop OBEX P1 Docs P2 Docs Learn Events
Running a Propeller with a 6 MHz Crystal. — Parallax Forums

Running a Propeller with a 6 MHz Crystal.

In my spare parts drawer I have a 40 pin propeller, a 3.3v regulator, various capacitors (.1, 10, 47, 100 uF), various resistors, and a 6MHz crystal. So I plan to breadboard a propeller circuit and see if the propeller chip works. Except for the Propeller backpack I've always used a 5 MHz , so I always use the standard clock multiplier.

My question is what happens when you use a nonstandard clock frequency? For example a 16x multiple yields a 98 MHz clock frequency, so if I try to generate composite or VGA video will it work?

What I ultimately plan to breadboard and then solder to a perf board is something like t PocketTerm:

http://www.brielcomputers.com/wordpress/?p=300

Note that I would buy it, but he no longer has any in stock, and I want something like this to free up my laptop when using one of my retro computers.

Comments

  • kwinnkwinn Posts: 8,697
    A 6MHz xtal will give a 96MHz clock with a 16x multiplier. That will affect the timing of the video signals unless it is taken into account.
  • If I set these values in the firmware would that result in correct timing? Or would I need to change something else? Like the constants used for the counters?

    CON
    _CLKMODE = XTAL1 + PLL16X
    _XINFREQ = 6_000_000
  • kwinnkwinn Posts: 8,697
    Martin_H wrote: »
    If I set these values in the firmware would that result in correct timing? Or would I need to change something else? Like the constants used for the counters?

    CON
    _CLKMODE = XTAL1 + PLL16X
    _XINFREQ = 6_000_000

    I took a quick look at the TV and VGA drivers and the timing appears to be done in clock cycles. You could multiply those constants by 1.2 (96/80) to run with a 6MHz xtal.
  • Mike GreenMike Green Posts: 23,101
    edited 2016-07-09 17:41
    The TV and VGA drivers use the CLKFREQ value stored in location 0 to compute the timings. They should work fine with any system clock frequency fast enough to execute properly. That includes 96MHz (6MHz x 16). I think NTSC TV requires a minimum system clock of 16MHz for example. See TV.spin around line 260.
  • kwinnkwinn Posts: 8,697
    BTW, what driver do you intend to use? Adjusting the timing seems a bit specific to each of the drivers.
  • @Mike, Thanks. I will give it a try tonight.
    kwinn wrote: »
    BTW, what driver do you intend to use? Adjusting the timing seems a bit specific to each of the drivers.

    Reading through Vince's firmware it looks like he's using Oddbitcollectors from the Obix with minimal modifications. Cool, I think I can build most of this using odds and ends.
  • Cluso99Cluso99 Posts: 18,069
    For 6MHz to work reliably you MUST use proper decoupling at the power pins!!
    All my boards will run reliably at 6.5MHz (104MHz).
  • I breadboarded part of the circuit with the propeller and the 6 MHz crystal. I was able to load a program and see the serial output. So the first test passed.

    I also found all of the needed capacitors and voltage regulators. So next step is migration to veroboard.
  • Cluso99Cluso99 Posts: 18,069
    I use an SMT 12MHz 3225 (3.2x2.5mm) xtal on my P8XBlade2 board. No space for anything bigger ;)
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-07-11 03:06
    I use cheap 6MHZ oscillators in 5x3mm packs
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2016-07-11 07:32
    Peter,

    That link does not work. Can you repost it, please? Corrected.

    -Phil
  • sorry, my bad, I was distracted and pasted the part number instead of the link.
  • See also these mems oscillators from Microchip direct. They're available in most smd sizes (7x5, 5x3, 3x2.5 etc), and there are sweet spots in the pricing (Eg DSC1001CC1-8.000 $0.67 qty 26)
    http://www.microchip.com/wwwproducts/en/DSC1001
  • Martin_H wrote: »
    My question is what happens when you use a nonstandard clock frequency?
    Perhaps it's helpful to point out, that there is no standard clock frequency for the propeller. Perhaps 5MHz * 16 is most common, but there are plenty other offerings, e.g. the Raspberry Pi Propeller HAT uses a 6MHz XO. More info about clock speeds can be found at https://github.com/rosco-pc/propeller-wiki/wiki/Oscillator .

  • Martin_H wrote: »
    My question is what happens when you use a nonstandard clock frequency?

    To directly answer your question, any code that relies on a 80MHz clock for precision timing (such as RS-232 I/O) will probably be affected. The code may or may not self-adjust for the change in frequency.

    Slower communication methods (and devices), such as I2C, might need adjustments.

    I've had to adjust servo drivers because of a change in the clock.

    Otherwise, zoom on!

    Walter


  • Actually most OBEX stuff I know DOES NOT relay on fixed 80 MHz.

    Usually in SPIN Objects/Code the timing is based on clock freq. divided by whatever whoever needed it.

    Especially all the serial objects. I do know of none not working with any combination of

    _clkmode = xtal1 + pllXXx
    _xinfreq = X_XXX_000

    you choose.

    Them usually just adjust the timing at compile time.

    But the current used freq. is also saved at address 0 in HUB (if I remember correct) and should be changed when changing cock modes to ensure running software can adapt to the new clock freq.

    Not sure how many serial driver do that.

    Anyways, there is a way to write code that adjust to the current clock freq. and it is widely common in OBEX objects.

    Mike
  • Yes, I've got the keyboard and serial ports working, so next is testing the VGA. After that I plan to tweak the PocketTerm firmware for my board which has a slightly different pin usage because I have a mouse port, the speaker is on pin 11, and the second serial line is on pins 5 and 6.

    One weird thing. Vince Briel used an MAX232 for the TTL to serial which is a 5 volt part, and a 1K resistor on the RX lines. Normally when mixing 5 volt parts with the Propeller you use a 3.3K resistor, so that struck me as odd.

    I substituted an ST232 which is pin compatible but uses .1 uF capacitors and it is much cheaper as well. But the 1K resistor did not work as the RX line acted erratic. So I pulled the power and used a 4.7K resistor which die the trick.

    Honestly point to point wiring this thing is a drag, and I wish I could have purchased a PCB when Vince was selling them. But I am done with it now, so It OK.
  • Well I spoke too soon with regards to the 6 mhz crystal. While the serial and keyboard drivers don't mind the higher clock rate, two of the VGA drivers from the OBEX do not. I also tried the PTFirmware which also doesn't like the higher clock rate.

    The symptom is the monitor displaying "out of scan range 43.3 KHz/ 83 Hz." I imagine if I dove deep into PASM code I might be able to figure this own, but it is probably wisest to get a 5MHz crystal.
  • Which VGA drivers? Think its pretty easy to change
  • I tried the http://obex.parallax.com/object/645 and http://obex.parallax.com/object/646 both were written by Chip, so if anyone wrote them correctly it would be him.
  • Martin_H wrote: »
    I tried the http://obex.parallax.com/object/645 and http://obex.parallax.com/object/646 both were written by Chip, so if anyone wrote them correctly it would be him.

    VGA.spin works fine for me with 5MHz and 6.25MHz crystals. You're probably just giving it bad parameters. Are you sure it doesn't think you're using a 5MHz crystal?
  • OK I thought I changed the required tuning parameters, but I'll try VGA.spin again tonight.
  • I tried all three demos on my PropBOE which has a 5 MHz crystal and they all worked find. I went back and looked at the source, and other than specifying the crystal frequency and base pin. I don't see any configuration parameters.

    So I still think the VGA driver is incompatible with6 MHz or I can find the right knob.
  • VGA.spin definitely supports multiple clock speeds. Look at lines 204 and 223 for "rdlong t1, #0", where it reads clkfreq (i.e. long[0]) into t1 and then calculates stuff from it.

    When you start VGA.spin, you pass its start method a pointer to a whole lot of parameters. The last one is the pixel rate - what value are you using for it?

    You are using the following clock settings, for a total of 96MHz, right?
    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 6_000_000
    

    Have you tried it with more than one Propeller? I've never had problems running Propellers at 100MHz with 6.25MHz crystals, but it's always a good idea to try different hardware.
  • Yes, I changed the _xinfreq to 6 MHz, but I didn't change a pixel rate parameter. I also have a spare propeller chip so I could swap them out tonight.
  • ElectrodudeElectrodude Posts: 1,657
    edited 2016-07-27 13:48
    I'm pretty sure you don't need to change the pixel rate parameter. I just mentioned it because it caused me trouble trying to use a 6.25MHz crystal - I had assumed it was in ticks and had to be changed, but it's actually in Hz and it's automatically converted to the correct PLL settings based on clkfreq, so you shouldn't change it when using a different crystal.

    Have you tried running your code (after setting _xinfreq to 5_000_000) on another board with a 5MHz crystal? Can you borrow a 5MHz crystal from another board and see if that works on this board?
  • Have you tried running your code (after setting _xinfreq to 5_000_000) on another board with a 5MHz crystal? Can you borrow a 5MHz crystal from another board and see if that works on this board?

    Yes, I did that yesterday and it worked just fine. Today I swapped Propeller chips and got the same symptoms. I looked through the code and other than _clkmode and _xinfreq I don't see any way to adjust for a change in Propeller frequency. Below is the signature of the start method and it doesn't take any parameters like that:

    PUB start(BasePin, ScreenPtr, ColorPtr, CursorPtr, SyncPtr) : okay | i, j

    Now it's entirely possible there's a way to do this, but it doesn't seem obvious to me. So I think switching to a 5 MHz crystal is the path of least resistance.
  • I removed the 6 MHz crystal and swapped it with another board that had a 5 MHz one. The video display now works perfectly.
Sign In or Register to comment.