PIC16F1937-I/ML Microchip Technology, PIC16F1937-I/ML Datasheet - Page 13

IC PIC MCU FLASH 512KX14 44-QFN

PIC16F1937-I/ML

Manufacturer Part Number
PIC16F1937-I/ML
Description
IC PIC MCU FLASH 512KX14 44-QFN
Manufacturer
Microchip Technology
Series
PIC® XLP™ 16Fr

Specifications of PIC16F1937-I/ML

Core Size
8-Bit
Program Memory Size
14KB (8K x 14)
Core Processor
PIC
Speed
32MHz
Connectivity
I²C, LIN, SPI, UART/USART
Peripherals
Brown-out Detect/Reset, LCD, POR, PWM, WDT
Number Of I /o
36
Program Memory Type
FLASH
Eeprom Size
256 x 8
Ram Size
512 x 8
Voltage - Supply (vcc/vdd)
1.8 V ~ 5.5 V
Data Converters
A/D 14x10b
Oscillator Type
Internal
Operating Temperature
-40°C ~ 85°C
Package / Case
44-QFN
Controller Family/series
PIC16F
No. Of I/o's
36
Eeprom Memory Size
256Byte
Ram Memory Size
512Byte
Cpu Speed
32MHz
No. Of Timers
5
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
ARITHMETIC
Arithmetic on the PIC12/16 is a very basic function but
can be full of small frustrations when working with
multi-byte data. For example, the legacy ADD
instructions do not include an add with Carry, so multi-
byte operations require additional instructions to
precondition the next Most Significant Byte (MSB)
based upon the results of the previous add. New
instructions added to the enhanced PIC12/16 simplify
this work, shaving many instructions from common
algorithms.
Multi-byte Add
Adding two 16-bit values with a PIC12/16 is usually
done as follows:
This code works quite well but has 2 extra cycles in the
middle, due to the missing add with Carry. This code
can be converted to the enhanced PIC12/16 as follows:
The enhanced version saves two instructions. If 16-bit
values are used extensively, the savings will add up.
Multi-byte Subtract
Subtract is similar to add because the Borrow flag must
be handled in the following computations. The legacy
code is as follows:
© 2009 Microchip Technology Inc.
Add16_enhanced
Add16
Sub16
ADDWF
MOVF
ADDWF
MOVF
BTFSC
ADDLW
SUBWF msb_b,f
MOVF
ADDWF
MOVF
ADDWFC
MOVF
SUBWF lsb_b,f
MOVF
BTFSS STATUS,C
ADDLW 0xFF
lsb_a,w
msb_a,w
msb_b,f
msb_b,f
lsb_a,w
lsb_b,f
msb_a,w
lsb_a,w
lsb_b,f
msb_a,w
STATUS,C
0x01
The enhanced version is as follows:
The enhanced version of subtract saves two
instructions.
Shifting
Shifting is the fastest method to divide or multiply by a
power of two, therefore, it is often used instead of
rotates. A rotate instruction can be made to operate like
a shift simply be preconditioning the Carry flag. The
legacy code is as follows:
This code will work but the W register is overwritten by
the first rotate. The ASRF instruction simplifies this
problem by handling the sign extension in hardware.
This is faster by requiring less code. Arithmetic
_Left_Shift does not need to perform a sign exten-
sion. It simply brings zero into the LSB.
If sign extend is not required, the code is simpler.
Simply clearing the Carry flag before performing the
rotate will create a logical shift. These examples can be
converted to single enhanced PIC12/16 instructions.
Logical_Right_Shift
Logical_Left_Shift
Sub16_enhanced
Arithmetic_Right_Shift
RRF
ASRF val,f
RLF
BCF
RRF
BCF
MOVF
SUBWF lsb_b,f
MOVF
SUBWFB msb_b,f
RLF
val,w ;save the MSB
val,f ;rotate right
val,f
STATUS,C
val,f
STATUS,C
lsb_a,w
msb_a,w
in the Carry
(corrupt W
with sign extend.
DS41375A-page 13

Related parts for PIC16F1937-I/ML