Propeller-2 Smart-Pin pulse/cycle output (%00100)
JonTitus
Posts: 193
in Propeller 2
See my code below. I can see the generated pulses on my scope.
1. On the Propeller-2 DEV Board I calculate a period of 40 nsec per count in the Smart-Pin pulse/cycle mode. That equals a 25 MHz clock. Is that correct?
2. In this mode, what role does the Y register play? Notes in the V33 docs indicate when it is nonzero, pulses start to appear. Is the Y register a counter that gets decremented at each clock cycle (25 MHz)? Or does the register count the times the X[15:0] count reaches zero? Or does it count something else? Maybe it is not a counter at all and must be set or reset by software. I need an explanation of how to use the Y register to control the number of pulses created in this mode.
3. Does this mode alter any flags? If so, which ones and how? I appreciate the help Forum members have offered to improve the assembly-language documentation. Thank you. --Jon
1. On the Propeller-2 DEV Board I calculate a period of 40 nsec per count in the Smart-Pin pulse/cycle mode. That equals a 25 MHz clock. Is that correct?
2. In this mode, what role does the Y register play? Notes in the V33 docs indicate when it is nonzero, pulses start to appear. Is the Y register a counter that gets decremented at each clock cycle (25 MHz)? Or does the register count the times the X[15:0] count reaches zero? Or does it count something else? Maybe it is not a counter at all and must be set or reset by software. I need an explanation of how to use the Y register to control the number of pulses created in this mode.
3. Does this mode alter any flags? If so, which ones and how? I appreciate the help Forum members have offered to improve the assembly-language documentation. Thank you. --Jon
CON dat org 0 dirl #20 'Setup Smart-Pin at P20 wrpin PulseConfig, #20 'Set configuration for pulse/cycle wxpin PulseTiming, #20 'Set overall cycle time and logic-0 period dirh #20 wypin Cycles, #20 'Send count to Y register nop 'Delay two clocks for IN to drop .myloop jmp #.myloop 'wait here PulseConfig long %0000_0000_000_00000_00000000_11_00100_0 'Pulse/cycle output Cycles long $3A98 'No idea how this value gets used PulseTiming long $01F4_05DC '40 usec logic-1, 20 usec logic-0
Comments
To get an accurate pulse rate you need to set a known sysclock frequency first, eg: For 80 MHz
For readability, I'd use decimal entry to fill "PulseTiming", eg:
How do I set the Smart-Pin in pulse/cycle mode so the pulses are inverted? That is, standby output of logic-1 then logic-0 pulses, then back to logic-1 in standby state?
I have tried to use the letter "O" bit (bit P6 in the Mode-register data), but that causes the following, that you can see in one of the attached images:
Logic-0 on scope. Then output rises to logic 1 and logic-0 pulses appear. At end of pulse cycle, output remains at logic-1.
When I run the program a second, third, etc., time without changes, I see the second image--looks like an R-C discharge--from the Smart-Pin connection. So, what's going on? I still need inverted pulses. Thanks--Jon
@JonTitus
Just use OUTL #pin and OUTH #pin
They will make the pin an output at the same time.
Presume you mean automatically. Sorry cannot help with this.
Jon,
Here's an example on how to invert a output pin.
Include this config bit with your smart pin config.
The above was obtained with a slight modification to Jon's code. Start with dirh #20 along with having the invert bit in PulseConfig to obtain steady state logic-1 with logic-0 pulses. PulseTiming value changed to match comments. Hope this is what you wanted Jon, I also solved my pulse timing problem by doing this.
Seems there is a 2.56ms delay before the beginning of the first logic-1 pulse out of the smart pin, is this normal?
EDIT: Wording
My clock is 300MHz so 40us= 12000 and I specify P48 as the target smartpin.
HILO takes high and low count and sets up the Smartpin.
LOW drives P50 low.
PULSES writes wypin with that value (just an alias)
WAITPIN waits for smartpin ack
(article on my wiki page)