counters and info
DXC
Posts: 33
People,
I like more info on counter with examples if possible.
Would it be possible to let 1 pin count to 4096 and the puls with another pin also set as a counter and the start counting to 4096 ......
All assembly ofcourse.
gr,
I like more info on counter with examples if possible.
Would it be possible to let 1 pin count to 4096 and the puls with another pin also set as a counter and the start counting to 4096 ......
All assembly ofcourse.
gr,
Comments
Yes, you can certainly count up to 4096.... and beyond if you want...
check out the following document:
http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/PELabsFunBook-v1.1.pdf and see chapter 7, "Counter Modules and Circuit Applications Lab".
It's presented in SPIN, however, and not assembly. But that should give you some idea of how the Propeller works with counters. Maybe somebody else on the forum can help you with the assembly aspects, since I don't know any.
hope that helps,
thnx for the explanating pdf, will look at it tommorow, it's now 22:39 here in holland.
Dont know if I will understand it soon, have to do some examples.
Also dont think its though to understand but just have to get a nice start.
Think they are very handy for many tasks.
gr,
IIRC there is an App Note AN001 on the counters and it should be downloaded with the PropTool. You may also try looking for the document section at the home page www.parallax.com
You could also do what you want using the free-running counter CNT. There is a description in the propeller manual which is also downloaded with the PropTool. This is just a 32bit counter which increments every clock (80MHz = 12.5ns). So you could also use this to do what you require.
I do not quite understand what you are trying to do. If you cannot work it out from the documents don't hesitate to post more info here for some more help.
I am controlling a tlc5940 now with 2cogs ,, 1 shifts data in and the other continously generates 4096 pulses on 1 pin at 5Mhz and after that it pulses another pin repeatetly.
I think that when using a counter a for making 4096 pulses and then a counter b that pulses once if counter a gets at 4097.
After that counter must be reset and start making 4096 pulses etc...
What clock speed are running at (e.g. 80MHz)? Also, is that sequence of 4K pulses + BLANK pulse running forever or do you need a certain amount of control over it (on/off/N-times)?
But you can't generate a puls per hardware when counter B reaches 4096, you just get the number of pulses in PHSB and must then do the puls with software.
Andy
prop is at 80Mhz, and the sequence runs forever.
Ariba,
Is it no possible to do something like below:
amount__1_______2_____.......4095____4096
GSCLK: 1111000011110000......1111000011110000 <-5Mhz pulses
BLANK: 0000000000000000......0000000000000110
That's certainly doable but requires a certain amount of s/w control. I'd stick with a counter for the 5MHz signal and a s/w loop which generates the BLANK pulse (which looks like a quarter of a GSCLK cycle which is 4 system clock cycles and can be easily achieved).
Something like this should do:
If Blank also can have only 1 high cycle (...0000000000000100) then you can use the second counter in DUTY mode and set it to a frequency of 5MHz/4096. But this needs some synchronization at start of the counters so that the DUTY pulse comes in the right position. If you do it in Assembly this should be possible by writing the right PHSB value before start of CTRB.
FRQB must be set to 2^32 / 16 / 4096.
Andy
Is it not possible to let de blank counter put "1" on an output pin when it reaches an certain amount of numbers.
Counter one put on 5 Mhz in 4096 steps.
Blank counter at 5Mhz in 16384 steps.
Setting blank counter with a AND function so when Blank counter reaches 11 1111 1111 1110 AND 11 1111 1111 1111 the Pin on the blank will be high.
Maybe 2 are not possible but only 11 1111 1111 1111 will also work.
This way I can setup 1 COG for datashifting and handeling the grayscale clock.
According the datasheet of the TLC5940 the min. pulse length is 20ns for clear, so if you clock the Propeller with not more then 50MHz this should work: Here are both counters in DUTY mode. Set the PLLx8 instead of PLLx16 so that the Propeller runs with 40MHz to try it.
Andy
Too bad I have to set de prop too a lower clock never the less I will look at it to understand it.
gr,
Counter usage:
- cog A: ctra for 5MHz pulse train
- cog B: ctra/ctrb for 2 cycle DUTY pulse
After that it's actually blindingly obvious (code only shows BLANK pulse generation).