PDA

View Full Version : Clock Trouble



edge87
05-25-2010, 09:40 AM
I need the whole propeller chip running at 80 Mhz , however a data sheet calls for a pin to send data at 8 mhz max. I'm having trouble doing the math to convert a delay that would accomplish this task. Thanks ahead of time for the help.




repeat
outa[DotClock] := 1
waitcnt(????) <-- Trouble Spot
outa[DotClock] := 0

JonnyMac
05-25-2010, 09:59 AM
I don't think you can generate a 8MHz signal is Spin or PASM; with a 80MHz clock an 8MHz cycle is just 10 clock ticks, and most instructions take four to execute.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

edge87
05-25-2010, 10:20 AM
Would making the clock slower help? or would the idea be to write this in assembly? Although i don't know any assembly i didn't know spin last month. I think i could pick up enough of it with a tutorial. Are there any good ones?

Also just so I understand. I understand it takes 4 ticks to perform a instruction. Would that be a 10 clock tick delay every time though the loop ? is that how that is calculated for future understanding.

kuroneko
05-25-2010, 10:43 AM
edge87 said...
Would making the clock slower help? or would the idea be to write this in assembly? Although i don't know any assembly i didn't know spin last month. I think i could pick up enough of it with a tutorial. Are there any good ones?

Also just so I understand. I understand it takes 4 ticks to perform a instruction. Would that be a 10 clock tick delay every time though the loop ? is that how that is calculated for future understanding.

Yes you could make the clock slower (e.g. 64MHz) which would make an assembler instruction last 62.5ns, two of them could generate your 8MHz clock (PASM only). However, with 64MHz you might as well use a counter to achieve the same result. If you want to stick with 80MHz then there are ways of doing it but it's slightly more expensive. For example you could (mis)use the video generator for this or - if your 8MHz duty cycle doesn't have to be exactly 50% - two interleaved cogs could generate the required waveform.

As for the clock tick delay, yes, 10 cycles would be required for the whole loop. This means 5 each, low and high (as you toggle the clock line). But it has been pointed out already that SPIN is definitly too slow for this and assembler isn't everyone's cup of tea. But don't let that discourage you!

Mike Green
05-25-2010, 11:11 AM
The way to generate an 8MHz pulse train using an 80MHz system clock is to use the cog counters. Download the application note on these (AN001) from the Parallax Download page. There's also the frequency generator object (obex.parallax.com/objects/47/ (http://obex.parallax.com/objects/47/)).

JonnyMac
05-25-2010, 11:17 AM
D'oh! Thanks for the reminder, Mike.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA

Phil Pilgrim (PhiPi)
05-25-2010, 11:31 AM
We're still missing a lot of info here:

1. You said a maximum of 8MHz. Is this the rate you plan to use?

2. What device's datasheet are you referring to?

3. What else accompanies the clock? Synchronous data? If so, there's a lot more that needs to be done than simply generating an 8MHz clock.

-Phil

edge87
05-25-2010, 08:56 PM
Phil Pilgrim (PhiPi) said...
We're still missing a lot of info here:

1. You said a maximum of 8 MHz. Is this the rate you plan to use?

2. What device's datasheet are you referring to?

3. What else accompanies the clock? Synchronous data? If so, there's a lot more that needs to be done than simply generating an 8MHz clock.

-Phil


1. I was assuming that 8 MHz would be the easiest to achieve. And since this is for a display I would prefer it to be faster.

2. The data sheet in question is here. It is a Vishay display.
http://www.vishay.com/docs/37006/apd128g.pdf (http:// http://www.vishay.com/docs/37006/apd128g.pdf )

3. Yes I will be displaying data with another pin in this loop set above. I'm not 100% sure how I'm going to be sending the data as of yet. I'm still trying to determine if this is going to work on this platform before I do that. I do have it sort of thought through. I would declare some DAT section stuff with all the 1's and 0's laid out in 32 bit chunks as thats all a long can hold and i'd pull them in one by one and assign them to the pin as we go through the loop. But i'm not 100% sure on that part. So as a simple test I have the data pin set to 1 at the top of the code. This should give me a solid display with no flickering if i have done it correctly.

I really appreciate the help i have receive thus far. When I finish i'll be sure to contribute this to the Object Exchange.

kuroneko
05-25-2010, 09:35 PM
edge87 said...
1. I was assuming that 8 MHz would be the easiest to achieve. And since this is for a display I would prefer it to be faster.

The data sheet lists 75ns (min) for the dot clock's high and low phase, i.e. cycle time is at least 150ns (max 6.67MHz). So 8MHz looks slightly out of spec. I suggest you start with something manageable, maybe a few hundred kHz and work from there (you can always refine your code and make it faster).

edge87
05-25-2010, 09:43 PM
I see where you got the 75ns (assuming ns stands for Nano seconds which is 1/1,000,000,000 of a second) how did you perform the calculations to arrive at 6.6 MHz? I've having a tough time getting this clock concept down. In all the other languages I've ever used time has never been this complex.

kuroneko
05-25-2010, 09:52 PM
edge87 said...
I see where you got the 75ns (assuming ns stands for Nano seconds which is 1/1,000,000,000 of a second) how did you perform the calculations to arrive at 6.6 MHz?

A (dot) clock cycle consists of a high and a low phase. Each of them has a minimum length of 75ns (t6 and t7). Meaning the whole clock cycle for the dot clock is 2x75ns, i.e. 150ns. Cycle time is 1/f which means max frequency is f = 1/(cycle time) = 1/150ns = 6.67MHz.

Different example, a normal PASM instruction takes 4 cycles, each being 1/f = 1/80MHza = 12.5ns in length. Which gives you an average execution time of 50ns (average because there are longer instructions).

a Demoboard setup

edge87
05-25-2010, 10:25 PM
I do now understand the Dot clock cycle. Its goes up for 75 ns, and down for 75 ns meaning the whole thing takes 150 ns (plus execution time).

My processor clock rate is 80,000,000 ticks per second.

i don't see how I divide 80 million into 150 ns and come up with 6.67 million. my units are getting mixed up. Or perhaps I'm backwards on this, How did 150 ns get multiplied to land at 6.67 million

kuroneko
05-25-2010, 10:43 PM
edge87 said...
i don't see how I divide 80 million into 150 ns and come up with 6.67 million. my units are getting mixed up. Or perhaps I'm backwards on this, How did 150 ns get multiplied to land at 6.67 million

Not multiplied, but divided by. f = 1/T = 1/(150e-9 seconds) = 6.666.666,67/1s = 6.67MHz

There is no connection between anything propeller related and the 150ns. The datasheet gives you a cycle time for a display. Period. A cycle time can also be expressed as a frequency (1Hz = 1 cycle/s, cycle being low phase + high phase). Hertz are measured in cycles per second. A cycle with a length of 150ns fits 1s/150e-9s = 6.666.666,67 times into a second. Meaning a cycle time of 150ns is equivalent to 6.67MHz.

All I'm trying to say is that your suggested 8MHz clock is too fast. The display seems only capable of 6.67MHz. How this is achieved with the propeller is a different story.

Post Edited (kuroneko) : 5/25/2010 2:49:26 PM GMT

edge87
05-25-2010, 11:56 PM
OH I thank you SO much for breaking that math down. I was having much difficulty making that logical walk. And i fully understand. I had somebody tell me that it should be 8 mhz but they were clearly incorrect I will modify my requirements to use 6.67 Mhz as a max frequency for a cycle.

So now completing my understand if i was sending 128 bits , on a cycle of 6.67 Mhz it would take .000019199 seconds to complete. (cross multiplied and divided. 128 cycles X 1 second / 6,666,666.67)

Now that I'm though that, how would i go about picking the best clock to suit the requirement. I'm thinking of dedicating a whole propeller to the display just to avoid my core clock from having to be modified.

Phil Pilgrim (PhiPi)
05-26-2010, 12:23 AM
That VFD is an interesting device (and BIG, too). To make effective use of it, you will need to take advantage of the Prop's VGA-style video output capabilities. I'm not familiar enough with the introductory literature to recommend a tutorial for this. Andre Lamothe's book (http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/lamothe/List/0/SortField/4/ProductID/534/Default.aspx) devotes a ten-page chapter to the subject, but I don't have a copy, so I can't say what's covered.

Anyway, generating the clock is just the tip of the iceberg here, but it's facilitated by the PLL circuitry in the Prop's counters, which can produce just about any frequency imaginable without having to divide the system clock frequency evenly.

-Phil

edge87
05-26-2010, 01:21 AM
Every step in the right direction is good.

How do i use the PLL circuitry to set a freq?

I intend to just send all 1's so the display goes solid. then from there change it up a bit.

Phil Pilgrim (PhiPi)
05-26-2010, 01:45 AM
From this point, you really need to study the available literature and tutorials, try some stuff on your own, and then come back with specific questions. It's beyond the scope of this forum to lead you every step from beginning to end of video signal generation.

-Phil

edge87
05-26-2010, 04:15 AM
Ok I understand. Thank you guys very much. Apart from Andre Lamothe's book, is there any other tutorials that could be recommend to me that would aid me in research on this topic?