SCL Reference: pin

The MPLAB® X simulator models the device pins (MPLAB® 8 did not) and SCL allows injection of values to these pins.

Pins are pretty complex entities. To begin with, most pins multiplex several signals. The simulator models this multiplexing and keeps track of which signal is currently driving the pin.


When accessing a pin in SCL, the signal name is used. So for example, to set RA5 high:

RA5 <= '1';
RA6 <= '0';     // example of setting a pin low

Further, pins can be in input or output mode, and digital or analog mode. Again the simulator keeps track of the current pin state.

Input versus output is perhaps the most "interesting" characteristic of a pin with regards to SCL. When SCL assigns a value to a pin that value is considered to be the value being driven to the pin from an external source. So if we assign RA5 to high as in the above example, but the pin is currently in output mode and driving low, we'll still read the pin as low.

But if the RA5 pin is subsequently switched to input mode, the high that had been previously injected via SCL will become the value of RA5.

Analog versus digital is an issue of interpretation instead of state of the pin. In other words, pins always have a voltage, which can be interpreted as digital high or low. In the simulator the nominal VDD voltage (from the datasheet) is used to model the digital state. If the voltage is greater than or equal to half the nominal VDD voltage the pin is considered digital high, otherwise the pin is digital low.

SCL allows pins to be set by voltage in addition to being set digitally:

AN0 <= 3 V;

AN1 <= 3500 mV;     // 3.5V (no decimal voltages allowed)

Pins can be used in boolean expressions:

if RA1 == '1' then

while AN0 <= 3500 mV loop

Sometimes a pin name contains a + or a - as part of its name. These two characters are illegal as part of variable names in SCL. In this case +'s are replaced with P and -'s replaced with N. So Vref+ and Vref- become VREFP and VREFN.

© 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.