When leaving a project running that generates log files or other data out of a serial data port it's nice to have a way of collecting the serial data and then taking it away for later readback. 

Software description 

After power on while waiting for first byte = low power standby mode. 

Record mode.

First input byte activates software.  Data speed fixed 9600,8,n

Timer-triggered interrupt service (ISR) periodically samples RXD input to receive serial data.  The ISR each time called gradually builds each byte and when a byte is complete it's written to the PIC's RAM ('Store').  Also via the ISR process the TXD output pin follows the incoming data as a realtime recording monitor.

RAM Store is 80(?) bytes wide, wrapped into a loop. When end of Store reached, write starts again from the beginning. Old Store data in RAM is continually overwritten as it circulates around. 

To keep track of the amount of buffered data in Store there is Store Pointer (SP) and a ReadStore Pointer (RSP) which track the respective write and read positions of the RAM Store. Each new received byte increments the SP by one.  

When StorePointer (write) advances past ReadStorePointer (read) by 64 bytes or more, the software reads a batch of bytes from the Store. Each byte read from Store increments RSP by one. An E2PROM page write is 64 bytes. Total page write time is about 5 ms.  

The I2C write process to the E2PROM is paused momentarily whenever servicing the ISR that may still be reading more input data. The I2C protocol doesn't mind these random wait states as it's static and asynchronous.

Playback mode

Pressing the Mode button at any time cancels Record. The recorded data in the E2PROM is played back. Pressing the Mode button during playback cancels and device returns to Record mode. 

Erase data

Press and hold the Mode button.