Square Signal generation
octal
Posts: 67
Hello,
I try to generate square wave signal (about 25MHz) with Propeller and I have some questions:
1- If I use asembly (or maybe spin only cause 25Mhz is not too much) can I have good square waves (I dont have a fast oscillo to check)
2- Are generated square waves using code as good as those generated using COG counters modules?
3- using COG counters, is there any solution (an example code) to make the signal generator generate only a certain number of waves? (I mean for example to generate only 1000 Pulses and stop) ?
Regards
I try to generate square wave signal (about 25MHz) with Propeller and I have some questions:
1- If I use asembly (or maybe spin only cause 25Mhz is not too much) can I have good square waves (I dont have a fast oscillo to check)
2- Are generated square waves using code as good as those generated using COG counters modules?
3- using COG counters, is there any solution (an example code) to make the signal generator generate only a certain number of waves? (I mean for example to generate only 1000 Pulses and stop) ?
Regards
Comments
This code itself of course can not count and stop after 1000 pulses. But as the propeller is fully deterministic you could have one COG which outputs the wave in a loop and another that waits long enough and then stops the squarewave-COG.
Counters can only divide the clock by power of 2 values. So, if you need 25MHz the only way is to use a 6.25MHz chrystal (=100MHz clock) and use the counters (divide by 4). As the counter runs allone after it's setup, the COG can do a waitcnt to wait for 1000 pulses and then stop the counter. As the propeller is deterministic there will be a formula that can be used to exactly calculate the waittime needed for any amount of pulses.
Finally I need only about 20 Mhz, so the 80MHz (5MHzxPLL) is enought. The main pb now for me is to find a way to stop perfectly the wave form gen after a certain num of pulses. not that easy, I'll check.
Regards
One way is to simply sit there in a waitcnt and then switch off the counter. You could also count the pulses (edge counter mode) your NCO emits and periodically check how far it got and do something else while you're waiting. When you get closer to your intended target you simply pay more attention so you don't miss the cut off point. There are other ways to achieve this, this should get you started.
Is this SPIN or PASM?
I'm effectively trying to do it using counters in a second COG.
As for the implementation, everything I'm writing is done using PASM (in the COG monitoring the count of pulses) because of the need for precision.
Regards
Is there a particular reason that you have to use a second cog? Are the two counters in the monitor cog not enough?