Serial Communication Input and Output, compare and contrast commands...

HertzHog

Member
Can you point me in the right direction please?
I see several ways of serial input and :confused: output. I think I understand the pin limitations of some methods and the baud speeds available, but can you explain the strengths and weaknesses of the commands Serout, SerTxd and Hserout.
For example are they all equally blocking to a polled interrupt or running program?
I do not quite understand the special reason for the Hserin and Hserout commands I guess.
Perhaps this compare and contrast bit has been done properly elsewhere but I could not find it.
 

AllyCat

Senior Member
Hi,

The Hserin and Hserout commands use dedicated hardware on the PIC(axe) chip which can be (also) accessed directly by POKESFR/PEEKSFR commands, and used this way are certainly NOT blocking. I suspect that Hserin/out of a single character are also non-blocking, but they may become blocking when used with character strings (at least with some types of PICaxe chip), including sending #variables, etc..

Because Hserin/out use dedicated hardware, they must use the allocated pin(s), however there may be one "alternate pin function" if you're prepared to delve into the "base PIC" data sheet. A wide range of baud rates is possible, particularly if you look deeply into the data sheet (or maybe a wizard).

The other commands are implemented by the PICaxe software (on-chip firmware) which generally can interface with a greater variety of pins, but with less choice of baud rate. Then, SERTXD and SERRXD commands are basically associated with the PICaxe Programming / Terminal interface and thus must use specific pins and baud rates.

Cheers, Alan.
 

lbenson

Senior Member
Hserin on the x1 and x2 picaxes can be set up for non-blocking background serial receive into the scratchpad. Non-blocking background serial receive on the M2 devices is limited to 2 characters (much can be done with 2-character commands, depending on the application). Some caveats may apply for non-blocking background serial receive depending on what else the chip is doing.
 

HertzHog

Member
I am really trying to achieve a non-blocking output string to a display that would be sent in the background. E.g.
"Level is ", numbervariable, "units"
And have that updating in a loop without blocking the measurment of incoming interrupt collected data and calculations.
So, pin and baud should be less of an issue, you see. Is Hserout easy to use advantageous and appropriate for that?
 

hippy

Ex-Staff (retired)
All PICAXE commands are blocking to some degree, in that they will execute in part or full before the PICAXE can respond to interrupts or continue program execution with a new command. It is not possible to create a completely non-blocking PICAXE program.

That is generally not a problem because the amount of blocking can be reduced to a minimum to suit the application or interrupts can be latched to overcome the effect of blocking.

When used appropriately, HSEROUT will perform less blocking than SERTXD or SEROUT will.
 

grim_reaper

Senior Member
Hertzhog,

One suggestion to your particular issue is to only update the display output when the value changes (depending what you're measuring, of course!). I find for things like domestic room temperatures, it's not really worth updating the display until the temperature has changed by an entire degree (usually runs into minutes). If it's something like RPM measurement, I guess faster methods must be used to ensure the latest information is visible.
 
Top