More help with counters. Simple minded use of Duty cycle mode
pgbpsu
Posts: 460
I'm trying to use the Duty cycle section in the Prop App note (AN001) to get a 50% duty square wave. Although that's not my final goal I thought I should start very simply since I'm not very familiar with using the counters.
I understand I need to setup the CTRA and FRQA registers. I
When I run this I get a very ratty waveform that looks to be beyond the abilities of my 50Mhz scope. I suspect that I was missing the fact that in this mode the outgoing waveform will be 80Mhz (since that's my system clock) and I only have control over the duty. Is that correct?
Is there a way to slow this down without adjusting the system clock? What I'd really like is a user selectable frequency and duty cycle. Most likely it would be something like 150Khz wave with 1.5% duty cycle. To put it another way, I need the high part of the waveform to be as narrow as 100ns, but I only need a new cycle about every ~6uSec.
I had some brute force PASM code, but I couldn't get the smallest high-time below 150nS because it took me too many instructions.
Does anyone know how to divide down the clock for Duty mode?
Thanks,
Peter
I understand I need to setup the CTRA and FRQA registers. I
PUB Duty_mode ' mode PLL BPIN APIN '1_09876_543_21098765_432109_876_543210 CTRA := %0_00110_000_00000000_000000_000_010011 'Establish mode and APIN (BPIN is ignored) ' PHSA := 0 FRQA := $8000_0000 'Set FRQA so PHSA[noparse][[/noparse]31] toggles every clock dira[noparse][[/noparse]%1_0011] := 1 'Set APIN to output repeat 'infinite loop, so counter continues to run
When I run this I get a very ratty waveform that looks to be beyond the abilities of my 50Mhz scope. I suspect that I was missing the fact that in this mode the outgoing waveform will be 80Mhz (since that's my system clock) and I only have control over the duty. Is that correct?
Is there a way to slow this down without adjusting the system clock? What I'd really like is a user selectable frequency and duty cycle. Most likely it would be something like 150Khz wave with 1.5% duty cycle. To put it another way, I need the high part of the waveform to be as narrow as 100ns, but I only need a new cycle about every ~6uSec.
I had some brute force PASM code, but I couldn't get the smallest high-time below 150nS because it took me too many instructions.
Does anyone know how to divide down the clock for Duty mode?
Thanks,
Peter
Comments
Massimo
Thanks for the suggestion. I took a look at that and it uses the NCO mode of the counter which I believe only allows 50% duty. I need to be able to vary the duty cycle so I think I've got to use the Duty mode. I need to vary the Frequency which I'm not sure is possible in that mode.
p
Thanks for responding. After reading your post I realized I didn't present my problem accurately. It still may not be possible, but I think it makes my requirements a bit easier.
I need a stable waveform that has a given frequency and duty cycle. If I need to change that duty cycle, I'm happy to shutdown the cog, re-program the registers and start up again. Once I've picked a frequency and duty cycle, that cog will stay that way until I kill it off. So my request for varying-duty isn't accurate. If I can simply select the duty cycle and frequency, I'll be satisfied.
Do you have an example of some PASM that shows how to fix the output frequency?
Thanks,
p
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
propmod_us and propmod_1x1 are in stock. Only $30. PCB available for $5
Want to make projects and have Gadget Gangster sell them for you? propmod-us_ps_sd and propmod-1x1 are now available for use in your Gadget Gangster Projects.
Need to upload large images or movies for use in the forum. you can do so at uploader.propmodule.com for free.
http://forums.parallax.com/showthread.php?p=829640
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 9/3/2009 3:27:37 PM GMT
Massimo
Thanks for all the leads. I'm convinced there's a way to get this working the way I need to. Now I've just got to get through all these suggestions and figure out which works best/simplest.
Thanks,
Peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com