Hsersetup problem

geoff07

Senior Member
Just checking, but I'm having problems with hardware serial on an 08M2+. Is there any reason why Hsersetup might hang with firmware v4.A? Processing just stops. It works in the simulator.
 

AllyCat

Senior Member
Hi,

Yes +1 . And What Problems? HSERIN or HSEROUT, What baud rate, etc., etc...

I have indeed found several "problems" with HSERIN on the M2s.

Cheers, Alan.
 

geoff07

Senior Member
The problem is as I said. Hsersetup hangs, I.e. the statement before executes and the statements after don't. If it helps, this is the code:

sertxd("Hser;")
HSerSetup B4800_32,%00
sertxd("Hser out;")

The first sertxd does it's thing, then everything stops. Weird I know.
 

Buzby

Senior Member
Sertxd uses the same pin as hserout, so the second sertxd might not be showing.

( I don't trust the simulator much when it is simulating hardware IO ! )
 

geoff07

Senior Member
Indeed. But this is the setup command, before any I/O is actually performed. Hence my question about the firmware. The chips may be a bit old, so it is possible that current chips use a later version.
 

Buzby

Senior Member
Are you sure it's stopped ?.

hsersetup will configure leg 7 ( pin c.0 ) to be used with the hardware IO even before any data is sent.

sertxd is software IO, so it might not like it if a pin is allocated to the internal hardware.
 

AllyCat

Senior Member
Hi,

How do you know that the setup is "hanging", since you have "disconnected" the SERTXD command path? As the command reference says:

"When 'hserout' output is enabled on the 08M2 and 14M2 any 'sertxd' commands will have no effect, will not output any data."

Cheers, Alan.
 

geoff07

Senior Member
Has it stopped? Well there aren't many other outputs, so it's going to be tricky if sertxd and hserout are incompatible. This isn't mentioned in the manual, though some potential conflicts are. Hmm. Time for a think.
 

geoff07

Senior Member
Interesting. The manual does not say what the online reference that you quoted says. So that probably is the cause. Thanks for the info. Can't trust the manual any more.
 

Buzby

Senior Member
it's going to be tricky if sertxd and hserout are incompatible.
They are not 'incompatible', they are 'alternatives'.

On an 08M2 or a 14M2 you have to choose hardware or software control of this pin. On a bigger chip, with seperate pins, you can use both methods.

Just use hserout in place of sertxd.
 

geoff07

Senior Member
You are right, though I said incompatible as both are described in the current manual on the web site and there is no caveat regarding single use. I don't know how the pins are connected to the internal logic but I could quite imagine both might be possible together, though doubtless at the same baud rate. But the online reference does make it clear. If they are not going to update the manual they should remove it to avoid confusion. Anyway, thanks to all for the clarification.
 

AllyCat

Senior Member
Hi,

No, selecting the (PIC) HSEROUT hardware physically disconnects the "normal" pin driver, which as Buzby said is used by the (PICaxe) firmware (software) to bit-bang the serial data. But there is also the "Alternate Pin Function" SF Register (APFCON) which allows you to switch the HSEROUT pin to Leg3 (C.4) and/or HSERIN onto Leg2 (C.5).

However, I believe that HSEROUT can do all (and more) than SERTXD, or you can switch between them "on the fly". HSERSETUP allows you to Enable and Disable both the HSEROUT and/or HSERIN hardware individually, but make sure that you allow the Hardware to complete the transmission of your character(s) before disconnecting it. :)

Cheers, Alan.
 

inglewoodpete

Senior Member
A more conclusive test would be to set another pin high immediately after the hSerSetup command. Eg High C.1, C.2 or C.4. A LED (with current limiting resistor), logic probe or multimeter will tell you if that command has been reached.
 

geoff07

Senior Member
Yes, thanks for the input. And just in case anyone else has this issue, note that you have to invert the Hserout signal to be compatible with sertxd/Serial Terminal:

e.g. HSerSetup B4800_32, %10

Otherwise you get perplexing garbage
 

Hemi345

Senior Member
I ran into the same issue just the other day thinking my program had hung when using HSERSETUP on a 14M2. I've used it many times before on 20X2 and 28X2, but always use sertxd to help explain in the terminal what the program is doing. Now I just issue a HSERSETUP OFF before I want to sertxd some data.

Alan, I'll have to remember that SFR. That would have come in handy with my last project (y)
 
Top