Hserout vs Serout

hey guys

i'm using a 28X1 with a serial LCD display.

It wants 2400 baud.

Is there any advantage to hserout over serout when using low baud rates? i couldn't see any advantage of either (at low baud rates) in the manual.

Thanks

Richard
 

eclectic

Moderator
hey guys

i'm using a 28X1 with a serial LCD display.

It wants 2400 baud.

Is there any advantage to hserout over serout when using low baud rates? i couldn't see any advantage of either (at low baud rates) in the manual.

Thanks

Richard
1. The Hserout is a one pin job, for example 28X2 pinC.6
"Ordinary" serout can be done on several pins. (Depending on the chip)

2. Is the "ordinary" serout working? If it ain't broke, then .....

3. Did you sort out your last question :

http://www.picaxeforum.co.uk/showthread.php?t=8202

e
 
Last edited:

westaust55

Moderator
SEROUT command transmits serial data output (8 data bits, no parity, 1 stop bit). Can be used with True and Inverted signal. This command can be used on any PICAXE pin that can be defined as a normal output.

For the 28X1 that is portB outputs 0 to 7 (physical pins 21 to 28). While portC pins can be used as outputs, they are not “normal” outputs and thus SEROUT will not function with these pins.


HSEROUT command transmits serial data (8 data bits, no parity, 1 stop bit). This command is only available for the X1 and X2 parts via the dedicated hardware serial output pin .

The HSERSETUP command must first be used to configure the hardware serial port for serial operation. Note that this command configures two pins to be dedicated to hserin and hserout. Both pins are affected, so you cannot use just one pin for input or output.

For the 28X1 the dedicated hardware serial output pin is portC pin6 (physical pin 17). Using HSEROUT to drive an LCD display at 2400 baud could be considered overkill as you also lose the use of normal inputs In6 and In 7.
 
Last edited:

BCJKiwi

Senior Member
Two key aspects of hser;
1. It is hardware based and the serial in can be automated to run and capture in the background
2. custom baud rates can be configured.
 

Andrew Cowan

Senior Member
You can't have different baud rates for hserin and hserout, so if you want to use a serial LCD at 2400 baud, this restricts what you can use hserin for.

A
 

hippy

Ex-Staff (retired)
Also when HSERSETUP is executed it makes the TX (HSEROUT) pin an output and RX (HSERIN) pin an input, and RX cannot be used for anything else.
 

PerthEng

Member
Also when HSERSETUP is executed it makes the TX (HSEROUT) pin an output and RX (HSERIN) pin an input, and RX cannot be used for anything else.
As westaust said in post3,
"The HSERSETUP command must first be used to configure the hardware serial port for serial operation. Note that this command configures two pins to be dedicated to hserin and hserout. Both pins are affected, so you cannot use just one pin for input or output."
 

rbwilliams

New Member
The "1 stop bit" thing is really screwing me up from understanding the hserout command.

Specifically, I am looking at the MIDI spec which needs a high-to-low, start bit, before the 8-bit MIDI message.

If hserout always inserts a 1 after 8 bits, I don't see how a MIDI-receiving device will ever see a high-to-low, start bit, before the actual 8-bit MIDI message.

For instance, a typical program change message should look like this:
[11111111]0010000111000000[01111111] where the data gets read right to left.

The bytes in brackets ([...]) are what bytes I imagine should be sent to include the necessary, MIDI start and stop bits (a MIDI stopbit is a low-to-high transistion).

In between the bytes in brackets = $21C0. The LSByte of this word is $C0 which is the status byte. And the MSByte is the program change number "33".

But, if the HSEROUT always places a 1 after every 8-bits, then the message would be read differently:
[1]00100001[1]11000000[1][01111111] = $0781, where the single "[1]' is the HSEROUT stopbit. But the MIDI-receiving device doesn't know that.

Can anyone clear this up for me?

Thanks!
 
Last edited:

Technical

Technical Support
Staff member
Don't confuse the start bit + 8 bits + stop bit issue with the actual bytes you are sending. Midi DOES use 8 data bits followed by 1 stop bit, but you don't even have to worry about that side of things - its just the way the protocol works. Forget about the start & stop bits all together as it is just confusing you - the transmitter hardware adds them and then the receiver hardware ignore them, so from your point of view they are irrelevant to the actual data sent!

If you want to send a midi string of $C0 then $21 then just do

hserout 0,($C0, $21)
 

rbwilliams

New Member
Technical,

Really? That's cool. I guess I'll just have to try that.

I don't have a scope, but I would really like to see this string coming from hserout port. Any ideas about how I can do that? (cheaply)

Thanks.
 

Dippy

Moderator
I guess it depends on your definition of "see".

If you want to "see" it ...
1. .. flashing then use LED+R.
2. .. as ASCII then connect another PICAXE, write some code, and show it on an LCD or Sertxd to Terminal.
3. .. as a high-low logic pulse stream then get a cheap 'scope or programme a PIC+GLCD to display logic.
There are loads of PC based 'scopes too.
Generally, you get what you pay for.
 

rbwilliams

New Member
Thanks Dippy,

Ok, one LAST question on this topic...

I have used these lines of code in the Editor:

symbol STATUS = b17
STATUS = $C0

hsersetup 63,%00
hserout 0, (STATUS, 33)
pause 2000
hsersetup off

But the simulator still shows portc, pin6 as an input, and no activity.

What am I doing wrong?

Thanks.
 

hippy

Ex-Staff (retired)
This is an issue with the 28X1 simulation pin display which we will investigate. As long as you turn the Serial Simulation Panel on you will see the HSEROUT sending two bytes of data.

Simulate -> Simulation Panels -> Standard -> Serial
 
Top