SCL Reference: packetin() Function

The SCL packetin() function parses a string for values to be injected to an SFR.

packetin(inString,     // String to be parsed
         sfr,          // SFR to be injected
         append);      // boolean, if false, clear previous packets

packetin(inString, RCREG, true);

packetin() is similar to accessin() in that the data is injected to the SFR "on demand", or each time the processor reads the SFR.

inString is a String variable with the data to be parsed. The data can be in two different formats, white space delimited hexadecimal values, or strings of characters. The string is often read in from a file.

06F 3FE 45 FFFE

"The quick brown fox."

The sfr is just the Special Function Register that will receive the injection values.

append is a boolean specifying whether previously parsed data is kept or discarded.

To understand what append does it is useful to know that packetin() was implemented to support register injection to the UART receive register RCREG. Moreover, that injection to RCREG is not on-demand. Instead the UART peripheral simulation determines when the next injection should occur, based on baud rate. So it is possible that some data values have not been injected yet when new data values are parsed by packetin. UART developers wanted to be able to simulate missed data packets. This is accomplished by setting append to false, causing the previous data values, not yet injected values to be thrown away before the new values are parsed.

Remember that packetin() is not limited to RCREG injection, and that all other SFRs are injected on-demand.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.