Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices

E-Blocks

Flowcode Step By Step

PICmicro Projects

Labs

Getting Data into a PICmicro

<^< Inputs and Outputs | Course Index | Outputting Data >^>

The PICmicro is a digital device, but it can take data in both analogue and digital forms. For optimum flexibility programmers can choose whether certain pins on the PICmicro should be used as analogue inputs, digital inputs or digital outputs. This flexibility can result in a little confusion. For example on the 16F1937 chip shown below pin 2 is marked as 'RA0/AN0'. This means that pin 2 can be used as bit 0 of port A (Register A bit 0) or as ANalogue input 0. The function of each pin is determined by setting the contents of internal registers inside the PICmicro device and If you were programming in assembly or C code then you would have to make sure these registers were set up correctly before using the chip.

The next diagram gives some details about the PIC 16F1937 chip.

This has 5 ports, A-B-C-D-E. Each pin on Port A is labelled RA0 to RA7, pins on Port B are labelled RB0 to RB7 etc. Ports A, B, C and D have eight pins but Port E has only 4. This allows us to connect either up to eight digital sensors to port A of the 16F1937. Notice that pins RA6 and RA7 are also labelled as OSC1 and OSC2. This is because they are often connected to an external oscillator circuit instead of being used for digital i/o.

If you want to use analogue sensors, then you can use all the pins labeled with an 'ANx' (ANalogue) label. All these pins can read analogue input signals between VDD (5V) and VSS (Gnd). These happen to be on ports A, B and E of this PICmicro device.

You should also notice that most of the pins have alternative functions. For example pin 25 is labelled as 'RC6/TX/CK'. This refers to the multiple functions of pin 25 as being Register C bit 6, or the Transmit pin(X) of the internal serial interface, or the ClocK pin of the internal serial interface.

Fortunately Flowcode takes care of all of the internal settings that dictate pin functions for you.

<^< Inputs and Outputs | Course index | Outputting Data >^>

Print - Search - Login

Page last modified on May 14, 2013, at 08:01 AM