CTRA, CTRB in two cogs to access the same pin
TCP71
Posts: 38
This is probably a basic and dumb question, but please bear with me. I have two input pins on my prop and I want a pulse on either one of them to trigger a single output pin as quickly as possible. I am already using the ctra/ctrb (with an intermediate pin to keep the polarity right) in a single cog to make it work, but when I try to activate two cog's registers to take the two input pins and make the intermediate or output pin change state, neither has any affect anymore. The code for the cogs is this:
PUB CTRReg1
dira[ETTOut]~~ 'Output
dira[PPSspare]~~
dira[B1TB]~
Ctra := %01011 << 26
Ctra |= PPSspare << 9
Ctra |= B1TB
Ctrb := %01011 << 26
Ctrb |= ETTOut << 9
Ctrb |= PPSspare
repeat
pause(100)
PUB CTRReg2
dira[ETTOut]~~ 'Output
dira[PPSspare]~~
dira[B2TB]~
Ctra := %01011 << 26
Ctra |= PPSspare << 9
Ctra |= B2TB
Ctrb := %01011 << 26
Ctrb |= ETTOut << 9
Ctrb |= PPSspare
repeat
pause(100)
The ETTOut is the single pin I need to mimic the two input pins, B2TB and B1TB, with PPSspare being the intermediate pin that is in opposite polarity to the required output. I call both CTRReg1 and CTRReg2 using the cognew command. Any help would be appreciated.
PUB CTRReg1
dira[ETTOut]~~ 'Output
dira[PPSspare]~~
dira[B1TB]~
Ctra := %01011 << 26
Ctra |= PPSspare << 9
Ctra |= B1TB
Ctrb := %01011 << 26
Ctrb |= ETTOut << 9
Ctrb |= PPSspare
repeat
pause(100)
PUB CTRReg2
dira[ETTOut]~~ 'Output
dira[PPSspare]~~
dira[B2TB]~
Ctra := %01011 << 26
Ctra |= PPSspare << 9
Ctra |= B2TB
Ctrb := %01011 << 26
Ctrb |= ETTOut << 9
Ctrb |= PPSspare
repeat
pause(100)
The ETTOut is the single pin I need to mimic the two input pins, B2TB and B1TB, with PPSspare being the intermediate pin that is in opposite polarity to the required output. I call both CTRReg1 and CTRReg2 using the cognew command. Any help would be appreciated.
Comments
I did notice that the "pause(100)" seems unnecessary and at least one counterB section is redundant.