hsersetup with shared scratchpad

MORA99

Senior Member
Im looking for some advise on how to handle shared scratchpad between program data and hardware serial.

First a copy from the manual ...
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 (se also the setintflags
command). The scratchpad is a circular buffer that overflows without warning.
I would like to use the scratchpad for some temporary data, but also use hardware serial, what would be the best way of doing that ?

1: Run the hserserup and change the hserptr right after to 100 (I will then use 0-99 myself), this will look "nice" in a memory map.
2: Move my own data to 20-119 and let hardware serial use the first 0-19bytes, this will not require to change the pointer after hsersetup.

What happens when the ptr is at the end, does it simply overflow ?

The data I will be recieving _should_ be just a few bytes, and the pc will wait for a responce before sending any more, and im only using hardware serial so that I dont have to worry about when to read it.


Alternativly I need an external ram thingy for my own stuff (or wait for x2 :) )
 

Technical

Technical Support
Staff member
Either will do fine. When the pointers get to 128 they simply overflow without warning back to 0.
 

MORA99

Senior Member
Thanks for the quick reply, in my qoute it actually says it will overflow, oops :)

I will run hsersetup then and change hserptr to 100 and reset it to 100 after I read the contens.
 
Top