Author Topic: Crystal oscillator with logic gates implemented on a PSoC chip - possible?  (Read 38031 times)

0 Members and 2 Guests are viewing this topic.

Offline randslTopic starter

  • Contributor
  • Posts: 40
Hi,

For a project I need a small microcontroller (to add a LCD + some buttons, ADC to read some analog inputs, to do some calculations), two crystal oscillators with some odd frequency (5.441 MHz & 5.510 MHz) and some logic gates & flip flops to implement a state machine.

I thought to use a PSoC chip from Cypress and based on their description everything what I need is available on the chip except two crystals. The two oscillators have to be crystal ones, need stable & low cost solution....

I gave try to implement the following crystal oscillator circuits on PSoC creator with this development board http://www.cypress.com/?rID=92146... but seems not working.
https://drive.google.com/file/d/0B0JYi6oszi-FNDBTejBJa2x4dzg/view?usp=sharing..( the NAND gate is implemented inside the PSoC chip and rest of the stuff remains off the chip)

But when I implement it with a real logic gate chip (www.ti.com/lit/ds/symlink/sn74aup1g00.pdf), the same circuit works really well and generates a nice square wave with the crystal frequency from the output of NAND gate.

Is it possible to use logic gates from a PSoC chip to create a crystal oscillator?
Could anyone give some advice about this one please.

I tried the same thing with a FPGA too... implemented a NAND gate inside a FPGA and took two pins out to connect the rest of the stuff.
Only once it worked and gave a square wave output, but the frequency was different than the crystal freq.

Am I trying something impossible? or are these gates inside these chips are not 'real' ones?

Thanks,
« Last Edit: October 15, 2014, 11:31:25 am by randsl »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Quote
Is it possible to use logic gates from a PSoC chip to create a crystal oscillator?

If you can configure it to produce a NOT / NAND gate, it would oscillate.

Your issue may be due to wrong configuration / load capacitance / wiring /...
================================
https://dannyelectronics.wordpress.com/
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Must be a pin configuration problem, I'll put an example in 6 hours or so when I get home from work.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4192
  • Country: us
Isn't implementing a NOT gate on a PSOC pretty much like doing it on a PAL?  That means you don't just have a few cmos transistors worth of inverter; you've got input logic, a big and/or array, and output logic.  I wouldn't be surprised if that makes it unusable for implementing a crystal oscillator...
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
This document has all you want to know and maybe even more on how to configure the PSoC 4 pins

http://www.cypress.com/?docID=49248

Also this is a less detailed explanation about clocks

http://www.cypress.com/?rID=80799

your output clock pin should look like this:

but instead of hooking the out_clk to an internal clock you should hook it to the output of the NAND gate.


But to use an external oscillator to begin with you probably need a different approach and hook it up as an external oscillator to the PSoC chip:
http://www.cypress.com/?rID=37884

I'm not sure you could drive the crystal directly.
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5114
  • Country: nl
I just tested a NOT gate on my Cy8KIT-50, connected to P3.6 and P3.7.
On the breadboard (not the best thing to do) a 4Mhz Xtal and a 1M resistor over the pins, and a 27p cap from each pin to ground.



Works fine.

Keyboard error: Press F1 to continue.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
But he wants to drive the oscillator directly, not just to use it as an external crystal.

 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
nevermind, from my own link before:
http://www.cypress.com/?rID=37884

on the AN54439.pdf doc:

 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
I couldn't find a xtal to do this so I used the internal clock to illustrate the setting of the output clock pin for a PSoC 4.

On the PSoC 3, 5 & 5LP you can just use the pin directly, on the PSoC 4 however you have to configure the output pin so it will use an external clock. Or you can use a flip-flop but that will half the frequency like in BIT_pin depicted here (I left the output mode on that pin to be transparent).



The Clock pin will toggle at the original external frequency with a tiny delay, unless you choose to sync it, then it will be delayed until the next clock and rise at the same time as the external clock but one cycle delayed.

For the external clock yo have to select the Clocking tab on the output pin configuration and select external, also you have to provide a logic high to the pin driver as illustrated on the previous image.



Finally under Pins/Output you might want to change the Output mode from Transparent (default) to Clock.



But I can't test if this will work how you set it up, I have found some oscillators on an old video card but I didn't find the energy to desolder them just yet.


But if you want just to get the external oscillator in, you should just the app notes that cypress provides to hook an external clock.
« Last Edit: October 16, 2014, 03:05:45 am by miguelvp »
 

Offline randslTopic starter

  • Contributor
  • Posts: 40
Thanks miguelvp, PA0PBZ, westfw, dannyf for your replies....

hi miguelvp,

Thanks a lot for your valuable ideas and sharing your knowledge....

I modified the pins as per your advice and please see below schematic.


Still I don't get a proper operation. I tried several crystals, with only one of those the circuit tries to start oscillation. The clock is not stable at all. It's changing phase/frequency all the time ( Not able to get a stable trace on the oscilloscope at all). Other crystals does not work at all...

I don't know why it's not working...

I raised the same question in Cypress PSoC4 forum http://www.cypress.com/?app=forum&id=4749&rID=101519&message=posted... I received some replies telling that it's not possible to do this one due to the additional internal stuff around the pin and they stops building an oscillation...

Does the additional internal stuff around the pin stops building an oscillation as mentioned there?

I'm bit confused...

cheers,
« Last Edit: October 16, 2014, 02:41:18 pm by randsl »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #10 on: October 16, 2014, 02:35:18 pm »
The serial resistor is way too small - I would start with 470k and going down from there.

The feedback resistor is kind of small as well - you can go as high as 10M.

The load capacitors of 0.1uf is insanely large. try 22pf or not use one at all.
================================
https://dannyelectronics.wordpress.com/
 

Offline randslTopic starter

  • Contributor
  • Posts: 40
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #11 on: October 16, 2014, 02:43:53 pm »
The serial resistor is way too small - I would start with 470k and going down from there.

The feedback resistor is kind of small as well - you can go as high as 10M.


Thanks dannyf, I'll try that one as well...

The load capacitors of 0.1uf is insanely large. try 22pf or not use one at all.

Actually I tried 18pF, not 0.1 uF.. Only the value shown in the schematic was a mistake. I corrected that... sorry about that...
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #12 on: October 16, 2014, 02:44:56 pm »
I was just showing two ways to generate clocks from the chip.

You don't need the flip flop it was just for illustration.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #13 on: October 16, 2014, 02:49:28 pm »
but it wont hurt, sorry just woke up.

You might need to use it as an external clock and then use it internally, not drive it directly.
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #14 on: October 16, 2014, 02:56:47 pm »
Using a flip-flop like that as a divide-by-two does have the added benefit of giving you a 50% duty cycle. So even if your ring/whatever oscillator produces something way off 50/50, then you still get a somewhat decent output clock. At half the original clock frequency obviously.
 

Offline paulie

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #15 on: October 16, 2014, 03:05:01 pm »

I raised the same question in Cypress PSoC4 forum http://www.cypress.com/?app=forum&id=4749&rID=101519&message=posted... I received some replies telling that it's not possible to do this one due to the additional internal stuff

Westfw was the only one here who mentioned that and I have a feeling him and the Cypress guys may be right. All those switches and mux can't be good for high frequency operation. What does the Cypress spec say about propagation delays? 4mhz don't seem that high but it would be surprising to see this succeed.

A lot of internet talk is more about what somebody "thinks" should work instead of actually reliable information. That series resistor for example. At those frequencies I can't see how that high resistance could possibly work. Ice cubes chance in hell comes to mind. Those are mainly to assist low power operation and I suspect none at all would be best.  I would try it myself but not setup for PSOC right now.
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5114
  • Country: nl
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #16 on: October 16, 2014, 07:01:21 pm »
I don't know who is right or wrong, but here is the 'proof':





Keyboard error: Press F1 to continue.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #17 on: October 16, 2014, 07:45:05 pm »
PSoC 5LP has different pin capabilities than the PSoC 4.

on the 5, 5LP, 3 and even 1 you can assign a clock to a pin directly and leave it transparent.

On the 4 it takes a bit more of setup, so might not be possible to drive it directly.

The PSoC 4 however allows you to use an external crystal oscillator (ECO) but not sure if you can just put a crystal (XTAL) directly, have to dig deeper in the documentation, I put the acronyms they use in case someone has free time to look at the documentation before me, since today is a busy day at work.
 

Offline paulie

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #18 on: October 16, 2014, 07:53:31 pm »
Ahaa... I suspected no series might be the key. It would be interesting to see if those caps are needed too. Generally they serve little purpose with modern hf crystals unless absolute accuracy is needed. This shows what excellent circuitry is hidden behind those tiny PSOC walls. I wonder what the fastest speed possible might be. 8mhz? 16mhz?
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #19 on: October 16, 2014, 11:39:50 pm »
Ahaa... I suspected no series might be the key. It would be interesting to see if those caps are needed too. Generally they serve little purpose with modern hf crystals unless absolute accuracy is needed. This shows what excellent circuitry is hidden behind those tiny PSOC walls. I wonder what the fastest speed possible might be. 8mhz? 16mhz?

Hardware no software controlled you can get the full 48MHz at the output pin named "Clock", the other one with the flip-flop outputs 24MHz.


Software controlled because of output port stall the fastest would be 4 clocks for on and 4 for off if you unroll the signal. so 12MHz for a 50% duty cycle, loop controlled you could achieve a period in 14 cpu cycles so 24/7 MHz so ~3.428 MHz

All those are +- 2% I believe.

PWM controlled 16 bits I will have to test it, but should be up there.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #20 on: October 17, 2014, 02:39:44 am »
PWM I can get 24MHz at 50% duty cycle with a count of 1 and a compare value of 1.

If you use the unconfigured TCPWM it's fully runtime programmable.

I can chose a count of 5 (0-5 is 6) to get 8MHz but then I can select the duty cycle by changing the compare value from 1 to 5 at 1/6 increments  so 16.666% duty for 1, 33.333% for value 2, 50% for 3 etc.

But there are also other alternatives like a fully programmable clock instance including the usage of an external clock, I'm still trying to find an example (hardware connection) to use an external oscillator for the PSoC4, it seems you just have to use the crystal with a physical NAND gate to and then feed that to the chip and add it into the clocks.

To the OP, any reason you won't use the internal clock?
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8515
  • Country: us
    • SiliconValleyGarage
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #21 on: October 17, 2014, 03:00:01 am »
Why do you want to do it with crystals ? Simply make a frac-n synthesizer in the psoc. All you need is an accumulator and two registers. a 16 bit accumulator should do nicely for what you need. no doubt the psoc has that on board.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #22 on: October 17, 2014, 05:13:58 am »
I replied to your cypress thread because, well... I'm close to get one of those nice port authority silk sports shirts ;)
Here is what I had to say:

Quote
From AN79953
 
"A 0 to 48-MHz external clock (EXTCLK) can be supplied through I/O pin (P0.6)."
 
The only problem is that the Configure System Clocks only allows integer clocks in MHz, so either 7 or 8, or any other integer from up to 48.
 
However you can then derive clocks from an external clock if you feel the built in system clock is not accurate for your needs.
 
Since the PSoC4 output pins are different than the rest of the PSoCs you might need to make it oscillate externally and use only one pin (P0.6).
 
Maybe the attached project will work by making the output pin a clock driveable output, but I'm not sure if this will work to make an oscillator.
 
I removed your 2nd oscilator and this project is non bootable but you should be able to copy and paste the schematic. I also added the EXTCLK in the test_osc_single.cydwr by selecting the clocks tab and double clicking to configure the clocks, so that the output clock is available if you hook it to P0.6.
 
Please let us know on the answer from your case. Or if changing the output pin to this output configuration makes it oscillate.
 
Thanks.

Attached is also a picture of the schematic to test but I have my doubts it will oscillate, but this is as close as you can do to make a PSoC 5LP output pin that drives a XTAL I think.



But I think this won't work because of the inner workings. So if you need a more precise clock than the internal 48MHz one you could just build the oscillator externally and feed it to the EXTCLK pin (P0.6) but you have to select a non fractional clock from 1 to 48 MHz in 1MHz increments. After you hook up the external clock in your system clocks, then you can use that to derive the lower clocks you desire. Or just stick with the internal 48MHz clock.

This is the Configure System Clocks with the EXTCLK activated if the external clock was the maximum allowed at 48MHz: (edit, updated image to show maximum clock speed and extclk selection)

But as stated you might need to drive it from an external oscillator already oscillating on it's own.
« Last Edit: October 17, 2014, 05:22:36 am by miguelvp »
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #23 on: October 17, 2014, 07:00:26 am »
According to this thread

No Crystal Oscillator in PSoC4?
http://www.cypress.com/?app=forum&id=4749&rID=80466

You'll need a crystal oscillator not just a crystal on the PSoC 4, that's why P0.6 is the only pin available for an external clock as a single pin input.


« Last Edit: October 17, 2014, 07:02:31 am by miguelvp »
 

Offline paulie

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: Crystal oscillator with logic gates implemented on a PSoC chip - possible?
« Reply #24 on: October 17, 2014, 07:41:42 am »
PSOC4 does have an internal oscillator as demonstrated in this thread. It just requires a digital block. The question is what is the maximum frequency. 4mhz seems to work but 48mhz is unlikely. If anybody can provide an elf file I have a huge collection of crystals and would be willing to test.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf