Need SERIN/SEROUT code help
Steel
Posts: 313
I am doing something which I thought would be easy...but the propeller is not liking it...Obviously, it is probably my issue, but I can't figure out what is wrong here...it should be easy.
I am using a PC sending a command down to the Propeller dev kit.
I have the BS2.Serin_Char to recieve the command and save it as a variable, "MODE".
I then use the BS2.Serout_Char command to send "MODE" up to the PC.
I send down 0xAA.· I recieve back 0x1B.
When I monitor the pins on the propeller, I see the 0xAA on the RX pin and I see 0x1B on the Propeller TX Pin.· For some reason, "MODE" is not storing the 0xAA and sending it back.
I have attached my scope trace showing 0xAA being recieved and 0x1B being sent.
Can someone help me?· Here is my code:
CON
· _CLKMODE = XTAL1 + PLL16X
· _CLKFREQ = 5_000_000
OBJ
·
· BS2 : "BS2_Functions.spin"
·
·
·
·
VAR
······· Byte MODE, X
PUB MAIN
·
·
·· MODE := 00
· REPEAT·
······· MODE := BS2.SERIN_CHAR(31, 9600, 1, 8)
······· CASE MODE
········· $0:
·········· 'Triggers Reset
········· $1:
·········· 'ProgPin Low·····················
········· $2:
·········· 'ProgPin High
········· $3:
·········· 'Shiftout
········· $4:
·········· 'ShiftIn
·······
······· BS2.SEROUT_CHAR(30, MODE, 9600, 1, 8)
·····
DAT
I am using a PC sending a command down to the Propeller dev kit.
I have the BS2.Serin_Char to recieve the command and save it as a variable, "MODE".
I then use the BS2.Serout_Char command to send "MODE" up to the PC.
I send down 0xAA.· I recieve back 0x1B.
When I monitor the pins on the propeller, I see the 0xAA on the RX pin and I see 0x1B on the Propeller TX Pin.· For some reason, "MODE" is not storing the 0xAA and sending it back.
I have attached my scope trace showing 0xAA being recieved and 0x1B being sent.
Can someone help me?· Here is my code:
CON
· _CLKMODE = XTAL1 + PLL16X
· _CLKFREQ = 5_000_000
OBJ
·
· BS2 : "BS2_Functions.spin"
·
·
·
·
VAR
······· Byte MODE, X
PUB MAIN
·
·
·· MODE := 00
· REPEAT·
······· MODE := BS2.SERIN_CHAR(31, 9600, 1, 8)
······· CASE MODE
········· $0:
·········· 'Triggers Reset
········· $1:
·········· 'ProgPin Low·····················
········· $2:
·········· 'ProgPin High
········· $3:
·········· 'Shiftout
········· $4:
·········· 'ShiftIn
·······
······· BS2.SEROUT_CHAR(30, MODE, 9600, 1, 8)
·····
DAT
bmp
1M
Comments
John Abshier
The PC (right now) is sending 0xAA every 100mS.· My loop in propeller code runs and then waits for the next message, so I can see it maybe being wrong on the first one but it is wrong on every message.· Also, 0x1B isn't a 'partial' message of 0xAA.
Am I assigning the SERIN to the variable correctly?
If I put in "MODE := $AA" in the line just above the SEROUT, The PC recieves 0xAA.· But It does not recieve 0xAA when I assign·the·SERIN to Mode...so it leads me to believe that something is wrong with "MODE := BS2.SERIN_CHAR(31, 9600, 1, 8)"
Grrrr
dira [noparse][[/noparse] 7..0 ] := 1
to the start of the code
and
outa [noparse][[/noparse] 7..0 ] := mode
after the serin
then you can look at pins 0 to 7 to see what was received by the prop
That would confirm if its the receive side that having the problem
BS2.SEROUT_CHAR(30, MODE, 9600, 0, 8)
John Abshier