Need to sync timers, and match on count for one via polling/waiting
nmz787
Posts: 24
Basically I want two GPIO lines toggling at 50% duty, one will be 4Mhz, the other will be <=1khz, variable in 250uS increments so its edges always always correspond to a rising edge of the 4Mhz line
I need to set up the two PWM lines with the timers, then start them, sync them, then poll the <=1khz PWM line to see when it goes low... then I'll execute some code there.
I need to set up the two PWM lines with the timers, then start them, sync them, then poll the <=1khz PWM line to see when it goes low... then I'll execute some code there.
Comments
Do you really need a 50% duty? A lot of devices don't really care about the duty cycle of a clock pulse. They'll have mininum and maximum times when different lines need to rise and fall.
It might help if you post the datasheet of the device.
-Phil
*Before Kuroneko jumps on this assertion, it's not quite that stringent, as long as frqb is related to frqa by a simple shift operation.
Yes same project, I couldn't find the minimum time for WAITCNT in assembly (though the SPIN version clearly states minimum is 281 or 381 cycles)... I think I'd be able to use that if it could respond in less than 20 cycles. The propeller manual also doesn't specify how quickly WAITPNE can respond... I thought of having a 4Mhz PWM looping back to a pin that was being sensed with WAITPNE, then toggling the lines manually
The datasheet says the duty cycle doesn't matter on the variable period GPIO, but looks like 50% on the master clock (4Mhz) GPIO (though it doesn't mention that specifically)
http://openspectrometer.com/datasheets/TCD1304AP.pdf
wait, what!? That seems like a big fault/limitation... am I wrong?
-Phil
-Phil
Almost, the two that don't change are ΦM and SH... ICG is pulled low for 1 SH period, just before 1/2 mark of the first SH period (ICG goes low just before SH goes high, ICG comes high on rising edge of ΦM after ~1 SH period of time )
I made a spreadsheet that's public of the times and frequencies of the 2^N value possibilities :
https://docs.google.com/spreadsheet/ccc?key=0AkTsdtdxo56DdDFZb0EtU2JyY3l2am53b2o1b1ZKR2c
I think that the values provided should be fine, at least for now (I don't know how much the exposure time will need adjusted, but the minimum is 10 microseconds)
So how do I sync the clocks? I'm testing this code now:
-Phil
Do you have some pointers, I'm not sure how to go about syncing them
-Phil
Thanks, got it working just after you posted.
So if the counter has 10 decimals left before overflowing, and FRQx adds 15, is the counter at 0 or 5 on the next clock cycle? I tried changing the FRQB to something that was just a multiple of FRQA and it didn't seem to work, but I didn't mess with it too much so I can't be sure I did it right (i.e. off by one, etc)
-Phil