How do I properly use the CTRA/FRQA/PSHA calls?
PoundSign2
Posts: 129
Hello friends! While looking through the OBEX I found some PWM objects and I wanted to better understand PWM. It's not something that I use frequently so I don't have much experience with it. After looking through the Propeller Manual under the CTRA/FRQA/PHSA commands I didn't come away with an exact method of using it properly. The point of the CTRA is to be the Counter and FRQA I believe sets the frequency (seems obvious) however I really don't know what PHSA is or how it works, and I don't know what it means. My guess is that PHSA means Phase(PortA).
While the OBEX files have given me a much better intuition as to how the code is executing and doing it's thing, I still do not understand how to construct the code on my own. A little insight and help would be much appreciated. Especially a good expanation for what is going on. Like what is CTRA, why do I use this and why and how do I use the other 2 registers (PHSA & FREQA)?
While the OBEX files have given me a much better intuition as to how the code is executing and doing it's thing, I still do not understand how to construct the code on my own. A little insight and help would be much appreciated. Especially a good expanation for what is going on. Like what is CTRA, why do I use this and why and how do I use the other 2 registers (PHSA & FREQA)?
Comments
Follow Mike's suggestion, and it's likely the biggest conceptual leap, is to grasp that a Prop 'Counter' is actually a 32 bit adder that can do
PHSA = FRQA + PHSA at a rate up to once every clock cycle.
The Add is conditional, based on the 5-bit CTRMODE Field in the CTRA config register.
In the DOCs it says : The counter operates by adding the contents of FRQA to PHSA at each clock cycle the accumulate condition is true.
Thanks a bunch for the links. Earlier I downloaded another example however, I've spent the last few hours trying to modified to something I could use. Hadn't got a clue how to make it work, but I tried and managed to learn a bunch in the process (since I was looking up syntax like crazy). Anyways what I did was download THIS OBEX file and tried to get it to work on all 8 pins (16..23) but I could never get it to work. I somehow got 6 to turn on, but I don't know how I did it. Just a chance bug perhaps. In any case, thanks for the help I really appreciate. The 32 channel PWM OBEX file is pretty much what I'm looking for. I just want to control the Demo Board and QuickStart on-board LEDs to experiment with.