hsersetup affecting input pin 6

lbenson

Senior Member
This is on a 28X1 with firmware version A.2.

When I execute hsersetup, input pin 6 appears always to be on.

When I run the following code, it gets stuck in the "do" loop after "if pin6 = 1 then" and never reaches the sertxd printouts. If I comment out the "hsersetup" line, it works as expected. If I change pin6 to pin0 and rewire, it works as expected.

Code:
#picaxe 28X1

start:
  pause 1000
  hsersetup B2400_4, %1  ' set up background receive (on I7)
  hserinflag = 0
  b1 = 0

main:
  if pin6 = 1 then
    do while pin6 = 1
    loop
    sertxd ("Button pressed",13,10)
  endif
  inc b1
  sertxd ("loop ", #b1,13,10)
  pause 2000
  goto main
I found the reason. I'll go ahead with the post in case anyone else searches for the problem. As manual 2 states for the hsersetup statement, hsersetup configures both hserin and hserout. The hserout pin is input pin 6, so that pin cannot be used as a normal input pin.
 

westaust55

Moderator
If you look at the 28X`1 pinout (see current manual 1 page 6) you will see the the HSEROUT uses PortC pin 6 which otherwise equates to input 6.

HSERSETUP automatically defines inputs 6 (as HSEROUT) AND input 7 as (HSERIN)

They come defined as a pair so input 6 AND 7 are allocated.
HSERSETUP does not know that you only desire to use the input function.

EDIT: ah -did not read the sentence under your example code - so all is well
 
Last edited:

Technical

Technical Support
Staff member
This is a restriction of the hardware serial module in the PICmicro architecture. Unfortunately there is no way around it - it's either both pins or nothing!
 
Top