[C.CC USERS] Further thoughts on using serial with arduino UNO
Steve Pretty
steve.g.pretty at btinternet.com
Tue Jan 25 17:23:29 GMT 2011
Further to my previous postings about using serial communications on the
arduino UNO:
I recommend that, when debugging code on the UNO, that you always (until
the issue is resolved) add code to coreectly configure the serial port -
even if your code does not use it. This is because the Transterpreter
firmware running on the arduino board may need to transmit useful
diagnostic information back to occPlug, if there is a problem with your
code. If you do not do the set up, you will just see some random
characters. The following listing (it is just a test case for some code
I am developing) - shows how to add the necessary serial.setup command
to your main PROC
PROC main ()
CHAN LEVEL x, y:
SEQ
serial.setup(TX0, 28800) -- Necessary for error messages on UNO
PAR
plcing.LD (2, x!)
plcing.TP (50, x?, y!)
plcing.OUT (13, y?)
:
What might the transterpreter want to tell you? Well, so far I have
encountered the following:
Information that your program has entered a STOP state (i.e. crashed) -
in my case this was largely due to forgetting that the occam IF process
must always have a condition that evaluates true - so I had to add the
TRUE / SKIP pattern as the last condition.
Information that your program has deadlocked - a rather more difficult
one to fix - much careful thinking about which processes are trying to
send messages and which are waiting to receive. In my case, it was
simply a case of process A waiting to send to process B at the same time
as B was waiting to send to A - so neither A or B was in a position to
run - i.e. deadlock.
Steve
More information about the users
mailing list