JMLStamp2p
01-30-2008, 04:29 AM
Good Evening,
I am trying to start a new cog to constantly look at inputs and run certain Methods contingent upon with Pin went High. I am working with Pin-7
at the moment and also have it pulled Low through a resistor and a push button to send it high. For some reason I can't get both cogs "Full_Duplex_Serial" and the "Button_Down" cog to Blink the LED's at the same time. With the code as is, Pins 16 & 23·are Blinking and it appears that my code is not correct in my Botton_Down Method. Could someone gve me some advise ?
.................................................. ...............................................
CON
·_CLKMODE = XTAL1 + PLL8X····
·_CLKFREQ = 40_000_000········
VAR
·long Stack[9], Temp
·
OBJ
·DELAY: "Clock"
·DATA: "FullDuplexSerial"
.................................................. .................................................. ...
PUB Main
·cognew(Button_Down(21), @Stack)········'Start new cog to handle the
·················································· ············'Button_Down Method
·dira[7]~
·dira[21]~~
·dira[19]~~
·data.Stop········· ·'Stop any outside process using the Full_Duplex_Serial Cog
·data.start(1,0,2,9600)····················· 'Set up Serial through FullDuplexSerial
·Recieve·········································· ············ ·'Call to my Recieve Method
.................................................. ..................................................
·································
PUB Button_Down(Pin)
·Temp := INA[7]
·repeat While Temp := 0
·· !outa[Pin]········································ 'Toggle Pin 21
·· waitcnt(40_000_000 + cnt)
·repeat While Temp :=·1
···!outa[Pin]········································ 'Toggle Pin 21
·· waitcnt(40_000_000 + cnt)
.................................................. ..................................................
PUB Recieve | rxbyte··································
· repeat
··· rxbyte := data.rx
··· if rxbyte == 1················································· ·····
····· Data_Recieved_1
····
··· if rxbyte == 4············
····· Data_Recieved_4
.................................................. .................................................. ..
·········
PUB Data_Recieved_1
· dira[16]~~
····· outa[16]~~
······· waitcnt(3_000_000 + cnt)
········· outa[16]~
·········· waitcnt(3_000_000 + cnt)
··········· data.rxflush
············ Recieve
.................................................. ..................................................
············
PUB Data_Recieved_4
· dira[23]~~
····· outa[23]~~
······· waitcnt(3_000_000 + cnt)
········· outa[23]~
·········· waitcnt(3_000_000 + cnt)
·········· data.rxflush
············ Recieve
.................................................. ..................................................
I am trying to start a new cog to constantly look at inputs and run certain Methods contingent upon with Pin went High. I am working with Pin-7
at the moment and also have it pulled Low through a resistor and a push button to send it high. For some reason I can't get both cogs "Full_Duplex_Serial" and the "Button_Down" cog to Blink the LED's at the same time. With the code as is, Pins 16 & 23·are Blinking and it appears that my code is not correct in my Botton_Down Method. Could someone gve me some advise ?
.................................................. ...............................................
CON
·_CLKMODE = XTAL1 + PLL8X····
·_CLKFREQ = 40_000_000········
VAR
·long Stack[9], Temp
·
OBJ
·DELAY: "Clock"
·DATA: "FullDuplexSerial"
.................................................. .................................................. ...
PUB Main
·cognew(Button_Down(21), @Stack)········'Start new cog to handle the
·················································· ············'Button_Down Method
·dira[7]~
·dira[21]~~
·dira[19]~~
·data.Stop········· ·'Stop any outside process using the Full_Duplex_Serial Cog
·data.start(1,0,2,9600)····················· 'Set up Serial through FullDuplexSerial
·Recieve·········································· ············ ·'Call to my Recieve Method
.................................................. ..................................................
·································
PUB Button_Down(Pin)
·Temp := INA[7]
·repeat While Temp := 0
·· !outa[Pin]········································ 'Toggle Pin 21
·· waitcnt(40_000_000 + cnt)
·repeat While Temp :=·1
···!outa[Pin]········································ 'Toggle Pin 21
·· waitcnt(40_000_000 + cnt)
.................................................. ..................................................
PUB Recieve | rxbyte··································
· repeat
··· rxbyte := data.rx
··· if rxbyte == 1················································· ·····
····· Data_Recieved_1
····
··· if rxbyte == 4············
····· Data_Recieved_4
.................................................. .................................................. ..
·········
PUB Data_Recieved_1
· dira[16]~~
····· outa[16]~~
······· waitcnt(3_000_000 + cnt)
········· outa[16]~
·········· waitcnt(3_000_000 + cnt)
··········· data.rxflush
············ Recieve
.................................................. ..................................................
············
PUB Data_Recieved_4
· dira[23]~~
····· outa[23]~~
······· waitcnt(3_000_000 + cnt)
········· outa[23]~
·········· waitcnt(3_000_000 + cnt)
·········· data.rxflush
············ Recieve
.................................................. ..................................................