hserflag vs hserinflag

geoff07

Senior Member
I'm getting confused about hardware serial. Specifically, the difference between hserflag and hserinflag.

hserflag: is bit 5 of the flags byte signifying, when set, that a background receive has occured, as per p 228 of the (latest) 2015 manual2:

"Name Special function Command
flag5 hserial background receive has occurred hsersetup"

hserinflag: seems to do the same job: p 97 of the same manual:

"In automatic background mode the hardware serial input is fully automated.
Serial data received by the hardware pin is saved into the scratchpad memory area
as soon as it is received. Upon the hsersetup command the serial pointer
(hserptr) is reset to 0. When a byte is received it is saved to this scratchpad
address, the hserptr variable is incremented and the hserinflag flag is set (must be
cleared by user software). Therefore the value ‘hserptr -1’ indicates the last byte
written, and ‘hserinflag = 1’ indicates a byte has been received (see also the
setintflags command)."

Both seem to be valid keywords.

Could some kind person explain which should I use? and how I would know from the manual which I should use?
 

Aries

New Member
I think they are the same thing. A little bit of self-help here ...
Code:
hserflag = 0
sertxd(13,10,#hserflag," ",#hserinflag)
hserflag = 1
sertxd(13,10,#hserflag," ",#hserinflag)
hserinflag = 0
sertxd(13,10,#hserflag," ",#hserinflag)
hserinflag = 1
sertxd(13,10,#hserflag," ",#hserinflag)
I've only run this in the simulator (my hserin project is scheduled for this winter)
Code:
RESULT:
0 0
1 1
0 0
1 1
but you can see that changing either one changes both, so I suspect that hserinflag is the correct name and hserflag is an older version
 

inglewoodpete

Senior Member
hSerInFlag definately works for X2 chips.

The following code is known to work in one of my 20X2 projects. The first few lines of the interrupt routine limits the background serial receive circular buffer to 64 bytes, allowing the remainder of the scratchpad to be used for other purposes.
Rich (BB code):
Symbol False         = 0
Symbol True          = 1
Symbol mskSerInRange = %00111111 'Bytes 0-63
Symbol mskTmrAndSer  = %10100000
Symbol flgTmrAndSer  = %10100000

Interrupt:If hSerInFlag = True then                    'Restrict pointer to 0-63 (Must appear
             hSerInPtr = hSerInPtr And mskSerInRange   '        first in the interrupt routine)
             hSerInFlag = False
          EndIf
          If TOFlag = True then
              '<timer-specific code>
          EndIf    'Timer has ticked
          SetIntFlags Or flgTmrAndSer, mskTmrAndSer    'Set timer 0 or hSerial to interrupt
          Return
 

geoff07

Senior Member
Thanks for the inputs, with appreciation for the efforts. Errors in the manuals are rare so I was hoping for an 'official' view as I can hypothesize but you never know what the subtleties are. I shall have to assume that they are synonyms for now.

Interesting idea to set the size of the circular buffer. I will have to look in to that. Is there a reference source?
 

inglewoodpete

Senior Member
Interesting idea to set the size of the circular buffer. I will have to look in to that. Is there a reference source?
I'm pretty sure I didn't 'copy' the idea from the forum as such. However, the AND and OR principle is used in many low-level programming languages.
 
Top