View Full Version : Need SERIN/SEROUT code help

07-24-2009, 02:41 AM
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:

· _CLKFREQ = 5_000_000

· BS2 : "BS2_Functions.spin"
······· Byte MODE, X
·· MODE := 00
······· 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)

John Abshier
07-24-2009, 02:59 AM
I don't know if it matters for this case but the BS2 function library has a start method that is not called in your code. Well I just looked at the code and the start method sets a variable used in a routine called by serialin_char.

John Abshier

07-24-2009, 03:04 AM
Another problem I can see if when you call serin_char you must call it before the char has started to be sent from the PC. I dont see how you do this. So it you call serin_char part what through the char being sent you will receive a different char.

07-24-2009, 04:20 AM
I added the start method to my code, and it does not improve it. The Propeller still sends back 0x1B.

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)"


07-24-2009, 05:08 AM
I think what I would do is add this

dira [ 7..0 ] := 1
to the start of the code
outa [ 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

John Abshier
07-24-2009, 05:18 AM
When I send data to the PC with FullDuplexSerial I use mode 0. Try
BS2.SEROUT_CHAR(30, MODE, 9600, 0, 8)

John Abshier