On an M2 part... is it possible to read the input state of the HSERIN pin independently of the background serial receive also watching it? Especially since the background serial receive is a bit different on the M2s. The documentation doesn't describe any interaction between hardware serial receive and reading the pin or if one negates or interferes with the other.
In other words...
Do an HSERSETUP that sets up background serial receive... (which on a 14M2 is pin B.1)...
Then, test IF PIN B.1 = 0 ....
and elsewhere still check for background receive, like this:
w1 = $FFFF
hserin w1
if w1 <> $FFFF then....
Do the reading of the pin and the background serial receive interfere with each other... or does HSERSETUP totally preempt the ability to read the pin in the first place?
The reason for the question is a desire to have the main program determine if the serial in is IDLE (which for an M2 part with no inversion would be HIGH) prior to seizing the bus and sending something out, but if not IDLE (remote serial device has started to send) don't transmit, but wait for the serial receive instead which might be multiple bytes.
Testing with HSERIN only returns a result at the END of a complete byte receive operation... I want to determine the serial line is in use at the START of the operation (in other words, I want to see the start bit).
The question also extends to whether this interaction would work with a COUNT command... something like this:
COUNT B.1,40,b0 ; count any low-to-high in a 40ms span - a byte at 300 baud takes 30ms and has at least one low-to-high
IF b0 > 0 then.... ; serial port was in use so try to receive
IF PIN B.1 = 0 then... ; serial port is in use right now! wait a bit and try to receive
;aha - serial port NOT in use - go ahead and transmit
or if COUNT is incompatible with background serial receive.
Even better would be the ability to use SETINT to set an interrupt that fires if B.1 goes low, which it would when receiving a start bit... but you can't do interrupts on port B on an M2 part!
In other words...
Do an HSERSETUP that sets up background serial receive... (which on a 14M2 is pin B.1)...
Then, test IF PIN B.1 = 0 ....
and elsewhere still check for background receive, like this:
w1 = $FFFF
hserin w1
if w1 <> $FFFF then....
Do the reading of the pin and the background serial receive interfere with each other... or does HSERSETUP totally preempt the ability to read the pin in the first place?
The reason for the question is a desire to have the main program determine if the serial in is IDLE (which for an M2 part with no inversion would be HIGH) prior to seizing the bus and sending something out, but if not IDLE (remote serial device has started to send) don't transmit, but wait for the serial receive instead which might be multiple bytes.
Testing with HSERIN only returns a result at the END of a complete byte receive operation... I want to determine the serial line is in use at the START of the operation (in other words, I want to see the start bit).
The question also extends to whether this interaction would work with a COUNT command... something like this:
COUNT B.1,40,b0 ; count any low-to-high in a 40ms span - a byte at 300 baud takes 30ms and has at least one low-to-high
IF b0 > 0 then.... ; serial port was in use so try to receive
IF PIN B.1 = 0 then... ; serial port is in use right now! wait a bit and try to receive
;aha - serial port NOT in use - go ahead and transmit
or if COUNT is incompatible with background serial receive.
Even better would be the ability to use SETINT to set an interrupt that fires if B.1 goes low, which it would when receiving a start bit... but you can't do interrupts on port B on an M2 part!