Device Selection
Each type of PIC microcontroller offers a different combination of features; the most suitable can be selected for any given application. The range is expanding all the time, with additional features and improved performance at lower cost. Tables of MCU families at www.microchip.com allow the current features and price of each to be readily compared. The key selection criteria are:
• Total number of I/O pins available
• Grouping of I/O in ports
• Program memory size
• Data RAM size
• EEPROM data memory availability
• Timers (8-bit or 16-bit), CCP, PWM
• Number of 10-bit analogue inputs
• Serial comms (USART, SPI, I2C, CAN, LIN)
• Internal/external oscillator and maximum clock speed
• Package/footprint (DIP, SOIC, PLCC, QFP)
• Price
When developing an embedded application, the hardware will generally be specified and designed first. This will determine the number and type of inputs and outputs required.
Simple switches will require single digital input, while a keypad will require several inputs.
A temperature sensor will need an analogue input, while a motor will probably require a PWM output. Most systems use some kind of status or information display, and the type of display will determine the number of output pins needed to drive it. Serial communication will often be used if the PIC is part of a larger system or is connected to a master controller.
When the hardware requirements have been established, the program can be developed, and tested by simulation. The size of the program will then be known, so that chip memory size can be specified. In addition, the size of the stack in the selected device must be sufficient for the number of subroutine levels and interrupts; if not, the program can be restructured or a different chip used. If necessary, an overspecified chip can be used initially, and the chip that matches the application requirements more exactly substituted later.
When the design parameters, such as I/O requirements, program memory size and so on, have been finally established, the most suitable device can be selected using the search facilities on the manufacturer’s website. Summary information for selected 8-bit PIC flash microcontrollers is provided in Table 12.2, as a guide to the range of features available. The current device selection tool on the website is illustrated in Figure 12.1.
The smallest 8-bit chip currently available has only four I/O, 256 instructions and one timer with an internal 4 MHz oscillator. The largest has 70 I/O, 128k program memory, a more extensive instruction set and multiple peripherals, and runs at 42 MHz.