Part Number Hot Search : 
S1L50000 03070 CL432AVS MCM6705A NDP6050 14004 MBR40030 AP560
Product Description
Full Text Search
 

To Download PIC16F1938T-ISP Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2009 microchip technology inc. preliminary ds41364c pic16f193x/lf193x data sheet 28/40/44-pin flash-based, 8-bit cmos microcontrollers with lcd driver and nanowatt xlp technology
ds41364c-page 2 preliminary ? 2009 microchip technology inc. information contained in this publication 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. trademarks the microchip name and logo, the microchip logo, dspic, k ee l oq , k ee l oq logo, mplab, pic, picmicro, picstart, rfpic and uni/o are registered trademarks of microchip technology incorporated in the u.s.a. and other countries. filterlab, hampshire, hi-tech c, linear active thermistor, mxdev, mxlab, seeval and the embedded control solutions company are registered trademarks of microchip technology incorporated in the u.s.a. analog-for-the-digital age, appl ication maestro, codeguard, dspicdem, dspicdem.net, dspicworks, dsspeak, ecan, economonitor, fansense, hi-tide, in-circuit serial programming, icsp, mindi, miwi, mpasm, mplab certified logo, mplib, mplink, mtouch, octopus, omniscient code generation, picc, picc-18, picdem, picdem.net, pickit, pictail, pic 32 logo, real ice, rflab, select mode, total endurance, tsharc, uniwin driver, wiperlock and zena are trademarks of microchip technology incorporated in the u.s.a. and other countries. sqtp is a service mark of microchip technology incorporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2009, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. note the following details of the code protection feature on microchip devices: ? microchip products meet the specification cont ained in their particular microchip data sheet. ? microchip believes that its family of products is one of the mo st secure families of its kind on the market today, when used i n the intended manner and under normal conditions. ? there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowledge, require using the microchip produc ts in a manner outside the operating specifications contained in microchip?s data sheets. most likely, the person doing so is engaged in theft of intellectual property. ? microchip is willing to work with the customer who is concerned about the integrity of their code. ? neither microchip nor any other semiconductor manufacturer c an guarantee the security of their code. code protection does not mean that we are guaranteeing the product as ?unbreakable.? code protection is constantly evolving. we at microchip are co mmitted to continuously improvi ng the code protection features of our products. attempts to break microchip?s c ode protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that act. microchip received iso/ts-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona; gresham, oregon and design centers in california and india. the company?s quality system processes and procedures are for its pic ? mcus and dspic ? dscs, k ee l oq ? code hopping devices, serial eeproms, microperipherals, nonvolatile memory and analog products. in addition, microchip?s quality system for the design and manufacture of development systems is iso 9001:2000 certified.
? 2009 microchip technology inc. preliminary ds41364c-page 3 pic16f193x/lf193x devices included in this data sheet: pic16f193x devices: pic16lf193x devices: high-performance risc cpu: ? only 49 instructions to learn: - all single-cycle instructions except branches ? operating speed: - dc ? 32 mhz oscillator/clock input - dc ? 125 ns instruction cycle ? up to 16k x 14 words of flash program memory ? up to 1024 bytes of data memory (ram) ? interrupt capability with automatic context saving ? 16-level deep hardware stack ? direct, indirect and relative addressing modes ? processor read access to program memory ? pinout compatible to other 28/40-pin pic16cxxx and pic16fxxx microcontrollers special microcontroller features: ? precision internal oscillator: - factory calibrated to 1%, typical - software selectable frequency range from 32 mhz to 31 khz ? power-saving sleep mode ? power-on reset (por) ? power-up timer (pwrt) and oscillator start-up timer (ost) ? brown-out reset (bor) - selectable between two trip points - disable in sleep option ? multiplexed master clear with pull-up/input pin ? programmable code protection ? high endurance flash/eeprom cell: - 100,000 write flash endurance - 1,000,000 write eeprom endurance - flash/data eeprom retention: > 40 years ? wide operating voltage range: - 1.8v-5.5v (pic16f193x) - 1.8v-3.6v (pic16lf193x) pic16lf193x low-power features: ? standby current: - 60 na @ 1.8v, typical ? operating current: -7.0 a @ 32 khz, 1.8v, typical -150 a @ 1 mhz, 1.8v, typical ? timer1 oscillator current: - 600 na @ 32 khz, 1.8v, typical ? low-power watchdog timer current: - 500 na @ 1.8v, typical peripheral features: ? up to 35 i/o pins and 1 input-only pin: - high-current source/sink for direct led drive - individually programmable interrupt-on-pin change pins - individually programmable weak pull-ups ? integrated lcd controller: - up to 96 segments - variable clock input - contrast control - internal voltage reference selections ? capacitive sensing module (mtouch tm ) - up to 16 selectable channels ? a/d converter: - 10-bit resolution and up to 14 channels - selectable 1.024/2.048/4.096v voltage reference ? timer0: 8-bit timer/counter with 8-bit programmable prescaler ? enhanced timer1 - dedicated low-power 32 khz oscillator driver - 16-bit timer/counter with prescaler - external gate input mode with toggle and single shot modes - interrupt-on-gate completion ? timer2, 4, 6: 8-bit timer/counter with 8-bit period register, prescaler and postscaler ? two capture, compare, pwm modules (ccp) - 16-bit capture, max. resolution 125 ns - 16-bit compare, max. resolution 125 ns - 10-bit pwm, max. frequency 31.25 khz ? three enhanced capture, compare, pwm modules (eccp) - 3 pwm time-base options - auto-shutdown and auto-restart - pwm steering - programmable dead-band delay ? pic16f1933 ? pic16f1934 ? pic16f1936 ? pic16f1937 ? pic16f1938 ? pic16f1939 ? pic16lf1933 ? pic16lf1934 ? pic16lf1936 ? pic16lf1937 ? pic16lf1938 ? pic16lf1939 28/40/44-pin flash-based, 8-bit cmos microcontrollers with lcd driver with nano watt xlp technology
pic16f193x/lf193x ds41364c-page 4 preliminary ? 2009 microchip technology inc. peripheral features (continued): ? master synchronous serial port (mssp) with spi and i 2 c tm with: - 7-bit address masking - smbus/pmbus tm compatibility - auto-wake-up on start ? enhanced universal synchronous asynchronous receiver transmitter (eusart) - rs-232, rs 485 and lin compatible - auto-baud detect ? sr latch (555 timer): - multiple set/reset input options ? 2 comparators: - rail-to-rail inputs/outputs - power mode control - software enable hysteresis ? voltage reference module: - fixed voltage reference (fvr) with 1.024v, 2.048v and 4.096v output levels - 5-bit rail-to-rail resistive dac with positive and negative reference selection pic16f193x/lf193x family types device program memory flash (words) data eeprom (bytes) sram (bytes) i/o?s 10-bit a/d (ch) capsense (ch) comparators timers 8/16-bit eusart i 2 c?/spi eccp ccp lcd pic16f1933 pic16lf1933 4096 256 256 25 11 8 2 4/1 yes yes 3 2 16 (1) /4 pic16f1934 pic16lf1934 4096 256 256 36 14 16 2 4/1 yes yes 3 2 24/4 pic16f1936 pic16lf1936 8192 256 512 25 11 8 2 4/1 yes yes 3 2 16 (1) /4 pic16f1937 pic16lf1937 8192 256 512 36 14 16 2 4/1 yes yes 3 2 24/4 pic16f1938 pic16lf1938 16384 256 1024 25 11 8 2 4/1 yes yes 3 2 16 (1) /4 pic16f1939 pic16lf1939 16384 256 1024 36 14 16 2 4/1 yes yes 3 2 24/4 note 1: com3 and seg15 share the same physical pin on pic16f1933/1936/1938/pic16lf1933/1936/1938, therefore, seg15 is not available when using 1/4 multiplex displays.
? 2009 microchip technology inc. preliminary ds41364c-page 5 pic16f193x/lf193x pin diagram ? 28-pin spdip/soic/ssop ( pic16f1933/1936/1938, pic16lf1933/1936/1938) 28-pin spdip, soic, ssop pic16f1933/1936/1938 pic16lf1933/1936/1938 1 2 3 4 5 6 7 8 9 10 v pp /mclr /re3 seg12/v cap (2) /ss (1) /srnq (1) /c2out (1) /c12in0-/an0/ra0 seg7/c12in1-/an1/ra1 com2/dacout/v ref -/c2in+/an2/ra2 seg15/com3/v ref +/c1in+/an3/ra3 seg4/ccp5/srq/t0cki/cps6/c1out/ra4 seg5/v cap (2) /ss (1) /srnq (1) /cps7/c2out (1) /an4/ra5 rb6/icspclk/icdclk/seg14 rb5/an13/cps5/p2b (1) /ccp3 (1) /p3a (1) /t1g (1) /com1 rb4/an11/cps4/p1d/com0 rb3/an9/c12in2-/cps3/ccp2 (1) / p2a (1) /vlcd3 rb2/an8/cps2/p1b/vlcd2 rb1/an10/c12in3-/cps1/p1c/vlcd1 rb0/an12/cps0/ccp4/sri/int/seg0 v dd v ss 11 12 13 14 15 16 17 18 19 20 28 27 26 25 24 23 22 21 v ss seg2/clkin/osc1/ra7 seg1/v cap (2) /clkout/osc2/ra6 p2b (1) /t1cki/t1oso/rc0 p2a (1) /ccp2 (1) /t1osi/rc1 seg3/p1a/ccp1/rc2 seg6/scl/sck/rc3 rc5/sdo/seg10 rc4/sdi/sda/t1g (1) /seg11 rc7/rx/dt/p3b/seg8 rc6/tx/ck/ccp3 (1) /p3a (1) /seg9 rb7/icspdat/icddat/seg13 note 1: pin function is selectable via the apfcon register. 2: pic16f193x devices only.
pic16f193x/lf193x ds41364c-page 6 preliminary ? 2009 microchip technology inc. pin diagram ? 28-pin qfn/uqfn ( pic16f1933/1936/1938, pic16lf1933/1936/1938) 2 3 6 1 18 19 20 21 15 7 16 17 p2b (1) /t1cki/t1oso/rc0 5 4 rb7/icspdat/icddat/seg13 rb6/icspclk/icdclk/seg14 rb5/an13/cps5/p2b (1) /ccp3 (1) /p3a (1) /t1g (1) /com1 rb4/an11/cps4/p1d/com0 rb3/an9/c12in2-/cps3/ccp2 (1) /p2a (1) /vlcd3 rb2/an8/cps2/p1b/vlcd2 rb1/an10/c12in3-/cps1/p1c/vlcd1 rb0/an12/cps0/ccp4/sri/int/seg0 v dd v ss rc7/rx/dt/p3b/seg8 seg9/p3a (1) /ccp3 (1) /ck/tx/rc6 seg10/sdo/rc5 seg11/t1g (1) /sda/sdi/rc4 re3/mclr /v pp ra0/an0/c12in0-/c2out (1) /srnq (1) /ss (1) /v cap (2) /seg12 ra1/an1/c12in1-/seg7 com2/dacout/v ref -/c2in+/an2/ra2 seg15/com3/v ref +/c1in+/an3/ra3 seg4/ccp5/srq/t0cki/cps6/c1out/ra4 seg5 (1) /v cap (2) /ss (1) /srnq/cps7/c2out (1) /an4/ra5 v ss seg2/clkin/osc1/ra7 seg1/v cap (2) /clkout/osc2/ra6 (1) p2a/ (1) ccp2/t1osi/rc1 seg3/p1a/ccp1/rc2 seg6/scl/sck/rc3 9 10 13 8 14 12 11 27 26 23 28 22 24 25 pic16f1933/1936/1938 pic16lf1933/1936/1938 28-pin qfn/uqfn note 1: pin function is selectable via the apfcon register. 2: pic16f193x devices only.
? 2009 microchip technology inc. preliminary ds41364c-page 7 pic16f193x/lf193x table 1: 28-pin summary (pic16f1933/1936/1938, pic16lf1933/1936/1938) i/o 28-pin sip 28-pin qfn/uqfn ansel a/d cap sense comparator sr latch timers ccp eusart mssp lcd interrupt pull-up basic ra0 2 27 y an0 ? c12in0-/ c2out (1) srnq (1) ? ? ? ss (1) seg12 ? ? v cap (2) ra1 3 28 y an1 ? c12in1- ? ? ? ? ? seg7 ? ? ? ra2 4 1 y an2/ v ref - ? c2in+/ dacout ? ? ? ? ? com2 ? ? ? ra3 5 2 y an3/ v ref + ? c1in+ ? ? ? ? ? seg15/ com3 ?? ? ra4 6 3 y ? cps6 c1out srq t0cki ccp5 ? ? seg4 ? ? ? ra5 7 4 y an4 cps7 c2out (1) srnq (1) ???ss (1) seg5 ? ? v cap (2) ra6 10 7 ? ? ? ? ? ? ? ? ? seg1 ? ? osc2/ clkout v cap (2) ra7 9 6 ? ? ? ? ? ? ? ? ? seg2 ? ? osc1/ clkin rb0 21 18 y an12 cps0 ? sri ? ccp4 ? ? seg0 int/ ioc y ? rb1 22 19 y an10 cps1 c12in3- ? ? p1c ? ? vlcd1 ioc y ? rb2 23 20 y an8 cps2 ? ? ? p1b ? ? vlcd2 ioc y ? rb3 24 21 y an9 cps3 c12in2- ? ? ccp2 (1) / p2a (1) ? ? vlcd3 ioc y ? rb4 25 22 y an11 cps4 ? ? ? p1d ? ? com0 ioc y ? rb5 26 23 y an13 cps5 ? ? t1g (1) p2b (1) ccp3 (1) / p3a (1) ??com1iocy ? rb6 27 24 ? ? ? ? ? ? ? ? ? seg14 ioc y icspclk/ icdclk rb7 28 25 ? ? ? ? ? ? ? ? ? seg13 ioc y icspdat/ icddat rc0 11 8 ? ? ? ? ? t1oso/ t1cki p2b (1) ? ? ? ? ? ? rc1 12 9 ? ? ? ? ? t1osi ccp2 (1) / p2a (1) ?? ??? ? rc2 13 10 ? ? ? ? ? ? ccp1 / p1a ? ? seg3 ? ? ? rc3 14 11 ? ? ? ? ? ? ? ? sck/scl seg6 ? ? ? rc4 15 12 ? ? ? ? ? t1g (1) ? ? sdi/sda seg11 ? ? ? rc51613???? ?? ? ?sdoseg10?? ? rc6 17 14 ? ? ? ? ? ? ccp3 (1) p3a (1) tx/ck ? seg9 ? ? ? rc7 18 15 ? ? ? ? ? ? p3b rx/dt ? seg8 ? ? ? re3126???? ?? ? ?? ??ymclr /v pp v dd 20 17 ? ? ? ? ? ? ? ? ? ? ? ? v dd vss 8, 19 5, 16 ???? ?? ? ?? ??? v ss note 1: pin functions can be moved using the apfcon register. 2: pic16f193x devices only.
pic16f193x/lf193x ds41364c-page 8 preliminary ? 2009 microchip technology inc. pin diagram ? 40-pin pdip ( pic16f1934/1937/1939, pic16lf1934/1937/1939) 40-pin pdip pic16f1934/1937/1939 pic16lf1934/1937/1939 2 3 4 5 6 7 8 9 10 v pp /mclr /re3 seg12/v cap (2) /ss (1) /srnq (1) /c2out (1) /c12in0-/an0/ra0 seg7/c12in1-/an1/ra1 com2/dacout/v ref -/c2in+/an2/ra2 seg15/v ref +/c1in+/an3/ra3 seg4/srq/t0cki/cps6/c1out/ra4 seg5/v cap (2) /ss (1) /srnq (1) /cps7/c2out (1) /an4/ra5 seg21/ccp3 (1) /p3a (1) /an5/re0 seg22/p3b/an6/re1 seg23/ccp5/an7/re2 rb6/icspclk/icdclk/seg14 rb5/an13/cps5/ccp3 (1) /p3a (1) /t1g (1) /com1 rb4/an11/cps4/com0 rb3/an9/c12in2-/cps3/ccp2 (1) / p2a (1) / vlcd3 rb2/an8/cps2/vlcd2 rb1/an10/c12in3-/cps1/vlcd1 rb0/an12/cps0/sri/int/seg0 v dd v ss rd2/cps10/p2b (1) 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 v dd v ss seg2/clkin/osc1/ra7 seg1/v cap (2) /clkout/osc2/ra6 p2b (1) /t1cki/t1oso/rc0 p2a (1) /ccp2 (1) /t1osi/rc1 seg3/p1a/ccp1/rc2 seg6/sck/scl/rc3 com3/cps8/rd0 ccp4/cps9/rd1 rc5/sdo/seg10 rc4/sdi/sda/t1g (1) /seg11 rd3/cps11/p2c/seg16 rd4/cps12/p2d/seg17 rc7/rx/dt/seg8 rc6/tx/ck/seg9 rd7/cps15/p1d/seg20 rd6/cps14/p1c/seg19 rd5/cps13/p1b/seg18 rb7/icspdat/icddat/seg13 1 note 1: pin function is selectable via the apfcon register. 2: pic16f193x devices only.
? 2009 microchip technology inc. preliminary ds41364c-page 9 pic16f193x/lf193x pin diagram ? 44-pin qfn ( pic16f1934/1937/1939, pic16lf1934/1937/1939) 10 11 2 3 4 5 6 1 18 19 20 21 22 12 13 14 15 38 8 7 44 43 42 41 40 39 16 17 29 30 31 32 33 23 24 25 26 27 28 36 34 35 9 37 seg7/c12in1-/an1/ra1 seg12/v cap (2) /ss (1) /srnq (1) /c2out (1) /c12in0-/an0/ra0 v pp /mclr /re3 vlcd3 / p2a (1) / ccp2 (1) /cps3/c12in2-/an9/rb3 seg13/icddat/icspdat/rb7 seg14/icdclk/icspclk/rb6 com1/t1g (1) /p3a (1) /ccp3 (1) /cps5/an13/rb5 com0/cps4/an11/rb4 nc rc6/tx/ck/seg9 rc5/sdo/seg10 rc4/sdi/sda/t1g (1) /seg11 rd3/cps11/p2c/seg16 rd2/cps10/p2b (1) rd1/cps9/ccp4 rd0/cps8/com3 rc3/scl/sck/seg6 rc2/ccp1/p1a/seg3 rc1/t1osi/ccp2 (1) /p2a (1) rc0/t1oso/t1cki/p2b (1) ra6/osc2/clkout/v cap (2) /seg1 ra7/osc1/clkin/seg2 v ss v ss nc v dd re2/an7/ccp5/seg23 re1/an6/p3b/seg22 re0/an5/ccp3 (1) /p3a (1) /seg21 ra5/an4/c2out (1) /cps7/srnq (1) /ss (1) /v cap (2) /seg5 ra4/c1out/cps6/t0cki/srq/seg4 seg8/dt/rx/rc7 seg17/p2d/cps12/rd4 seg18/p1b/cps13/rd5 seg19/p1c/cps14/rd6 seg20/p1d/cps15/rd7 v ss v dd v dd seg0/int/sri/cps0/an12/rb0 vlcd1/cps1/c12in3-/an10/rb1 vlcd2/cps2/an8/rb2 44-pin qfn pic16f1934/1937/1939 pic16lf1934/1937/1939 seg15v ref +/c1in+/an3/ra3 com2/dacout/v ref -/c2in+/an2/ra2 note 1: pin function is selectable via the apfcon register. 2: pic16f193x devices only.
pic16f193x/lf193x ds41364c-page 10 preliminary ? 2009 microchip technology inc. pin diagram ? 44-pin tqfp ( pic16f1934/1937/1939, pic16lf1934/1937/1939) 44-pin tqfp 10 11 2 3 6 1 18 19 20 21 22 12 13 14 15 38 8 7 44 43 42 41 40 39 16 17 29 30 31 32 33 23 24 25 26 27 28 36 34 35 9 37 seg15/v ref +/c1in+/an3/ra3 com2/dacout/v ref -/c2in+/an2/ra2 seg7/c12in1-/an1/ra1 seg12/v cap (2) /ss (1) /srnq (1) /c2out (1) /c12in0-/an0/ra0 v pp /mclr /re3 nc seg13/icddat/icspdat/rb7 seg14/icdclk/icspclk/rb6 com1/t1g (1) /p3a (1) /ccp3 (1) /cps5/an13/rb5 com0/cps4/an11/rb4 nc nc nc rc0/t1oso/t1cki/p2b (1) v ss v dd seg0/int/sri/cps0/an12/rb0 vlcd1/cps1/c12in3-/an10/rb1 vlcd2/cps2/an8/rb2 vlcd3 / p2a (1) / ccp2 (1) /cps3/c12in2-/an9/rb3 5 4 pic16f1934/1937/1939 pic16lf1934/1937/1939 ra6/osc2/clkout/v cap (2) /seg1 ra7/osc1/clkin/seg2 v ss v dd re2/an7/ccp5/seg23 re1/an6/p3b/seg22 re0/an5/ccp3 (1) /p3a (1) /seg21 ra5/an4/c2out (1) /cps7/srnq (1) /ss (1) /v cap (2) /seg5 ra4/c1out/cps6/t0cki/srq/seg4 seg8/dt/rx/rc7 seg17/p2d/cps12/rd4 seg18/p1b/cps13/rd5 seg19/p1c/cps14/rd6 seg20/p1d/cps15/rd7 rc6/tx/ck/seg9 rc5/sdo/seg10 rc4/sdi/sda/t1g (1) /seg11 rd3/cps11/p2c/seg16 rd2/cps10/p2b (1) rd1/cps9/ccp4 rd0/cps8/com3 rc3/scl/sck/seg6 rc2/ccp1/p1a/seg3 rc1/t1osi/ccp2 (1) /p2a (1) note 1: pin function is selectable via the apfcon register. 2: pic16f193x devices only.
? 2009 microchip technology inc. preliminary ds41364c-page 11 pic16f193x/lf193x table 2: 40/44-pin summary(pic16f1934/1937/1939, pic16lf1934/1937/1939) i/o 40-pin pdip 44-pin tqfp 44-pin qfn ansel a/d cap sense comparator sr latch timers ccp eusart mssp lcd interrupt pull-up basic ra0 2 19 19 y an0 ? c12in0-/ c2out (1) srnq (1) ? ? ? ss (1) seg12 ? ? v cap ra1 3 20 20 y an1 ? c12in1- ? ? ? ? ? seg7 ? ? ? ra2 4 21 21 y an2/ v ref - ? c2in+/ dacout ? ? ? ? ? com2 ? ? ? ra3 5 22 22 y an3/ v ref + ? c1in+ ? ? ? ? ? seg15 ? ? ? ra4 6 23 23 y ? cps6 c1out srq t0cki ? ? seg4 ? ? ? ra5 7 24 24 y an4 cps7 c2out (1) srnq (1) ???ss (1) seg5 ? ? v cap ra6 14 31 33 ? ? ? ? ? ? ? ? ? seg1 ? ? osc2/ clkout v cap ra7 13 30 32 ? ? ? ? ? ? ? ? ? seg2 ? ? osc1/ clkin rb0 33 8 9 y an12 cps0 ? sri ? ? ? ? seg0 int/ ioc y ? rb1 34 9 10 y an10 cps1 c12in3- ? ? ? ? ? vlcd1 ioc y ? rb2 35 10 11 y an8 cps2 ? ? ? ? ? ? vlcd2 ioc y ? rb3 36 11 12 y an9 cps3 c12in2- ? ? ccp2 (1) / p2a (1) ? ? vlcd3 ioc y ? rb4 37 14 14 y an11 cps4 ? ? ? ? ? ? com0 ioc y ? rb5 38 15 15 y an13 cps5 ? ? t1g (1) ccp3 (1) / p3a (1) ??com1iocy ? rb6 39 16 16 ? ? ? ? ? ? ? ? ? seg14 ioc y icspclk/ icdclk rb7 40 17 17 ? ? ? ? ? ? ? ? ? seg13 ioc y icspdat/ icddat rc0 15 32 34 ? ? ? ? ? t1oso/ t1cki p2b (1) ? ? ? ? ? ? rc1 16 35 35 ? ? ? ? ? t1osi ccp2 (1) / p2a (1) ?? ???? rc2 17 36 36 ? ? ? ? ? ? ccp1 / p1a ? ? seg3 ? ? ? rc3 18 37 37 ? ? ? ? ? ? ? ? sck/scl seg6 ? ? ? rc4 23 42 42 ? ? ? ? ? t1g (1) ? ? sdi/sda seg11 ? ? ? rc5 24 43 43 ? ? ? ? ? ? ? ? sdo seg10 ? ? ? rc6 25 44 44 ? ? ? ? ? ? ? tx/ck ? seg9 ? ? ? rc7 26 1 1 ? ? ? ? ? ? ? rx/dt ? seg8 ? ? ? rd0 19 38 38 y ? cps8 ? ? ? ? ? ? com3 ? ? ? rd1 20 39 39 y ? cps9 ? ? ? ccp4 ? ? ? ? ? ? rd2 21 40 40 y ? cps10 ? ? ? p2b (1) ? ? ? ? ? ? rd3 22 41 41 y ? cps11 ? ? ? p2c ? ? seg16 ? ? ? rd4 27 2 2 y ? cps12 ? ? ? p2d ? ? seg17 ? ? ? rd5 28 3 3 y ? cps13 ? ? ? p1b ? ? seg18 ? ? ? rd6 29 4 4 y ? cps14 ? ? ? p1c ? ? seg19 ? ? ? rd7 30 5 5 y ? cps15 ? ? ? p1d ? ? seg20 ? ? ? re0 8 25 25 y an5 ? ? ? ? ccp3 (1) p3a (1) ? ? seg21 ? ? ? re1 9 26 26 y an6 ? ? ? ? p3b ? ? seg22 ? ? ? re2 10 27 27 y an7 ? ? ? ? ccp5 ? ? seg23 ? ? ? re3 1 18 18 ? ? ? ? ? ? ? ? ? ? ? y mclr /v pp v dd 11, 32 7, 28 7,8, 28 ? ? ? ? ? ? ? ? ? ? ? ? v dd vss 12, 31 6, 29 6,30, 31 ?? ? ? ? ? ? ? ? ? ? ? v ss note 1: pin functions can be moved using the apfcon register.
pic16f193x/lf193x ds41364c-page 12 preliminary ? 2009 microchip technology inc. table of contents 1.0 device overview ............................................................................................................. ........................................................... 15 2.0 memory organization ......................................................................................................... ........................................................ 23 3.0 resets ...................................................................................................................... .................................................................. 59 4.0 interrupts .................................................................................................................. .................................................................. 71 5.0 low dropout (ldo) voltage regulator ......................................................................................... ............................................. 83 6.0 i/o ports ................................................................................................................... .................................................................. 85 7.0 interrupt-on-change ......................................................................................................... ....................................................... 105 8.0 oscillator module (with fail-safe clock monitor)............................................................................ ......................................... 109 9.0 sr latch.................................................................................................................... ............................................................... 123 10.0 device configuration ....................................................................................................... ......................................................... 127 11.0 analog-to-digital converter (adc) module ................................................................................... ........................................... 133 12.0 comparator module.......................................................................................................... ........................................................ 145 13.0 digital-to-analog converter (dac) module ................................................................................... ........................................... 153 14.0 fixed voltage reference .................................................................................................... ...................................................... 157 15.0 timer0 module .............................................................................................................. ........................................................... 159 16.0 timer1 module with gate control............................................................................................ ................................................. 163 17.0 timer2/4/6 modules......................................................................................................... ......................................................... 175 18.0 capacitive sensing module .................................................................................................. .................................................... 179 19.0 capture/compare/pwm modules (eccp1, eccp2, eccp3, ccp4, ccp5) .............................................................. ............ 185 20.0 enhanced universal synchronous asynchronous receiver transmitter (eusart) .................................................. ............. 215 21.0 liquid crystal display (lcd) driver module ................................................................................. ............................................ 243 22.0 master synchronous serial port (mssp) module ............................................................................... ..................................... 275 23.0 data eeprom and flash program memory control ............................................................................... ................................ 323 24.0 power-down mode (sleep) .................................................................................................... .................................................. 335 25.0 in-circuit serial programming? (icsp?) ..................................................................................... .......................................... 337 26.0 instruction set summary .................................................................................................... ...................................................... 339 27.0 development support........................................................................................................ ....................................................... 353 28.0 electrical specifications.................................................................................................. .......................................................... 357 29.0 dc and ac characteristics graphs and charts ................................................................................ ....................................... 389 30.0 packaging information...................................................................................................... ........................................................ 391 appendix a: data sheet revision history........................................................................................ .................................................. 405 appendix b: migrating from other pic? devices .................................................................................. ........................................... 405 index .......................................................................................................................... ........................................................................ 407 the microchip web site ......................................................................................................... ............................................................ 415 customer change notification service ........................................................................................... ................................................... 415 customer support ............................................................................................................... ............................................................... 415 reader response ................................................................................................................ .............................................................. 416 product identification system.................................................................................................. ........................................................... 417
? 2009 microchip technology inc. preliminary ds41364c-page 13 pic16f193x/lf193x to our valued customers it is our intention to provide our valued customers with the best documentation possible to ensure successful use of your micro chip products. to this end, we will continue to improve our publications to better suit your needs. our publications will be refined and enhanced as new volumes and updates are introduced. if you have any questions or comments regar ding this publication, please contact the marketing communications department via e-mail at docerrors@mail.microchip.com or fax the reader response form in the back of this data sheet to (480) 792-4150. we welcome your feedback. most current data sheet to obtain the most up-to-date version of this data s heet, please register at our worldwide web site at: http://www.microchip.com you can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page . the last character of the literature number is the vers ion number, (e.g., ds30000a is version a of document ds30000). errata an errata sheet, describing minor operational differences fr om the data sheet and recommended workarounds, may exist for curren t devices. as device/documentation issues become known to us, we will publish an errata sheet. the errata will specify the revisi on of silicon and revision of document to which it applies. to determine if an errata sheet exists for a particular device, please check with one of the following: ? microchip?s worldwide web site; http://www.microchip.com ? your local microchip sales office (see last page) ? the microchip corporate literature center; u.s. fax: (480) 792-7277 when contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (inclu de literature number) you are using. customer notification system register on our web site at www.microchip.com/cn to receive the most current information on all of our products.
pic16f193x/lf193x ds41364c-page 14 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 15 pic16f193x/lf193x 1.0 device overview the pic16f193x/lf193x devices are described within this data sheet. they are available in 28/40/44-pin packages. figure 1-1 shows a block diagram of the pic16f193x/lf193x devices. table 1-1 shows the pinout descriptions. figure 1-1: pic16f193x/lf193x block diagram data bus 8 14 program bus instruction reg program counter 8 level stack (13-bit) direct addr 7 9 addr mux indirect addr fsr reg status reg mux alu w reg power-up timer oscillator start-up timer power-on reset watchdog timer instruction decode & control timing generation osc1/clkin osc2/clkout v dd porta ra4 rc0 rc1 rc2 rc3 rc4 rc5 rc6 rc7 8 8 brown-out reset ra3 ra1 ra0 12 3 ra6 ra7 rb6 rb7 v ss internal oscillator block configuration data bus 8 14 program bus instruction reg program counter 8 level stack (13-bit) direct addr 7 addr mux indirect addr fsr reg status reg mux alu w reg instruction decode & control timing generation v dd rc1 8 8 3 v ss internal oscillator block configuration 15 data bus 8 14 program bus instruction reg program counter 16-level stack (15-bit) direct addr 7 ram addr addr mux indirect addr fsr0 reg status reg mux alu w reg instruction decode and control timing generation v dd portb portc ra5 8 8 ra2 3 rb0 rb1 rb2 rb3 rb4 rb5 v ss internal oscillator block configuration flash program memory ram timer1 timer0 timer2/4/6 comparators timer1 ccp4/5 eccp1/2/3 mssp addressable eusart data eeprom 256 bytes sr latch lcd rd0 rc1 rd2 rd3 rd4 rd5 rd6 rd7 rd1 portd re0 re2 re3/mclr re1 porte fsr reg fsr reg fsr1 reg 15 15 mux 15 program memory read (pmr)
pic16f193x/lf193x ds41364c-page 16 preliminary ? 2009 microchip technology inc. 1.1 enhanced mid-range cpu pic16f193x/lf193x devices contain an enhanced mid-range 8-bit cpu core. the cpu has 49 instructions. interrupt capability includes automatic context saving. the hardware stack is 16 levels deep and has overflow and underflow reset capability. direct, indirect, and relative addressing modes are available. two file select registers (fsrs) provide the ability to read program and data memory. during interrupts, certain registers are automatically saved in shadow registers and restored when returning from the interrupt. this saves stack space and user code. see section 4.5 ?context saving? , for more information. 1.1.1 16-level stack with overflow and underflow reset the pic16f193x/lf193x devices have an external stack memory 15 bits wide and 16 deep. during normal operation, the stack is assumed to be 16 words deep. if enabled, a stack overflow or underflow will set the appropriate bit (stkovf or stkunf) in the pcon register, and cause a software reset. see section section 2.4 ?stack? for more details. 1.1.2 file select registers there are two 16-bit file select registers (fsr). fsrs can access all file registers and program memory, which allows one data pointer for all memory. when an fsr points to program memory, there is 1 additional instruction cycle in instructions using indf to allow the data to be fetched. there are also new instructions to support the fsrs. see section 2.5 ?indirect addressing, indf and fsr registers? for more details. 1.1.3 instruction set there are 48 instructions for the enhanced mid-range cpu to support the features of the cpu. see section 26.0 ?instruction set summary? for more details.
? 2009 microchip technology inc. preliminary ds41364c-page 17 pic16f193x/lf193x table 1-1: pic16f193x/lf193x pinout description name function input type output type description ra0/an0/c12in0-/c2out (1) / srnq (1) /ss (1) /v cap (2) /seg12 ra0 ttl cmos general purpose i/o. an0 an ? a/d channel 0 input. c12in0- an ? comparator c1 or c2 negative input. c2out ? cmos comparator c2 output. srnq ? cmos sr latch inverting output. ss st ? slave select input. v cap power power filter capacitor for voltage regulator (pic16f193x only). seg12 ? an lcd analog output. ra1/an1/c12in1-/seg7 ra1 ttl cmos general purpose i/o. an1 an ? a/d channel 1 input. c12in1- an ? comparator c1 or c2 negative input. seg7 ? an lcd analog output. ra2/an2/c2in+/v ref -/cv ref / com2 ra2 ttl cmos general purpose i/o. an2 an ? a/d channel 2 input. c2in+ an ? comparator c2 positive input. v ref - an ? a/d negative voltage reference input. cv ref ? an comparator voltage reference output. com2 ? an lcd analog output. ra3/an3/c1in+/v ref +/ com3 (3) /seg15 ra3 ttl cmos general purpose i/o. an3 an ? a/d channel 3 input. c1in+ an ? comparator c1 positive input. v ref + an ? a/d voltage reference input. com3 (3) ? an lcd analog output. seg15 ? an lcd analog output. ra4/c1out/cps6/t0cki/srq/ ccp5/seg4 ra4 ttl cmos general purpose i/o. c1out ? cmos comparator c1 output. cps6 an ? capacitive sensing input 6. t0cki st ? timer0 clock input. srq ? cmos sr latch non-inverting output. ccp5 st cmos capture/compare/pwm5. seg4 ? an lcd analog output. ra5/an4/c2out (1) /cps7/ srnq (1) /ss (1) /v cap (2) /seg5 ra5 ttl cmos general purpose i/o. an4 an ? a/d channel 4 input. c2out ? cmos comparator c2 output. cps7 an ? capacitive sensing input 7. srnq ? cmos sr latch inverting output. ss st ? slave select input. v cap power power filter capacitor for voltage regulator (pic16f193x only). seg5 ? an lcd analog output. legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels i 2 c? = schmitt trigger input with i 2 c hv = high voltage xtal = crystal levels note 1: pin function is selectable via the apfcon register. 2: pic16f193x devices only. 3: pic16f1933/1936/1938/pic16lf1933/1936/1938 devices only. 4: portd is available on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only. 5: re<2:0> are available on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only
pic16f193x/lf193x ds41364c-page 18 preliminary ? 2009 microchip technology inc. ra6/osc2/clkout/v cap (2) / seg1 ra6 ttl cmos general purpose i/o. osc2 ? xtal crystal/resonator (lp, xt, hs modes). clkout ? cmos f osc /4 output. v cap power power filter capacitor for voltage regulator (pic16f193x only). seg1 ? an lcd analog output. ra7/osc1/clkin/seg2 ra7 ttl cmos general purpose i/o. osc1 xtal ? crystal/resonator (lp, xt, hs modes). clkin cmos ? external clock input (ec mode). seg2 ? an lcd analog output. rb0/an12/cps0/ccp4/sri/int/ seg0 rb0 ttl cmos general purpose i/o. indivi dually controlled interrupt-on-change. individually enabled pull-up. an12 an ? a/d channel 12 input. cps0 an ? capacitive sensing input 0. ccp4 st cmos capture/compare/pwm4. sri ? st sr latch input. int st ? external interrupt. seg0 ? an lcd analog output. rb1/an10/c12in3-/cps1/p1c/ vlcd1 rb1 ttl cmos general purpose i/o. indivi dually controlled interrupt-on-change. individually enabled pull-up. an10 an ? a/d channel 10 input. c12in3- an ? comparator c1 or c2 negative input. cps1 an ? capacitive sensing input 1. p1c ? cmos pwm output. vlcd1 an ? lcd analog input. rb2/an8/cps2/p1b/vlcd2 rb2 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. an8 an ? a/d channel 8 input. cps2 an ? capacitive sensing input 2. p1b ? cmos pwm output. vlcd2 an ? lcd analog input. rb3/an9/c12in2-/cps3/ ccp2 (1) /p2a (1) /vlcd3 rb3 ttl cmos general purpose i/o. indivi dually controlled interrupt-on-change. individually enabled pull-up. an9 an ? a/d channel 9 input. c12in2- an ? comparator c1 or c2 negative input. cps3 an ? capacitive sensing input 3. ccp2 st cmos capture/compare/pwm2. p2a ? cmos pwm output. vlcd3 an ? lcd analog input. table 1-1: pic16f193x/lf193x pi nout description (continued) name function input type output type description legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels i 2 c? = schmitt trigger input with i 2 c hv = high voltage xtal = crystal levels note 1: pin function is selectable via the apfcon register. 2: pic16f193x devices only. 3: pic16f1933/1936/1938/pic16lf1933/1936/1938 devices only. 4: portd is available on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only. 5: re<2:0> are available on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only
? 2009 microchip technology inc. preliminary ds41364c-page 19 pic16f193x/lf193x rb4/an11/cps4/p1d/com0 rb4 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. an11 an ? a/d channel 11 input. cps4 an ? capacitive sensing input 4. p1d ? cmos pwm output. com0 ? an lcd analog output. rb5/an13/cps5/p2b/ccp3 (1) / p3a (1) /t1g (1) /com1 rb5 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. an13 an ? a/d channel 13 input. cps5 an ? capacitive sensing input 5. p2b ? cmos pwm output. ccp3 st cmos capture/compare/pwm3. p3a ? cmos pwm output. t1g st ? timer1 gate input. com1 ? an lcd analog output. rb6/icspclk/icdclk/seg14 rb6 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. icspclk st ? serial programming clock. icdclk st ? in-circuit debug clock. seg14 ? an lcd analog output. rb7/icspdat/icddat/seg13 rb7 ttl cmos general purpose i/o. individually controlled interrupt-on-change. individually enabled pull-up. icspdat st cmos icsp? data i/o. icddat st cmos in-circuit data i/o. seg13 ? an lcd analog output. rc0/t1oso/t1cki/p2b (1) rc0 st cmos general purpose i/o. t1oso xtal xtal timer1 oscillator connection. t1cki st ? timer1 clock input. p2b ? cmos pwm output. rc1/t1osi/ccp2 (1) /p2a (1) rc1 st cmos general purpose i/o. t1osi xtal xtal timer1 oscillator connection. ccp2 st cmos capture/compare/pwm2. p2a ? cmos pwm output. rc2/ccp1/p1a/seg3 rc2 st cmos general purpose i/o. ccp1 st cmos capture/compare/pwm1. p1a ? cmos pwm output. seg3 ? an lcd analog output. rc3/sck/scl/seg6 rc3 st cmos general purpose i/o. sck st cmos spi clock. scl i 2 codi 2 c? clock. seg6 ? an lcd analog output. table 1-1: pic16f193x/lf193x pi nout description (continued) name function input type output type description legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels i 2 c? = schmitt trigger input with i 2 c hv = high voltage xtal = crystal levels note 1: pin function is selectable via the apfcon register. 2: pic16f193x devices only. 3: pic16f1933/1936/1938/pic16lf1933/1936/1938 devices only. 4: portd is available on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only. 5: re<2:0> are available on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only
pic16f193x/lf193x ds41364c-page 20 preliminary ? 2009 microchip technology inc. rc4/sdi/sda/t1g (1) /seg11 rc4 st cmos general purpose i/o. sdi st ? spi data input. sda i 2 codi 2 c? data input/output. t1g st ? timer1 gate input. seg11 ? an lcd analog output. rc5/sdo/seg10 rc5 st cmos general purpose i/o. sdo ? cmos spi data output. seg10 ? an lcd analog output. rc6/tx/ck/ccp3/p3a/seg9 rc6 st cmos general purpose i/o. tx ? cmos usart asynchronous transmit. ck st cmos usart synchronous clock. ccp3 st cmos capture/compare/pwm3. p3a ? cmos pwm output. seg9 ? an lcd analog output. rc7/rx/dt/p3b/seg8 rc7 st cmos general purpose i/o. rx st ? usart asynchronous input. dt st cmos usart synchronous data. p3b ? cmos pwm output. seg8 ? an lcd analog output. rd0 (4) /cps8/com3 rd0 st cmos general purpose i/o. cps8 an ? capacitive sensing input 8. com3 ? an lcd analog output. rd1 (4) /cps9/ccp4 rd1 st cmos general purpose i/o. cps9 an ? capacitive sensing input 9. ccp4 st cmos capture/compare/pwm4. rd2 (4) /cps10/p2b rd2 st cmos general purpose i/o. cps10 an ? capacitive sensing input 10. p2b ? cmos pwm output. rd3 (4) /cps11/p2c/seg16 rd3 st cmos general purpose i/o. cps11 an ? capacitive sensing input 11. p2c ? cmos pwm output. seg16 ? an lcd analog output. rd4 (4) /cps12/p2d/seg17 rd4 st cmos general purpose i/o. cps12 an ? capacitive sensing input 12. p2d ? cmos pwm output. seg17 ? an lcd analog output. rd5 (4) /cps13/p1b/seg18 rd5 st cmos general purpose i/o. cps13 an ? capacitive sensing input 13. p1d ? cmos pwm output. seg18 ? an lcd analog output. table 1-1: pic16f193x/lf193x pi nout description (continued) name function input type output type description legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels i 2 c? = schmitt trigger input with i 2 c hv = high voltage xtal = crystal levels note 1: pin function is selectable via the apfcon register. 2: pic16f193x devices only. 3: pic16f1933/1936/1938/pic16lf1933/1936/1938 devices only. 4: portd is available on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only. 5: re<2:0> are available on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only
? 2009 microchip technology inc. preliminary ds41364c-page 21 pic16f193x/lf193x rd6 (4) /cps14/p1c/seg19 rd6 st cmos general purpose i/o. cps14 an ? capacitive sensing input 14. p1c ? cmos pwm output. seg19 ? an lcd analog output. rd7 (4) /cps15/p1d/seg20 rd7 st cmos general purpose i/o. cps15 an ? capacitive sensing input 15. p1d ? cmos pwm output. seg20 ? an lcd analog output. re0 (5) /an5/p3a (1) /ccp3 (1) / seg21 re0 st cmos general purpose i/o. an5 an ? a/d channel 5 input. p3a ? cmos pwm output. ccp3 st cmos capture/compare/pwm3. seg21 ? an lcd analog output. re1 (5) /an6/p3b/seg22 re1 st cmos general purpose i/o. an6 an ? a/d channel 6 input. p3b ? cmos pwm output. seg22 ? an lcd analog output. re2 (5) /an7/ccp5/seg23 re2 st cmos general purpose i/o. an7 an ? a/d channel 7 input. ccp5 st cmos capture/compare/pwm5. seg23 ? an lcd analog output. re3/mclr /v pp re3 ttl ? general purpose input. mclr st ? master clear with internal pull-up. v pp hv ? programming voltage. v dd v dd power ? positive supply. v ss v ss power ? ground reference. table 1-1: pic16f193x/lf193x pi nout description (continued) name function input type output type description legend: an = analog input or output cmos = cmos compatible input or output od = open drain ttl = ttl compatible input st = schmitt trigger input with cmos levels i 2 c? = schmitt trigger input with i 2 c hv = high voltage xtal = crystal levels note 1: pin function is selectable via the apfcon register. 2: pic16f193x devices only. 3: pic16f1933/1936/1938/pic16lf1933/1936/1938 devices only. 4: portd is available on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only. 5: re<2:0> are available on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only
pic16f193x/lf193x ds41364c-page 22 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 23 pic16f193x/lf193x 2.0 memory organization 2.1 program memory organization the enhanced mid-range core has a 15-bit program counter capable of addressing 32k x 14 program memory space. table 2-1 shows the memory sizes implemented for the pic16f193x/lf193x device family. accessing a location above these boundaries will cause a wrap-around within the implemented memory space. the reset vector is at 0000h and the interrupt vector is at 0004h (see figures 2-1, 2-2 and 2-3). table 2-1: device sizes and addresses device program memory space (words) last program memory address pic16f1933 / pic16lf1933 4,096 0fffh pic16f1934 / pic16lf1934 4,096 0fffh pic16f1936 / pic16lf1936 8,192 1fffh pic16f1937 / pic16lf1937 8,192 1fffh pic16f1938 / pic16lf1938 16,384 3fffh pic16f1939 / pic16lf1939 16,384 3fffh
pic16f193x/lf193x ds41364c-page 24 preliminary ? 2009 microchip technology inc. figure 2-1: program memory map and stack for the pic16f1933/pic16lf1933/ pic16f1934/pic16lf1934 figure 2-2: program memory map and stack for the pic16f1936/pic16lf1936/ pic16f1937/pic16lf1937 pc<14:0> 15 0000h 0004h stack level 0 stack level 15 reset vector interrupt vector call, callw return, retlw stack level 1 0005h on-chip program memory page 0 07ffh rollover to page 0 0800h 0fffh 1000h 7fffh page 1 rollover to page 1 interrupt, retfie pc<14:0> 15 0000h 0004h stack level 0 stack level 15 reset vector interrupt vector stack level 1 0005h on-chip program memory page 0 07ffh rollover to page 0 0800h 0fffh 1000h 7fffh page 1 rollover to page 3 page 2 page 3 17ffh 1800h 1fffh 2000h call, callw return, retlw interrupt, retfie
? 2009 microchip technology inc. preliminary ds41364c-page 25 pic16f193x/lf193x figure 2-3: program memory map and stack for the pic16f1938/pic16lf1938/ pic16f1939/pic16lf1939 2.1.1 reading program memory as data there are two methods of accessing constants in pro- gram memory. the first method is to use tables of retlw instructions. the second method is to set an fsr to point to the program memory. 2.1.1.1 retlw instruction the retlw instruction can be used to provide access to tables of constants. the recommended way to create such a table is shown in example 2-1. example 2-1: retlw instruction the brw instruction makes this type of table very sim- ple to implement. if your code must remain portable with previous generations of microcontrollers, then the brw instruction is not available so the older table read method must be used. 2.1.1.2 indirect read with fsr the program memory can be accessed as data by set- ting bit 7 of the fsrxh register and reading the match- ing indfx register. the moviw instruction will place the lower 8 bits of the addressed word in the w register. writes to the program memory cannot be performed via the indf registers. instructions that access the pro- gram memory via the fsr require one extra instruction cycle to complete. example 2-2 demonstrates access- ing the program memory via an fsr. example 2-2: accessing program memory via fsr pc<14:0> 15 0000h 0004h stack level 0 stack level 15 reset vector interrupt vector stack level 1 0005h on-chip program memory page 0 07ffh rollover to page 0 0800h 0fffh 1000h 7fffh page 1 rollover to page 7 page 2 page 3 17ffh 1800h 1fffh 2000h page 4 page 7 3fffh 4000h call, callw return, retlw interrupt, retfie constants brw retlw data1 retlw data2 retlw data3 retlw data4 my_function ;? lots of code? movlw data_index call constants ;? the constant is in w bsf fsr1h,7 moviw 0[indf1] ;the program memory is in w
pic16f193x/lf193x ds41364c-page 26 preliminary ? 2009 microchip technology inc. 2.2 data memory organization the data memory is partitioned in up to 32 memory banks with up to 128 bytes in a bank. each bank consists of 12 core registers, 20 special function registers (sfr), 16 common registers, and up to 80 bytes of general purpose registers (gpr). the active bank is selected by writing the bank number into the bank select register (bsr). unimplemented memory will read as ? 0 ?. all banks contain the core sfrs and common registers. unimplemented sfrs or gprs will read as ? 0 ?. all data memory can be accessed either directly (via instructions that use the file registers) or indirectly via the two file select registers (fsr). see section 2.5 ?indirect addressing, indf and fsr registers? for more information. 2.2.1 general purpose register file the general purpose register file is an 8-bit ram memory for use by your application. there are up to 80 bytes of gpr in each data memory bank. 2.2.2 special function register the special function registers are registers used by the application to control the desired operation of peripheral functions in the device. the special function registers can be classified into two sets: core and peripheral. the special function registers associated with the ?core? are described in the following sections. the registers associated with the operation of the peripherals are described in the appropriate peripheral chapter of this data sheet.
pic16f193x/lf193x ds41364c-page 27 preliminary ? 2009 microchip technology inc. table 2-2: pic16f1933/1934 memory map, banks 0-7 legend: = unimplemented data memory locations, read as ? 0 ?. note 1: not available on pic16f1933/1936/1938/pic16lf1933/1936/1938. bank 0 bank 1 bank 2 bank 3 bank 4 bank 5 bank 6 bank 7 000h indf0 080h indf0 100h indf0 180h indf0 200h indf0 280h indf0 300h indf0 380h indf0 001h indf1 081h indf1 101h indf1 181h indf1 201h indf1 281h indf1 301h indf1 381h indf1 002h pcl 082h pcl 102h pcl 182h pcl 202h pcl 282h pcl 302h pcl 382h pcl 003h status 083h status 103h status 183h status 203h status 283h status 303h status 383h status 004h fsr0l 084h fsr0l 104h fsr0l 184h fsr0l 204h fsr0l 284h fsr0l 304h fsr0l 384h fsr0l 005h fsr0h 085h fsr0h 105h fsr0h 185h fsr0h 205h fsr0h 285h fsr0h 305h fsr0h 385h fsr0h 006h fsr1l 086h fsr1l 106h fsr1l 186h fsr1l 206h fsr1l 286h fsr1l 306h fsr1l 386h fsr1l 007h fsr1h 087h fsr1h 107h fsr1h 187h fsr1h 207h fsr1h 287h fsr1h 307h fsr1h 387h fsr1h 008h bsr 088h bsr 108h bsr 188h bsr 208h bsr 288h bsr 308h bsr 388h bsr 009h wreg 089h wreg 109h wreg 189h wreg 209h wreg 289h wreg 309h wreg 389h wreg 00ah pclath 08ah pclath 10ah pclath 18ah pclath 20ah pclath 28ah pclath 30ah pclath 38ah pclath 00bh intcon 08bh intcon 10bh intcon 18bh intcon 20bh intcon 28bh intcon 30bh intcon 38bh intcon 00ch porta 08ch trisa 10ch lata 18ch ansela 20ch ? 28ch ? 30ch ? 38ch ? 00dh portb 08dh trisb 10dh latb 18dh anselb 20dh wpub 28dh ? 30dh ? 38dh ? 00eh portc 08eh trisc 10eh latc 18eh ?20eh ?28eh ?30eh ?38eh ? 00fh portd (1) 08fh trisd (1) 10fh latd (1) 18fh anseld (1) 20fh ?28fh ?30fh ?38fh ? 010h porte 090h trise 110h late (1) 190h ansele (1) 210h wpue 290h ? 310h ? 390h ? 011h pir1 091h pie1 111h cm1con0 191h eeadrl 211h sspbuf 291h ccpr1l 311h ccpr3l 391h ? 012h pir2 092h pie2 112h cm1con1 192h eeadrh 212h sspadd 292h ccpr1h 312h ccpr3h 392h ? 013h pir3 093h pie3 113h cm2con0 193h eedatl 213h sspmsk 293h ccp1con 313h ccp3con 393h ? 014h ?094h ? 114h cm2con1 194h eedath 214h sspstat 294h pwm1con 314h pwm3con 394h iocbp 015h tmr0 095h option 115h cmout 195h eecon1 215h sspcon1 295h ccp1as 315h ccp3as 395h iocbn 016h tmr1l 096h pcon 116h borcon 196h eecon2 216h sspcon2 296h pstr1con 316h pstr3con 396h iocbf 017h tmr1h 097h wdtcon 117h fvrcon 197h ? 217h sspcon3 297h ? 317h ? 397h ? 018h t1con 098h osctune 118h daccon0 198h ?218h ? 298h ccpr2l 318h ccpr4l 398h ? 019h t1gcon 099h osccon 119h daccon1 199h rcreg 219h ? 299h ccpr2h 319h ccpr4h 399h ? 01ah tmr2 09ah oscstat 11ah srcon0 19ah txreg 21ah ? 29ah ccp2con 31ah ccp4con 39ah ? 01bh pr2 09bh adresl 11bh srcon1 19bh spbrgl 21bh ? 29bh pwm2con 31bh ?39bh ? 01ch t2con 09ch adresh 11ch ? 19ch spbrgh 21ch ? 29ch ccp2as 31ch ccpr5l 39ch ? 01dh ? 09dh adcon0 11dh apfcon 19dh rcsta 21dh ? 29dh pstr2con 31dh ccpr5h 39dh ? 01eh cpscon0 09eh adcon1 11eh ? 19eh txsta 21eh ? 29eh ccptmrs0 31eh ccp5con 39eh ? 01fh cpscon1 09fh ?11fh ? 19fh baudctr 21fh ? 29fh ccptmrs1 31fh ?39fh ? 020h general purpose register 96 bytes 0a0h general purpose register 80 bytes 120h general purpose register 80 bytes 1a0h unimplemented read as ? 0 ? 220h unimplemented read as ? 0 ? 2a0h unimplemented read as ? 0 ? 320h unimplemented read as ? 0 ? 3a0h unimplemented read as ? 0 ? 06fh 0efh 16fh 1efh 26fh 2efh 36fh 3efh 070h 0f0h accesses 70h ? 7fh 170h accesses 70h ? 7fh 1f0h accesses 70h ? 7fh 270h accesses 70h ? 7fh 2f0h accesses 70h ? 7fh 370h accesses 70h ? 7fh 3f0h accesses 70h ? 7fh 07fh 0ffh 17fh 1ffh 27fh 2ffh 37fh 3ffh
pic16f193x/lf193x ds41364c-page 28 preliminary ? 2009 microchip technology inc. table 2-3: pic16f1933/1934 memory map, banks 8-15 legend: = unimplemented data memory locations, read as ? 0 ?. bank 8 bank 9 bank 10 bank 11 bank 12 bank 13 bank 14 bank 15 400h indf0 480h indf0 500h indf0 580h indf0 600h indf0 680h indf0 700h indf0 780h indf0 401h indf1 481h indf1 501h indf1 581h indf1 601h indf1 681h indf1 701h indf1 781h indf1 402h pcl 482h pcl 502h pcl 582h pcl 602h pcl 682h pcl 702h pcl 782h pcl 403h status 483h status 503h status 583h status 603h status 683h status 703h status 783h status 404h fsr0l 484h fsr0l 504h fsr0l 584h fsr0l 604h fsr0l 684h fsr0l 704h fsr0l 784h fsr0l 405h fsr0h 485h fsr0h 505h fsr0h 585h fsr0h 605h fsr0h 685h fsr0h 705h fsr0h 785h fsr0h 406h fsr1l 486h fsr1l 506h fsr1l 586h fsr1l 606h fsr1l 686h fsr1l 706h fsr1l 786h fsr1l 407h fsr1h 487h fsr1h 507h fsr1h 587h fsr1h 607h fsr1h 687h fsr1h 707h fsr1h 787h fsr1h 408h bsr 488h bsr 508h bsr 588h bsr 608h bsr 688h bsr 708h bsr 788h bsr 409h wreg 489h wreg 509h wreg 589h wreg 609h wreg 689h wreg 709h wreg 789h wreg 40ah pclath 48ah pclath 50ah pclath 58ah pclath 60ah pclath 68ah pclath 70ah pclath 78ah pclath 40bh intcon 48bh intcon 50bh intcon 58bh intcon 60bh intcon 68bh intcon 70bh intcon 78bh intcon 40ch ? 48ch ? 50ch ? 58ch ? 60ch ? 68ch ? 70ch ? 78ch ? 40dh ? 48dh ? 50dh ? 58dh ? 60dh ? 68dh ? 70dh ? 78dh ? 40eh ? 48eh ? 50eh ? 58eh ? 60eh ? 68eh ? 70eh ? 78eh ? 40fh ? 48fh ? 50fh ? 58fh ? 60fh ? 68fh ? 70fh ? 78fh ? 410h ? 490h ? 510h ? 590h ? 610h ? 690h ? 710h ? 790h ? 411h ? 491h ? 511h ? 591h ? 611h ? 691h ? 711h ? 791h see table 2-10 or ta b l e 2 - 11 412h ? 492h ? 512h ? 592h ? 612h ? 692h ? 712h ? 792h 413h ? 493h ? 513h ? 593h ? 613h ? 693h ? 713h ? 793h 414h ? 494h ? 514h ? 594h ? 614h ? 694h ? 714h ? 794h 415h tmr4 495h ? 515h ? 595h ? 615h ? 695h ? 715h ? 795h 416h pr4 496h ? 516h ? 596h ? 616h ? 696h ? 716h ? 796h 417h t4con 497h ? 517h ? 597h ? 617h ? 697h ? 717h ? 797h 418h ? 498h ? 518h ? 598h ? 618h ? 698h ? 718h ? 798h 419h ? 499h ? 519h ? 599h ? 619h ? 699h ? 719h ? 799h 41ah ? 49ah ? 51ah ? 59ah ? 61ah ? 69ah ? 71ah ? 79ah 41bh ? 49bh ? 51bh ? 59bh ? 61bh ? 69bh ? 71bh ? 79bh 41ch tmr6 49ch ? 51ch ? 59ch ? 61ch ? 69ch ? 71ch ? 79ch 41dh pr6 49dh ? 51dh ? 59dh ? 61dh ? 69dh ? 71dh ? 79dh 41eh t6con 49eh ? 51eh ? 59eh ? 61eh ? 69eh ? 71eh ? 79eh 41fh ? 49fh ? 51fh ? 59fh ? 61fh ? 69fh ? 71fh ? 79fh 420h unimplemented read as ? 0 ? 4a0h unimplemented read as ? 0 ? 520h unimplemented read as ? 0 ? 5a0h unimplemented read as ? 0 ? 620h unimplemented read as ? 0 ? 6a0h unimplemented read as ? 0 ? 720h unimplemented read as ? 0 ? 7a0h 46fh 4efh 56fh 5efh 66fh 6efh 76fh 7efh 470h accesses 70h ? 7fh 4f0h accesses 70h ? 7fh 570h accesses 70h ? 7fh 5f0h accesses 70h ? 7fh 670h accesses 70h ? 7fh 6f0h accesses 70h ? 7fh 770h accesses 70h ? 7fh 7f0h accesses 70h ? 7fh 47fh 4ffh 57fh 5ffh 67fh 6ffh 77fh 7ffh
pic16f193x/lf193x ds41364c-page 29 preliminary ? 2009 microchip technology inc. table 2-4: pic16f1936/1937 memory map, banks 0-7 legend: = unimplemented data memory locations, read as ? 0 ?. note 1: not available on pic16f1933/1936/1938/pic16lf1933/1936/1938. bank 0 bank 1 bank 2 bank 3 bank 4 bank 5 bank 6 bank 7 000h indf0 080h indf0 100h indf0 180h indf0 200h indf0 280h indf0 300h indf0 380h indf0 001h indf1 081h indf1 101h indf1 181h indf1 201h indf1 281h indf1 301h indf1 381h indf1 002h pcl 082h pcl 102h pcl 182h pcl 202h pcl 282h pcl 302h pcl 382h pcl 003h status 083h status 103h status 183h status 203h status 283h status 303h status 383h status 004h fsr0l 084h fsr0l 104h fsr0l 184h fsr0l 204h fsr0l 284h fsr0l 304h fsr0l 384h fsr0l 005h fsr0h 085h fsr0h 105h fsr0h 185h fsr0h 205h fsr0h 285h fsr0h 305h fsr0h 385h fsr0h 006h fsr1l 086h fsr1l 106h fsr1l 186h fsr1l 206h fsr1l 286h fsr1l 306h fsr1l 386h fsr1l 007h fsr1h 087h fsr1h 107h fsr1h 187h fsr1h 207h fsr1h 287h fsr1h 307h fsr1h 387h fsr1h 008h bsr 088h bsr 108h bsr 188h bsr 208h bsr 288h bsr 308h bsr 388h bsr 009h wreg 089h wreg 109h wreg 189h wreg 209h wreg 289h wreg 309h wreg 389h wreg 00ah pclath 08ah pclath 10ah pclath 18ah pclath 20ah pclath 28ah pclath 30ah pclath 38ah pclath 00bh intcon 08bh intcon 10bh intcon 18bh intcon 20bh intcon 28bh intcon 30bh intcon 38bh intcon 00ch porta 08ch trisa 10ch lata 18ch ansela 20ch ? 28ch ? 30ch ? 38ch ? 00dh portb 08dh trisb 10dh latb 18dh anselb 20dh wpub 28dh ? 30dh ? 38dh ? 00eh portc 08eh trisc 10eh latc 18eh ?20eh ?28eh ?30eh ?38eh ? 00fh portd (1) 08fh trisd (1) 10fh latd (1) 18fh anseld (1) 20fh ?28fh ?30fh ?38fh ? 010h porte 090h trise 110h late (1) 190h ansele (1) 210h wpue 290h ? 310h ? 390h ? 011h pir1 091h pie1 111h cm1con0 191h eeadrl 211h sspbuf 291h ccpr1l 311h ccpr3l 391h ? 012h pir2 092h pie2 112h cm1con1 192h eeadrh 212h sspadd 292h ccpr1h 312h ccpr3h 392h ? 013h pir3 093h pie3 113h cm2con0 193h eedatl 213h sspmsk 293h ccp1con 313h ccp3con 393h ? 014h ?094h ? 114h cm2con1 194h eedath 214h sspstat 294h pwm1con 314h pwm3con 394h iocbp 015h tmr0 095h option 115h cmout 195h eecon1 215h sspcon1 295h ccp1as 315h ccp3as 395h iocbn 016h tmr1l 096h pcon 116h borcon 196h eecon2 216h sspcon2 296h pstr1con 316h pstr3con 396h iocbf 017h tmr1h 097h wdtcon 117h fvrcon 197h ? 217h sspcon3 297h ? 317h ? 397h ? 018h t1con 098h osctune 118h daccon0 198h ?218h ? 298h ccpr2l 318h ccpr4l 398h ? 019h t1gcon 099h osccon 119h daccon1 199h rcreg 219h ? 299h ccpr2h 319h ccpr4h 399h ? 01ah tmr2 09ah oscstat 11ah srcon0 19ah txreg 21ah ? 29ah ccp2con 31ah ccp4con 39ah ? 01bh pr2 09bh adresl 11bh srcon1 19bh spbrgl 21bh ? 29bh pwm2con 31bh ?39bh ? 01ch txcon 09ch adresh 11ch ? 19ch spbrgh 21ch ? 29ch ccp2as 31ch ccpr5l 39ch ? 01dh ? 09dh adcon0 11dh apfcon 19dh rcsta 21dh ? 29dh pstr2con 31dh ccpr5h 39dh ? 01eh cpscon0 09eh adcon1 11eh ? 19eh txsta 21eh ? 29eh ccptmrs0 31eh ccp5con 39eh ? 01fh cpscon1 09fh ?11fh ? 19fh baudcon 21fh ? 29fh ccptmrs1 31fh ?39fh ? 020h general purpose register 96 bytes 0a0h general purpose register 80 bytes 120h general purpose register 80 bytes 1a0h general purpose register 80 bytes 220h general purpose register 80 bytes 2a0h general purpose register 80 bytes 320h general purpose register 16 bytes 3a0h unimplemented read as ? 0 ? 32fh 330h unimplemented read as ? 0 ? 06fh 0efh 16fh 1efh 26fh 2efh 36fh 3efh 070h 0f0h accesses 70h ? 7fh 170h accesses 70h ? 7fh 1f0h accesses 70h ? 7fh 270h accesses 70h ? 7fh 2f0h accesses 70h ? 7fh 370h accesses 70h ? 7fh 3f0h accesses 70h ? 7fh 07fh 0ffh 17fh 1ffh 27fh 2ffh 37fh 3ffh
pic16f193x/lf193x ds41364c-page 30 preliminary ? 2009 microchip technology inc. table 2-5: pic16f1936/1937 memory map, banks 8-15 legend: = unimplemented data memory locations, read as ? 0 ?. bank 8 bank 9 bank 10 bank 11 bank 12 bank 13 bank 14 bank 15 400h indf0 480h indf0 500h indf0 580h indf0 600h indf0 680h indf0 700h indf0 780h indf0 401h indf1 481h indf1 501h indf1 581h indf1 601h indf1 681h indf1 701h indf1 781h indf1 402h pcl 482h pcl 502h pcl 582h pcl 602h pcl 682h pcl 702h pcl 782h pcl 403h status 483h status 503h status 583h status 603h status 683h status 703h status 783h status 404h fsr0l 484h fsr0l 504h fsr0l 584h fsr0l 604h fsr0l 684h fsr0l 704h fsr0l 784h fsr0l 405h fsr0h 485h fsr0h 505h fsr0h 585h fsr0h 605h fsr0h 685h fsr0h 705h fsr0h 785h fsr0h 406h fsr1l 486h fsr1l 506h fsr1l 586h fsr1l 606h fsr1l 686h fsr1l 706h fsr1l 786h fsr1l 407h fsr1h 487h fsr1h 507h fsr1h 587h fsr1h 607h fsr1h 687h fsr1h 707h fsr1h 787h fsr1h 408h bsr 488h bsr 508h bsr 588h bsr 608h bsr 688h bsr 708h bsr 788h bsr 409h wreg 489h wreg 509h wreg 589h wreg 609h wreg 689h wreg 709h wreg 789h wreg 40ah pclath 48ah pclath 50ah pclath 58ah pclath 60ah pclath 68ah pclath 70ah pclath 78ah pclath 40bh intcon 48bh intcon 50bh intcon 58bh intcon 60bh intcon 68bh intcon 70bh intcon 78bh intcon 40ch ? 48ch ? 50ch ? 58ch ? 60ch ? 68ch ? 70ch ? 78ch ? 40dh ? 48dh ? 50dh ? 58dh ? 60dh ? 68dh ? 70dh ? 78dh ? 40eh ? 48eh ? 50eh ? 58eh ? 60eh ? 68eh ? 70eh ? 78eh ? 40fh ? 48fh ? 50fh ? 58fh ? 60fh ? 68fh ? 70fh ? 78fh ? 410h ? 490h ? 510h ? 590h ? 610h ? 690h ? 710h ? 790h ? 411h ? 491h ? 511h ? 591h ? 611h ? 691h ? 711h ? 791h see table 2-10 or ta b l e 2 - 11 412h ? 492h ? 512h ? 592h ? 612h ? 692h ? 712h ? 792h 413h ? 493h ? 513h ? 593h ? 613h ? 693h ? 713h ? 793h 414h ? 494h ? 514h ? 594h ? 614h ? 694h ? 714h ? 794h 415h tmr4 495h ? 515h ? 595h ? 615h ? 695h ? 715h ? 795h 416h pr4 496h ? 516h ? 596h ? 616h ? 696h ? 716h ? 796h 417h t4con 497h ? 517h ? 597h ? 617h ? 697h ? 717h ? 797h 418h ? 498h ? 518h ? 598h ? 618h ? 698h ? 718h ? 798h 419h ? 499h ? 519h ? 599h ? 619h ? 699h ? 719h ? 799h 41ah ? 49ah ? 51ah ? 59ah ? 61ah ? 69ah ? 71ah ? 79ah 41bh ? 49bh ? 51bh ? 59bh ? 61bh ? 69bh ? 71bh ? 79bh 41ch tmr6 49ch ? 51ch ? 59ch ? 61ch ? 69ch ? 71ch ? 79ch 41dh pr6 49dh ? 51dh ? 59dh ? 61dh ? 69dh ? 71dh ? 79dh 41eh t6con 49eh ? 51eh ? 59eh ? 61eh ? 69eh ? 71eh ? 79eh 41fh ? 49fh ? 51fh ? 59fh ? 61fh ? 69fh ? 71fh ? 79fh 420h unimplemented read as ? 0 ? 4a0h unimplemented read as ? 0 ? 520h unimplemented read as ? 0 ? 5a0h unimplemented read as ? 0 ? 620h unimplemented read as ? 0 ? 6a0h unimplemented read as ? 0 ? 720h unimplemented read as ? 0 ? 7a0h 46fh 4efh 56fh 5efh 66fh 6efh 76fh 7efh 470h accesses 70h ? 7fh 4f0h accesses 70h ? 7fh 570h accesses 70h ? 7fh 5f0h accesses 70h ? 7fh 670h accesses 70h ? 7fh 6f0h accesses 70h ? 7fh 770h accesses 70h ? 7fh 7f0h accesses 70h ? 7fh 47fh 4ffh 57fh 5ffh 67fh 6ffh 77fh 7ffh
pic16f193x/lf193x ds41364c-page 31 preliminary ? 2009 microchip technology inc. table 2-6: pic16f1938/1939 memory map, banks 0-7 legend: = unimplemented data memory locations, read as ? 0 ?. note 1: not available on pic16f1933/1936/1938/pic16lf1933/1936/1938. bank 0 bank 1 bank 2 bank 3 bank 4 bank 5 bank 6 bank 7 000h indf0 080h indf0 100h indf0 180h indf0 200h indf0 280h indf0 300h indf0 380h indf0 001h indf1 081h indf1 101h indf1 181h indf1 201h indf1 281h indf1 301h indf1 381h indf1 002h pcl 082h pcl 102h pcl 182h pcl 202h pcl 282h pcl 302h pcl 382h pcl 003h status 083h status 103h status 183h status 203h status 283h status 303h status 383h status 004h fsr0l 084h fsr0l 104h fsr0l 184h fsr0l 204h fsr0l 284h fsr0l 304h fsr0l 384h fsr0l 005h fsr0h 085h fsr0h 105h fsr0h 185h fsr0h 205h fsr0h 285h fsr0h 305h fsr0h 385h fsr0h 006h fsr1l 086h fsr1l 106h fsr1l 186h fsr1l 206h fsr1l 286h fsr1l 306h fsr1l 386h fsr1l 007h fsr1h 087h fsr1h 107h fsr1h 187h fsr1h 207h fsr1h 287h fsr1h 307h fsr1h 387h fsr1h 008h bsr 088h bsr 108h bsr 188h bsr 208h bsr 288h bsr 308h bsr 388h bsr 009h wreg 089h wreg 109h wreg 189h wreg 209h wreg 289h wreg 309h wreg 389h wreg 00ah pclath 08ah pclath 10ah pclath 18ah pclath 20ah pclath 28ah pclath 30ah pclath 38ah pclath 00bh intcon 08bh intcon 10bh intcon 18bh intcon 20bh intcon 28bh intcon 30bh intcon 38bh intcon 00ch porta 08ch trisa 10ch lata 18ch ansela 20ch ? 28ch ? 30ch ? 38ch ? 00dh portb 08dh trisb 10dh latb 18dh anselb 20dh wpub 28dh ? 30dh ? 38dh ? 00eh portc 08eh trisc 10eh latc 18eh ?20eh ?28eh ?30eh ?38eh ? 00fh portd (1) 08fh trisd (1) 10fh latd (1) 18fh anseld (1) 20fh ?28fh ?30fh ?38fh ? 010h porte 090h trise 110h late (1) 190h ansele (1) 210h wpue 290h ? 310h ? 390h ? 011h pir1 091h pie1 111h cm1con0 191h eeadrl 211h sspbuf 291h ccpr1l 311h ccpr3l 391h ? 012h pir2 092h pie2 112h cm1con1 192h eeadrh 212h sspadd 292h ccpr1h 312h ccpr3h 392h ? 013h pir3 093h pie3 113h cm2con0 193h eedatl 213h sspmsk 293h ccp1con 313h ccp3con 393h ? 014h ?094h ? 114h cm2con1 194h eedath 214h sspstat 294h pwm1con 314h pwm3con 394h iocbp 015h tmr0 095h option 115h cmout 195h eecon1 215h sspcon1 295h ccp1as 315h ccp3as 395h iocbn 016h tmr1l 096h pcon 116h borcon 196h eecon2 216h sspcon2 296h pstr1con 316h pstr3con 396h iocbf 017h tmr1h 097h wdtcon 117h fvrcon 197h ? 217h sspcon3 297h ? 317h ? 397h ? 018h t1con 098h osctune 118h daccon0 198h ?218h ? 298h ccpr2l 318h ccpr4l 398h ? 019h t1gcon 099h osccon 119h daccon1 199h rc1reg 219h ? 299h ccpr2h 319h ccpr4h 399h ? 01ah tmr2 09ah oscstat 11ah srcon0 19ah tx1reg 21ah ? 29ah ccp2con 31ah ccp4con 39ah ? 01bh pr2 09bh adresl 11bh srcon1 19bh spbrgl1 21bh ? 29bh pwm2con 31bh ?39bh ? 01ch t2con 09ch adresh 11ch ? 19ch spbrgh1 21ch ? 29ch ccp2as 31ch ccpr5l 39ch ? 01dh ? 09dh adcon0 11dh apfcon 19dh rcsta1 21dh ? 29dh pstr2con 31dh ccpr5h 39dh ? 01eh cpscon0 09eh adcon1 11eh ? 19ehtxsta121eh ? 29eh ccptmrs0 31eh ccp5con 39eh ? 01fh cpscon1 09fh ?11fh ? 19fh baudctl1 21fh ? 29fh ccptmrs1 31fh ?39fh ? 020h general purpose register 96 bytes 0a0h general purpose register 80 bytes 120h general purpose register 80 bytes 1a0h general purpose register 80 bytes 220h general purpose register 80 bytes 2a0h general purpose register 80 bytes 320h general purpose register 80 bytes 3a0h general purpose register 80 bytes 32fh 330h 06fh 0efh 16fh 1efh 26fh 2efh 36fh 3efh 070h 0f0h accesses 70h ? 7fh 170h accesses 70h ? 7fh 1f0h accesses 70h ? 7fh 270h accesses 70h ? 7fh 2f0h accesses 70h ? 7fh 370h accesses 70h ? 7fh 3f0h accesses 70h ? 7fh 07fh 0ffh 17fh 1ffh 27fh 2ffh 37fh 3ffh
pic16f193x/lf193x ds41364c-page 32 preliminary ? 2009 microchip technology inc. table 2-7: pic16f1938/1939 memory map, banks 8-15 legend: = unimplemented data memory locations, read as ? 0 ?. bank 8 bank 9 bank 10 bank 11 bank 12 bank 13 bank 14 bank 15 400h indf0 480h indf0 500h indf0 580h indf0 600h indf0 680h indf0 700h indf0 780h indf0 401h indf1 481h indf1 501h indf1 581h indf1 601h indf1 681h indf1 701h indf1 781h indf1 402h pcl 482h pcl 502h pcl 582h pcl 602h pcl 682h pcl 702h pcl 782h pcl 403h status 483h status 503h status 583h status 603h status 683h status 703h status 783h status 404h fsr0l 484h fsr0l 504h fsr0l 584h fsr0l 604h fsr0l 684h fsr0l 704h fsr0l 784h fsr0l 405h fsr0h 485h fsr0h 505h fsr0h 585h fsr0h 605h fsr0h 685h fsr0h 705h fsr0h 785h fsr0h 406h fsr1l 486h fsr1l 506h fsr1l 586h fsr1l 606h fsr1l 686h fsr1l 706h fsr1l 786h fsr1l 407h fsr1h 487h fsr1h 507h fsr1h 587h fsr1h 607h fsr1h 687h fsr1h 707h fsr1h 787h fsr1h 408h bsr 488h bsr 508h bsr 588h bsr 608h bsr 688h bsr 708h bsr 788h bsr 409h wreg 489h wreg 509h wreg 589h wreg 609h wreg 689h wreg 709h wreg 789h wreg 40ah pclath 48ah pclath 50ah pclath 58ah pclath 60ah pclath 68ah pclath 70ah pclath 78ah pclath 40bh intcon 48bh intcon 50bh intcon 58bh intcon 60bh intcon 68bh intcon 70bh intcon 78bh intcon 40ch ? 48ch ? 50ch ? 58ch ? 60ch ? 68ch ? 70ch ? 78ch ? 40dh ? 48dh ? 50dh ? 58dh ? 60dh ? 68dh ? 70dh ? 78dh ? 40eh ? 48eh ? 50eh ? 58eh ? 60eh ? 68eh ? 70eh ? 78eh ? 40fh ? 48fh ? 50fh ? 58fh ? 60fh ? 68fh ? 70fh ? 78fh ? 410h ? 490h ? 510h ? 590h ? 610h ? 690h ? 710h ? 790h ? 411h ? 491h ? 511h ? 591h ? 611h ? 691h ? 711h ? 791h see table 2-10 or ta b l e 2 - 11 412h ? 492h ? 512h ? 592h ? 612h ? 692h ? 712h ? 792h 413h ? 493h ? 513h ? 593h ? 613h ? 693h ? 713h ? 793h 414h ? 494h ? 514h ? 594h ? 614h ? 694h ? 714h ? 794h 415h tmr4 495h ? 515h ? 595h ? 615h ? 695h ? 715h ? 795h 416h pr4 496h ? 516h ? 596h ? 616h ? 696h ? 716h ? 796h 417h t4con 497h ? 517h ? 597h ? 617h ? 697h ? 717h ? 797h 418h ? 498h ? 518h ? 598h ? 618h ? 698h ? 718h ? 798h 419h ? 499h ? 519h ? 599h ? 619h ? 699h ? 719h ? 799h 41ah ? 49ah ? 51ah ? 59ah ? 61ah ? 69ah ? 71ah ? 79ah 41bh ? 49bh ? 51bh ? 59bh ? 61bh ? 69bh ? 71bh ? 79bh 41ch tmr6 49ch ? 51ch ? 59ch ? 61ch ? 69ch ? 71ch ? 79ch 41dh pr6 49dh ? 51dh ? 59dh ? 61dh ? 69dh ? 71dh ? 79dh 41eh t6con 49eh ? 51eh ? 59eh ? 61eh ? 69eh ? 71eh ? 79eh 41fh ? 49fh ? 51fh ? 59fh ? 61fh ? 69fh ? 71fh ? 79fh 420h general purpose register 80 bytes 4a0h general purpose register 80 bytes 520h general purpose register 80 bytes 5a0h general purpose register 80 bytes 620h general purpose register 48 bytes 6a0h unimplemented read as ? 0 ? 720h unimplemented read as ? 0 ? 7a0h unimplemented read as ? 0 ? 46fh 4efh 56fh 5efh 66fh 6efh 76fh 7efh 470h accesses 70h ? 7fh 4f0h accesses 70h ? 7fh 570h accesses 70h ? 7fh 5f0h accesses 70h ? 7fh 670h accesses 70h ? 7fh 6f0h accesses 70h ? 7fh 770h accesses 70h ? 7fh 7f0h accesses 70h ? 7fh 47fh 4ffh 57fh 5ffh 67fh 6ffh 77fh 7ffh
? 2009 microchip technology inc. preliminary ds41364c-page 33 pic16f193x/lf193x table 2-8: pic16f193x/lf193 x memory map, banks 16-23 legend: = unimplemented data memory locations, read as ? 0 ?. bank 16 bank 17 bank 18 bank 19 bank 20 bank 21 bank 22 bank 23 800h indf0 880h indf0 900h indf0 980h indf0 a00h indf0 a80h indf0 b00h indf0 b80h indf0 801h indf1 881h indf1 901h indf1 981h indf1 a01h indf1 a81h indf1 b01h indf1 b81h indf1 802h pcl 882h pcl 902h pcl 982h pcl a02h pcl a82h pcl b02h pcl b82h pcl 803h status 883h status 903h status 983h status a03h status a83h status b03h status b83h status 804h fsr0l 884h fsr0l 904h fsr0l 984h fsr0l a04h fsr0l a84h fsr0l b04h fsr0l b84h fsr0l 805h fsr0h 885h fsr0h 905h fsr0h 985h fsr0h a05h fsr0h a85h fsr0h b05h fsr0h b85h fsr0h 806h fsr1l 886h fsr1l 906h fsr1l 986h fsr1l a06h fsr1l a86h fsr1l b06h fsr1l b86h fsr1l 807h fsr1h 887h fsr1h 907h fsr1h 987h fsr1h a07h fsr1h a87h fsr1h b07h fsr1h b87h fsr1h 808h bsr 888h bsr 908h bsr 988h bsr a08h bsr a88h bsr b08h bsr b88h bsr 809h wreg 889h wreg 909h wreg 989h wreg a09h wreg a89h wreg b09h wreg b89h wreg 80ah pclath 88ah pclath 90ah pclath 98ah pclath a0ah pclath a8ah pclath b0ah pclath b8ah pclath 80bh intcon 88bh intcon 90bh intcon 98bh intcon a0bh intcon a8bh intcon b0bh intcon b8bh intcon 80ch ? 88ch ? 90ch ? 98ch ?a0ch ?a8ch ?b0ch ?b8ch ? 80dh ? 88dh ? 90dh ? 98dh ?a0dh ?a8dh ?b0dh ?b8dh ? 80eh ?88eh ?90eh ?98eh ?a0eh ?a8eh ?b0eh ?b8eh ? 80fh ?88fh ?90fh ?98fh ?a0fh ?a8fh ?b0fh ?b8fh ? 810h ?890h ?910h ?990h ?a10h ?a90h ?b10h ?b90h ? 811h ?891h ?911h ?991h ?a11h ?a91h ?b11h ?b91h ? 812h ?892h ?912h ?992h ?a12h ?a92h ?b12h ?b92h ? 813h ?893h ?913h ?993h ?a13h ?a93h ?b13h ?b93h ? 814h ?894h ?914h ?994h ?a14h ?a94h ?b14h ?b94h ? 815h ?895h ?915h ?995h ?a15h ?a95h ?b15h ?b95h ? 816h ?896h ?916h ?996h ?a16h ?a96h ?b16h ?b96h ? 817h ?897h ?917h ?997h ?a17h ?a97h ?b17h ?b97h ? 818h ?898h ?918h ?998h ?a18h ?a98h ?b18h ?b98h ? 819h ?899h ?919h ?999h ?a19h ?a99h ?b19h ?b99h ? 81ah ?89ah ?91ah ?99ah ?a1ah ?a9ah ?b1ah ?b9ah ? 81bh ?89bh ?91bh ?99bh ?a1bh ?a9bh ?b1bh ?b9bh ? 81ch ? 89ch ? 91ch ? 99ch ?a1ch ?a9ch ?b1ch ?b9ch ? 81dh ? 89dh ? 91dh ? 99dh ?a1dh ?a9dh ?b1dh ?b9dh ? 81eh ?89eh ?91eh ?99eh ?a1eh ?a9eh ?b1eh ?b9eh ? 81fh ?89fh ?91fh ?99fh ?a1fh ?a9fh ?b1fh ?b9fh ? 820h unimplemented read as ? 0 ? 8a0h unimplemented read as ? 0 ? 920h unimplemented read as ? 0 ? 9a0h unimplemented read as ? 0 ? a20h unimplemented read as ? 0 ? aa0h unimplemented read as ? 0 ? b20h unimplemented read as ? 0 ? ba0h unimplemented read as ? 0 ? 86fh 8efh 96fh 9efh a6fh aefh b6fh befh 870h accesses 70h ? 7fh 8f0h accesses 70h ? 7fh 970h accesses 70h ? 7fh 9f0h accesses 70h ? 7fh a70h accesses 70h ? 7fh af0h accesses 70h ? 7fh b70h accesses 70h ? 7fh bf0h accesses 70h ? 7fh 87fh 8ffh 97fh 9ffh a7fh affh b7fh bffh
pic16f193x/lf193x ds41364c-page 34 preliminary ? 2009 microchip technology inc. table 2-9: pic16f193x/lf193 x memory map, banks 24-31 legend: = unimplemented data memory locations, read as ? 0 ?. bank 24 bank 25 bank 26 bank 27 bank 28 bank 29 bank 30 bank 31 c00h indf0 c80h indf0 d00h indf0 d80h indf0 e00h indf0 e80h indf0 f00h indf0 f80h indf0 c01h indf1 c81h indf1 d01h indf1 d81h indf1 e01h indf1 e81h indf1 f01h indf1 f81h indf1 c02h pcl c82h pcl d02h pcl d82h pcl e02h pcl e82h pcl f02h pcl f82h pcl c03h status c83h status d03h status d83h status e03h status e83h status f03h status f83h status c04h fsr0l c84h fsr0l d04h fsr0l d84h fsr0l e04h fsr0l e84h fsr0l f04h fsr0l f84h fsr0l c05h fsr0h c85h fsr0h d05h fsr0h d85h fsr0h e05h fsr0h e85h fsr0h f05h fsr0h f85h fsr0h c06h fsr1l c86h fsr1l d06h fsr1l d86h fsr1l e06h fsr1l e86h fsr1l f06h fsr1l f86h fsr1l c07h fsr1h c87h fsr1h d07h fsr1h d87h fsr1h e07h fsr1h e87h fsr1h f07h fsr1h f87h fsr1h c08h bsr c88h bsr d08h bsr d88h bsr e08h bsr e88h bsr f08h bsr f88h bsr c09h wreg c89h wreg d09h wreg d89h wreg e09h wreg e89h wreg f09h wreg f89h wreg c0ah pclath c8ah pclath d0ah pclath d8ah pclath e0ah pclath e8ah pclath f0ah pclath f8ah pclath c0bh intcon c8bh intcon d0bh intcon d8bh intcon e0bh intcon e8bh intcon f0bh intcon f8bh intcon c0ch ?c8ch ?d0ch ?d8ch ?e0ch ?e8ch ?f0ch ?f8ch see table 2-12 c0dh ?c8dh ?d0dh ?d8dh ?e0dh ?e8dh ?f0dh ?f8dh c0eh ?c8eh ?d0eh ?d8eh ?e0eh ?e8eh ?f0eh ?f8eh c0fh ?c8fh ?d0fh ?d8fh ?e0fh ?e8fh ?f0fh ?f8fh c10h ?c90h ?d10h ?d90h ?e10h ?e90h ?f10h ?f90h c11h ?c91h ?d11h ?d91h ?e11h ?e91h ?f11h ?f91h c12h ?c92h ?d12h ?d92h ?e12h ?e92h ?f12h ?f92h c13h ?c93h ?d13h ?d93h ?e13h ?e93h ?f13h ?f93h c14h ?c94h ?d14h ?d94h ?e14h ?e94h ?f14h ?f94h c15h ?c95h ?d15h ?d95h ?e15h ?e95h ?f15h ?f95h c16h ?c96h ?d16h ?d96h ?e16h ?e96h ?f16h ?f96h c17h ?c97h ?d17h ?d97h ?e17h ?e97h ?f17h ?f97h c18h ?c98h ?d18h ?d98h ?e18h ?e98h ?f18h ?f98h c19h ?c99h ?d19h ?d99h ?e19h ?e99h ?f19h ?f99h c1ah ?c9ah ?d1ah ?d9ah ?e1ah ?e9ah ?f1ah ?f9ah c1bh ?c9bh ?d1bh ?d9bh ?e1bh ?e9bh ?f1bh ?f9bh c1ch ?c9ch ?d1ch ?d9ch ?e1ch ?e9ch ?f1ch ?f9ch c1dh ?c9dh ?d1dh ?d9dh ?e1dh ?e9dh ?f1dh ?f9dh c1eh ?c9eh ?d1eh ?d9eh ?e1eh ?e9eh ?f1eh ?f9eh c1fh ?c9fh ?d1fh ?d9fh ?e1fh ?e9fh ?f1fh ?f9fh c20h unimplemented read as ? 0 ? ca0h unimplemented read as ? 0 ? d20h unimplemented read as ? 0 ? da0h unimplemented read as ? 0 ? e20h unimplemented read as ? 0 ? ea0h unimplemented read as ? 0 ? f20h unimplemented read as ? 0 ? fa0h c6fh cefh d6fh defh e6fh eefh f6fh fefh c70h accesses 70h ? 7fh cf0h accesses 70h ? 7fh d70h accesses 70h ? 7fh df0h accesses 70h ? 7fh e70h accesses 70h ? 7fh ef0h accesses 70h ? 7fh f70h accesses 70h ? 7fh ff0h accesses 70h ? 7fh cffh cffh d7fh dffh e7fh effh f7fh fffh
? 2009 microchip technology inc. preliminary ds41364c-page 35 pic16f193x/lf193x table 2-10: pic16f1933/1936/1938 memory map, bank 15 table 2-11: pic16f1934/1937/1939 memory map, bank 15 legend: = unimplemented data memory locations, read as ? 0 ?. bank 15 791h lcdcon 792h lcdps 793h lcdref 794h lcdcst 795h lcdrl 796h ? 797h ? 798h lcdse0 799h lcdse1 79ah ? 79bh ? 79ch ? 79dh ? 79eh ? 79fh ? 7a0h lcddata0 7a1h lcddata1 7a2h ? 7a3h lcddata3 7a4h lcddata4 7a5h ? 7a6h lcddata6 7a7h lcddata7 7a8h ? 7a9h lcddata9 7aah lcddata10 7abh ? 7ach ? 7adh ? 7aeh ? 7afh ? 7b0h ? 7b1h ? 7b2h ? 7b3h ? 7b4h ? 7b5h ? 7b6h ? 7b7h ? 7b8h unimplemented read as ? 0 ? 7efh legend: = unimplemented data memory locations, read as ? 0 ?. bank 15 791h lcdcon 792h lcdps 793h lcdref 794h lcdcst 795h lcdrl 796h ? 797h ? 798h lcdse0 799h lcdse1 79ah lcdse2 79bh ? 79ch ? 79dh ? 79eh ? 79fh ? 7a0h lcddata0 7a1h lcddata1 7a2h lcddata2 7a3h lcddata3 7a4h lcddata4 7a5h lcddata5 7a6h lcddata6 7a7h lcddata7 7a8h lcddata8 7a9h lcddata9 7aah lcddata10 7abh lcddata11 7ach ? 7adh ? 7aeh ? 7afh ? 7b0h ? 7b1h ? 7b2h ? 7b3h ? 7b4h ? 7b5h ? 7b6h ? 7b7h ? 7b8h unimplemented read as ? 0 ? 7efh
pic16f193x/lf193x ds41364c-page 36 preliminary ? 2009 microchip technology inc. table 2-12: pic16f193x/lf193x memory map, bank 31 legend: = unimplemented data memory locations, read as ? 0 ?. bank 31 f8ch unimplemented read as ? 0 ? fe3h fe4h status_shad fe5h wreg_shad fe6h bsr_shad fe7h pclath_shad fe8h fsr0l_shad fe9h fsr0h_shad feah fsr1l_shad febh fsr1h_shad fech ? fedh stkptr feeh tosl fefh tosh
? 2009 microchip technology inc. preliminary ds41364c-page 37 pic16f193x/lf193x table 2-13: special fu nction register summary address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets bank 0 000h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 001h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 002h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 003h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu 004h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu 005h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 006h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu 007h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 008h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 009h (2) wreg working register 0000 0000 uuuu uuuu 00ah (1, 2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 00bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u 00ch porta porta data latch when written: porta pins when read xxxx xxxx uuuu uuuu 00dh portb portb data latch when written: portb pins when read xxxx xxxx uuuu uuuu 00eh portc portc data latch when written: portc pins when read xxxx xxxx uuuu uuuu 00fh (3) portd portd data latch when written: portd pins when read xxxx xxxx uuuu uuuu 010h porte ? ? ? ?re3re2 (3) re1 (3) re0 (3) ---- xxxx ---- uuuu 011h pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 0000 0000 0000 0000 012h pir2 osfif c2if c1if eeif bclif lcdif ? ccp2if 0000 00-0 0000 00-0 013h pir3 ? ccp5if ccp4if ccp3if tmr6if ?tmr4if ? -000 0-0- -000 0-0- 014h pir4 unimplemented ? ? 015h tmr0 timer0 module register xxxx xxxx uuuu uuuu 016h tmr1l holding register for the least significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu 017h tmr1h holding register for the most significant byte of the 16-bit tmr1 register xxxx xxxx uuuu uuuu 018h t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on 0000 00-0 uuuu uu-u 019h t1gcon tmr1ge t1gpol t1gtm t1gspm t1ggo/ done t1gval t1gss1 t1gss0 0000 0x00 uuuu uxuu 01ah tmr2 timer 2 module register 0000 0000 0000 0000 01bh pr2 timer 2 period register 1111 1111 1111 1111 01ch t2con ? t2outps3 t2outps2 t2outps1 t2outps0 tmr2on t2ckps1 t2ckps0 -000 0000 -000 0000 01dh ? unimplemented ? ? 01eh cpscon0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs 0--- 0000 0--- 0000 01fh cpscon1 ? ? ? ? cpsch3 cpsch2 cpsch1 cpsch0 ---- 0000 ---- 0000 legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
pic16f193x/lf193x ds41364c-page 38 preliminary ? 2009 microchip technology inc. bank 1 080h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 081h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 082h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 083h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu 084h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu 085h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 086h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu 087h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 088h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 089h (2) wreg working register 0000 0000 uuuu uuuu 08ah (1, 2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 08bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u 08ch trisa porta data direction register 1111 1111 1111 1111 08dh trisb portb data direction register 1111 1111 1111 1111 08eh trisc portc data direction register 1111 1111 1111 1111 08fh (3) trisd portd data direction register 1111 1111 1111 1111 090h trise ? ? ? ? trise3 trise2 (3) trise1 (3) trise0 (3) ---- 1111 ---- 1111 091h pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 0000 0000 0000 0000 092h pie2 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie 0000 00-0 0000 00-0 093h pie3 ? ccp5ie ccp4ie ccp3ie tmr6ie ?tmr4ie ? -000 0-0- -000 0-0- 094h ? unimplemented ? ? 095h option_reg wpuen intedg t0cs t0se psa ps2 ps1 ps0 1111 1111 1111 1111 096h pcon stkovf stkunf ? ?rmclr ri por bor 00-- 11qq qq-- qquu 097h wdtcon ? ? wdtps4 wdtps3 wdtps2 wdtps1 wdtps0 swdten --01 0110 --01 0110 098h osctune ? ? tun5 tun4 tun3 tun2 tun1 tun0 --00 0000 --00 0000 099h osccon spllen ircf3 ircf2 ircf1 ircf0 ? scs1 scs0 0011 1-00 0011 1-00 09ah oscstat t1oscr pllr osts hfiofr hfiofl mfiofr lfiofr hfiofr 00q0 0q0- qqqq qq0- 09bh adresl a/d result register low xxxx xxxx uuuu uuuu 09ch adresh a/d result register high xxxx xxxx uuuu uuuu 09dh adcon0 ? chs4 chs3 chs2 chs1 chs0 go/done adon -000 0000 -000 0000 09eh adcon1 adfm adcs2 adcs1 adcs0 ? adnref adpref1 adpref0 0000 -000 0000 -000 09fh ? unimplemented ? ? table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 39 pic16f193x/lf193x bank 2 100h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 101h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 102h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 103h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu 104h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu 105h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 106h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu 107h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 108h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 109h (2) wreg working register 0000 0000 uuuu uuuu 10ah (1, 2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 10bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u 10ch lata porta data latch xxxx xxxx uuuu uuuu 10dh latb portb data latch xxxx xxxx uuuu uuuu 10eh latc portc data latch xxxx xxxx uuuu uuuu 10fh (3) latd portd data latch xxxx xxxx uuuu uuuu 110h late ? ? ? ? late3 late2 (3) late1 (3) late0 (3) ---- -xxx ---- -uuu 111h cm1con0 c1on c1out c1oe c1pol ? c1sp c1hys c1sync 0000 -100 0000 -100 112h cm1con1 c1intp c1intn c1pch1 c1pch0 ? ? c1nch1 c1nch0 0000 --00 0000 --00 113h cm2con0 c2on c2out c2oe c2pol ? c2sp c2hys c2sync 0000 -100 0000 -100 114h cm2con1 c2intp c2intn c2pch1 c2pch0 ? ? c2nch1 c2nch0 0000 --00 0000 --00 115h cmout ? ? ? ? ? ? mc2out mc1out ---- --00 ---- --00 116h borcon sboren ? ? ? ? ? ? borrdy 1--- ---q u--- ---u 117h fvrcon fvren fvrrdy tsen tsrng cdafvr1 cdafvr0 adfvr1 adfvr0 0q00 0000 0q00 0000 118h daccon0 dacen daclps dacoe --- dacpss1 dacpss0 --- dacnss 000- 00-0 000- 00-0 119h daccon1 --- --- --- dacr4 dacr3 dacr2 dacr1 dacr0 ---0 0000 ---0 0000 11ah srcon0 srlen srclk2 srclk1 srclk0 srqen srnqen srps srpr 0000 0000 0000 0000 11bh srcon1 srspe srscke srsc2e srsc1e srrpe srrcke srrc2e srrc1e 0000 0000 0000 0000 11ch ? unimplemented ? ? 11dh apfcon ? ccp3sel t1gsel p2bsel srnqsel c2outsel sssel ccp2sel -000 0000 -000 0000 11eh ? unimplemented ? ? 11fh ? unimplemented ? ? table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
pic16f193x/lf193x ds41364c-page 40 preliminary ? 2009 microchip technology inc. bank 3 180h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 181h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 182h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 183h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu 184h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu 185h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 186h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu 187h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 188h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 189h (2) wreg working register 0000 0000 uuuu uuuu 18ah (1, 2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 18bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u 18ch ansela ? ? ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 --11 1111 --11 1111 18dh anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 --11 1111 --11 1111 18eh ? unimplemented ? ? 18fh (3) anseld ansd7 ansd6 ansd5 ansd4 ansd3 ansd2 ansd1 ansd0 1111 1111 1111 1111 190h (3) ansele ? ? ? ? ? anse2 anse1 anse0 ---- -111 ---- -111 191h eeadrl eeprom / program memory address register low byte 0000 0000 0000 0000 192h eeadrh ? eeprom / program memory address register high byte -000 0000 -000 0000 193h eedatl eeprom / program memory read data register low byte xxxx xxxx uuuu uuuu 194h eedath ? ? eeprom / program memory read data register high byte --xx xxxx --uu uuuu 195h eecon1 eepgd cfgs lwlo free wrerr wren wr rd 0000 x000 0000 q000 196h eecon2 eeprom control register 2 0000 0000 0000 0000 197h ? unimplemented ? ? 198h ? unimplemented ? ? 199h rcreg usart receive data register 0000 0000 0000 0000 19ah txreg usart transmit data register 0000 0000 0000 0000 19bh spbrgl brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 0000 0000 0000 0000 19ch spbrgh brg15 brg14 brg13 brg12 brg11 brg10 brg9 brg8 0000 0000 0000 0000 19dh rcsta spen rx9 sren cren adden ferr oerr rx9d 0000 000x 0000 000x 19eh txsta csrc tx9 txen sync sendb brgh trmt tx9d 0000 0010 0000 0010 19fh baudcon abdovf rcidl ? sckp brg16 ? wue abden 01-0 0-00 01-0 0-00 table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 41 pic16f193x/lf193x bank 4 200h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 201h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 202h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 203h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu 204h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu 205h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 206h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu 207h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 208h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 209h (2) wreg working register 0000 0000 uuuu uuuu 20ah (1, 2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 20bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u 20ch ? unimplemented ? ? 20dh wpub wpub7 wpub6 wpub5 wpub4 wpub3 wpub2 wpub1 wpub0 1111 1111 1111 1111 20eh ? unimplemented ? ? 20fh ? unimplemented ? ? 210h wpue ? ? ? ? wpue3 ? ? ? ---- 1--- ---- 1--- 211h sspbuf synchronous serial port receive buffer/transmit register xxxx xxxx uuuu uuuu 212h sspadd add7 add6 add5 add4 add3 add2 add1 add0 0000 0000 0000 0000 213h sspmsk msk7 msk6 msk5 msk4 msk3 msk2 msk1 msk0 1111 1111 1111 1111 214h sspstat smp cke d/a psr/w ua bf 0000 0000 0000 0000 215h sspcon1 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 216h sspcon2 gcen ackstat ackdt acken rcen pen rsen sen 0000 0000 0000 0000 217h sspcon3 acktim pcie scie boen sdaht sbcde ahen dhen 0000 0000 0000 0000 218h ? unimplemented ? ? 219h ? unimplemented ? ? 21ah ? unimplemented ? ? 21bh ? unimplemented ? ? 21ch ? unimplemented ? ? 21dh ? unimplemented ? ? 21eh ? unimplemented ? ? 21fh ? unimplemented ? ? table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
pic16f193x/lf193x ds41364c-page 42 preliminary ? 2009 microchip technology inc. bank 5 280h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 281h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 282h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 283h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu 284h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu 285h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 286h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu 287h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 288h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 289h (2) wreg working register 0000 0000 uuuu uuuu 28ah (1, 2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 28bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u 28ch ? unimplemented ? ? 28dh ? unimplemented ? ? 28eh ? unimplemented ? ? 28fh ? unimplemented ? ? 290h ? unimplemented ? ? 291h ccpr1l capture/compare/pwm register 1 (lsb) xxxx xxxx uuuu uuuu 292h ccpr1h capture/compare/pwm register 1 (msb) xxxx xxxx uuuu uuuu 293h ccp1con p1m1 p1m0 dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 0000 0000 0000 0000 294h pwm1con p1rsen p1dc6 p1dc5 p1dc4 p1dc3 p1dc2 p1dc1 p1dc0 0000 0000 0000 0000 295h ccp1as ccp1ase ccp1as2 ccp1as1 ccp1as0 pss1ac1 pss1ac0 pss1bd1 pss1bd0 0000 0000 0000 0000 296h pstr1con ? ? ? str1sync str1d str1c str1b str1a ---0 0001 ---0 0001 297h ? unimplemented ? ? 298h ccpr2l capture/compare/pwm register 2 (lsb) xxxx xxxx uuuu uuuu 299h ccpr2h capture/compare/pwm register 2 (msb) xxxx xxxx uuuu uuuu 29ah ccp2con p2m1 p2m0 dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 0000 0000 0000 0000 29bh pwm2con p2rsen p2dc6 p2dc5 p2dc4 p2dc3 p2dc2 p2dc1 p2dc0 0000 0000 0000 0000 29ch ccp2as ccp2ase ccp2as2 ccp2as1 ccp2as0 pss2ac1 pss2ac0 pss2bd1 pss2bd0 0000 0000 0000 0000 29dh pstr2con ? ? ? str2sync str2d str2c str2b str2a ---0 0001 ---0 0001 29eh ccptmrs0 c4tsel1 c4tsel0 c3tsel1 c3tsel0 c2tsel1 c2tsel0 c1tsel1 c1tsel0 0000 0000 0000 0000 29fh ccptmrs1 ? ? ? ? ? ? c5tsel1 c5tsel0 ---- --00 ---- --00 table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 43 pic16f193x/lf193x bank 6 300h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 301h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 302h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 303h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu 304h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu 305h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 306h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu 307h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 308h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 309h (2) wreg working register 0000 0000 uuuu uuuu 30ah (1, 2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 30bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u 30ch ? unimplemented ? ? 30dh ? unimplemented ? ? 30eh ? unimplemented ? ? 30fh ? unimplemented ? ? 310h ? unimplemented ? ? 311h ccpr3l capture/compare/pwm register 3 (lsb) xxxx xxxx uuuu uuuu 312h ccpr3h capture/compare/pwm register 3 (msb) xxxx xxxx uuuu uuuu 313h ccp3con p3m1 p3m0 dc3b1 dc3b0 ccp3m3 ccp3m2 ccp3m1 ccp3m0 0000 0000 0000 0000 314h pwm3con p3rsen p3dc6 p3dc5 p3dc4 p3dc3 p3dc2 p3dc1 p3dc0 0000 0000 0000 0000 315h ccp3as ccp3ase ccp3as2 ccp3as1 ccp3as0 pss3ac1 pss3ac0 pss3bd1 pss3bd0 0000 0000 0000 0000 316h pstr3con ? ? ? str3sync str3d str3c str3b str3a ---0 0001 ---0 0001 317h ? unimplemented ? ? 318h ccpr4l capture/compare/pwm register 4 (lsb) xxxx xxxx uuuu uuuu 319h ccpr4h capture/compare/pwm register 4 (msb) xxxx xxxx uuuu uuuu 31ah ccp4con ? ? dc4b1 dc4b0 ccp4m3 ccp4m2 ccp4m1 ccp4m0 --00 0000 --00 0000 31bh ? unimplemented ? ? 31ch ccpr5l capture/compare/pwm register 5 (lsb) xxxx xxxx uuuu uuuu 31dh ccpr5h capture/compare/pwm register 5 (msb) xxxx xxxx uuuu uuuu 31eh ccp5con ? ? dc5b1 dc5b0 ccp5m3 ccp5m2 ccp5m1 ccp5m0 --00 0000 --00 0000 31fh ? unimplemented ? ? table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
pic16f193x/lf193x ds41364c-page 44 preliminary ? 2009 microchip technology inc. bank 7 380h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 381h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 382h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 383h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu 384h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu 385h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 386h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu 387h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 388h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 389h (2) wreg working register 0000 0000 uuuu uuuu 38ah (1, 2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 38bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u 38ch ? unimplemented ? ? 38dh ? unimplemented ? ? 38eh ? unimplemented ? ? 38fh ? unimplemented ? ? 390h ? unimplemented ? ? 391h ? unimplemented ? ? 392h ? unimplemented ? ? 393h ? unimplemented ? ? 394h iocbp iocbp7 iocbp6 iocbp5 iocbp4 iocbp3 iocbp2 iocbp1 iocbp0 0000 0000 0000 0000 395h iocbn iocbn7 iocbn6 iocbn5 iocbn4 iocbn3 iocbn2 iocbn1 iocbn0 0000 0000 0000 0000 396h iocbf iocbf7 iocbf6 iocbf5 iocbf4 iocbf3 iocbf2 iocbf1 iocbf0 0000 0000 0000 0000 397h ? unimplemented ? ? 398h ? unimplemented ? ? 399h ? unimplemented ? ? 39ah ? unimplemented ? ? 39bh ? unimplemented ? ? 39ch ? unimplemented ? ? 39dh ? unimplemented ? ? 39eh ? unimplemented ? ? 39fh ? unimplemented ? ? table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 45 pic16f193x/lf193x bank 8 400h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 401h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 402h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 403h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu 404h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu 405h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 406h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu 407h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 408h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 409h (2) wreg working register 0000 0000 uuuu uuuu 40ah (1, 2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 40bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u 40ch ? unimplemented ? ? 40dh ? unimplemented ? ? 40eh ? unimplemented ? ? 40fh ? unimplemented ? ? 410h ? unimplemented ? ? 411h ? unimplemented ? ? 412h ? unimplemented ? ? 413h ? unimplemented ? ? 414h ? unimplemented ? ? 415h tmr4 timer 4 module register 0000 0000 0000 0000 416h pr4 timer 4 period register 1111 1111 1111 1111 417h t4con ? t4outps3 t4outps2 t4outps1 t4outps0 tmr4on t4ckps1 t4ckps0 -000 0000 -000 0000 418h ? unimplemented ? ? 419h ? unimplemented ? ? 41ah ? unimplemented ? ? 41bh ? unimplemented ? ? 41ch tmr6 timer 6 module register 0000 0000 0000 0000 41dh pr6 timer 6 period register 1111 1111 1111 1111 41eh t6con ? t6outps3 t6outps2 t6outps1 t6outps0 tmr6on t6ckps1 t6ckps0 -000 0000 -000 0000 41fh ? unimplemented ? ? table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
pic16f193x/lf193x ds41364c-page 46 preliminary ? 2009 microchip technology inc. banks 9-14 x00h/ x80h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx x00h/ x81h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx x02h/ x82h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 x03h/ x83h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu x04h/ x84h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu x05h/ x85h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 x06h/ x86h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu x07h/ x87h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 x08h/ x88h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 x09h/ x89h (2) wreg working register 0000 0000 uuuu uuuu x0ah/ x8ah (1),(2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 x0bh/ x8bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u x0ch/ x8ch ? x1fh/ x9fh ? unimplemented ? ? table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 47 pic16f193x/lf193x bank 15 780h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 781h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx 782h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 783h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu 784h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu 785h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 786h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu 787h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 788h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 789h (2) wreg working register 0000 0000 uuuu uuuu 78ah (1, 2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 78bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u 78ch ? unimplemented ? ? 78dh ? unimplemented ? ? 78eh ? unimplemented ? ? 78fh ? unimplemented ? ? 790h ? unimplemented ? ? 791h lcdcon lcden slpen werr ? cs1 cs0 lmux1 lmux0 000- 0011 000- 0011 792h lcdps wft biasmd lcda wa lp3 lp2 lp1 lp0 0000 0000 0000 0000 793h lcdref lcdire lcdirs lcdiri ? vlcd3pe vlcd2pe vlcd1pe ? 000- 000- 000- 000- 794h lcdcst ? ? ? ? ? lcdcst2 lcdcst1 lcdcst0 ---- -000 ---- -000 795h lcdrl lrlap1 lrlap0 lrlbp1 lrlbp0 ? lrlat2 lr lat1 lrlat0 0000 -000 0000 -000 796h ? unimplemented ? ? 797h ? unimplemented ? ? 798h lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 0000 0000 uuuu uuuu 799h lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 0000 0000 uuuu uuuu 79ah lcdse2 (3) se23 se22 se21 se20 se19 se18 se17 se16 0000 0000 uuuu uuuu 79bh ? unimplemented ? ? 79ch ? unimplemented ? ? 79dh ? unimplemented ? ? 79eh ? unimplemented ? ? 79fh ? unimplemented ? ? 7a0h lcddata0 seg7 com0 seg6 com0 seg5 com0 seg4 com0 seg3 com0 seg2 com0 seg1 com0 seg0 com0 xxxx xxxx uuuu uuuu 7a1h lcddata1 seg15 com0 seg14 com0 seg13 com0 seg12 com0 seg11 com0 seg10 com0 seg9 com0 seg8 com0 xxxx xxxx uuuu uuuu 7a2h lcddata2 (3) seg23 com0 seg22 com0 seg21 com0 seg20 com0 seg19 com0 seg18 com0 seg17 com0 seg16 com0 xxxx xxxx uuuu uuuu 7a3h lcddata3 seg7 com1 seg6 com1 seg5 com1 seg4 com1 seg3 com1 seg2 com1 seg1 com1 seg0 com1 xxxx xxxx uuuu uuuu 7a4h lcddata4 seg15 com1 seg14 com1 seg13 com1 seg12 com1 seg11 com1 seg10 com1 seg9 com1 seg8 com1 xxxx xxxx uuuu uuuu 7a5h lcddata5 (3) seg23 com1 seg22 com1 seg21 com1 seg20 com1 seg19 com1 seg18 com1 seg17 com1 seg16 com1 xxxx xxxx uuuu uuuu table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
pic16f193x/lf193x ds41364c-page 48 preliminary ? 2009 microchip technology inc. bank 15 (continued) 7a6h lcddata6 seg7 com2 seg6 com2 seg5 com2 seg4 com2 seg3 com2 seg2 com2 seg1 com2 seg0 com2 xxxx xxxx uuuu uuuu 7a7h lcddata7 seg15 com2 seg14 com2 seg13 com2 seg12 com2 seg11 com2 seg10 com2 seg9 com2 seg8 com2 xxxx xxxx uuuu uuuu 7a8h lcddata8 (3) seg23 com2 seg22 com2 seg21 com2 seg20 com2 seg19 com2 seg18 com2 seg17 com2 seg16 com2 xxxx xxxx uuuu uuuu 7a9h lcddata9 seg7 com3 seg6 com3 seg5 com3 seg4 com3 seg3 com3 seg2 com3 seg1 com3 seg0 com3 xxxx xxxx uuuu uuuu 7aah lcddata10 seg15 com3 seg14 com3 seg13 com3 seg12 com3 seg11 com3 seg10 com3 seg9 com3 seg8 com3 xxxx xxxx uuuu uuuu 7abh lcddata11 (3) seg23 com3 seg22 com3 seg21 com3 seg20 com3 seg19 com3 seg18 com3 seg17 com3 seg16 com3 xxxx xxxx uuuu uuuu 7ach ? 7efh ? unimplemented ? ? table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 49 pic16f193x/lf193x banks 16-30 x00h/ x80h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx x00h/ x81h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx x02h/ x82h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 x03h/ x83h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu x04h/ x84h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu x05h/ x85h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 x06h/ x86h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu x07h/ x87h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 x08h/ x88h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 x09h/ x89h (2) wreg working register 0000 0000 uuuu uuuu x0ah/ x8ah (1),(2) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 x0bh/ x8bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u x0ch/ x8ch ? x1fh/ x9fh ? unimplemented ? ? table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
pic16f193x/lf193x ds41364c-page 50 preliminary ? 2009 microchip technology inc. bank 31 f80h (2) indf0 addressing this location uses contents of fsr0h/fsr0l to address data memory (not a physical register) xxxx xxxx xxxx xxxx f81h (2) indf1 addressing this location uses contents of fsr1h/fsr1l to address data memory (not a physical register) xxxx xxxx xxxx xxxx f82h (2) pcl program counter (pc) least significant byte 0000 0000 0000 0000 f83h (2) status ? ? ?to pd zdcc ---1 1000 ---q quuu f84h (2) fsr0l indirect data memory address 0 low pointer 0000 0000 uuuu uuuu f85h (2) fsr0h indirect data memory address 0 high pointer 0000 0000 0000 0000 f86h (2) fsr1l indirect data memory address 1 low pointer 0000 0000 uuuu uuuu f87h (2) fsr1h indirect data memory address 1 high pointer 0000 0000 0000 0000 f88h (2) bsr ? ? ? bsr4 bsr3 bsr2 bsr1 bsr0 ---0 0000 ---0 0000 f89h (2) wreg working register 0000 0000 uuuu uuuu f8ah (1),(2 ) pclath ? write buffer for the upper 7 bits of the program counter -000 0000 -000 0000 f8bh (2) intcon gie peie tmr0ie inte iocie tmr0if intf iocif 0000 000x 0000 000u f8ch ? fe3h ? unimplemented ? ? fe4h status_ shad zdcc ---- -xxx ---- -uuu fe5h wreg_ shad working register normal (non-icd) shadow xxxx xxxx uuuu uuuu fe6h bsr_ shad bank select register normal (non-icd) shadow ---x xxxx ---u uuuu fe7h pclath_ shad program counter latch high register normal (non-icd) shadow -xxx xxxx uuuu uuuu fe8h fsr0l_ shad indirect data memory address 0 low pointer normal (non-icd) shadow xxxx xxxx uuuu uuuu fe9h fsr0h_ shad indirect data memory address 0 high pointer normal (non-icd) shadow xxxx xxxx uuuu uuuu feah fsr1l_ shad indirect data memory address 1 low pointer normal (non-icd) shadow xxxx xxxx uuuu uuuu febh fsr1h_ shad indirect data memory address 1 high pointer normal (non-icd) shadow xxxx xxxx uuuu uuuu fech ? unimplemented ? ? fedh stkptr ? ? ? current stack pointer ---1 1111 ---1 1111 feeh tosl top of stack low byte xxxx xxxx uuuu uuuu fefh tosh ? top of stack high byte -xxx xxxx -uuu uuuu table 2-13: special function register summary (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on: por, bor value on all other resets legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ? 0 ?, r = reserved. shaded locations are unimplemented, read as ? 0 ?. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for the pc<14:8>, whose contents are transferred to the upper byte of the program counter. 2: these registers can be addressed from any bank. 3: these registers/bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 51 pic16f193x/lf193x 2.2.3 core registers the core registers contain the registers that directly affect the basic operation of the pic16f193x/lf193x. these registers are listed below: ? indf0 ? indf1 ?pcl ?status ?fsr0 low ? fsr0 high ?fsr1 low ? fsr1 high ? bsr ?wreg ?pclath ?intcon note: the core registers are the first 12 addresses of every data memory bank.
pic16f193x/lf193x ds41364c-page 52 preliminary ? 2009 microchip technology inc. 2.2.3.1 status register the status register, shown in register 2-1, contains: ? the arithmetic status of the alu ? the reset status ? the bank select bits for data memory (sram) the status register can be the destination for any instruction, like any other register. if the status register is the destination for an instruction that affects the z, dc or c bits, then the write to these three bits is disabled. these bits are set or cleared according to the device logic. furthermore, the to and pd bits are not writable. therefore, the result of an instruction with the status register as destination may be different than intended. for example, clrf status will clear the upper three bits and set the z bit. this leaves the status register as ? 000u u1uu ? (where u = unchanged). it is recommended, therefore, that only bcf, bsf, swapf and movwf instructions are used to alter the status register, because these instructions do not affect any status bits. for other instructions not affecting any status bits (refer to section 26.0 ?instruction set summary? ). note 1: the c and dc bits operate as borrow and digit borrow out bits, respectively, in subtraction. register 2-1: status: status register u-0 u-0 u-0 r-1/q r-1/q r/w-x/x r/w-x/x r/w-x/x ? ? ? to pd zdc (1) c (1) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared q = value depends on condition bit 7-5 unimplemented: read as ? 0 ? bit 4 to : time-out bit 1 = after power-up, clrwdt instruction or sleep instruction 0 = a wdt time-out occurred bit 3 pd : power-down bit 1 = after power-up or by the clrwdt instruction 0 = by execution of the sleep instruction bit 2 z: zero bit 1 = the result of an arithmetic or logic operation is zero 0 = the result of an arithmetic or logic operation is not zero bit 1 dc: digit carry/digit borrow bit ( addwf , addlw,sublw,subwf instructions) (1) 1 = a carry-out from the 4th low-order bit of the result occurred 0 = no carry-out from the 4th low-order bit of the result bit 0 c: carry/borrow bit (1) ( addwf , addlw, sublw, subwf instructions) (1) 1 = a carry-out from the most significant bit of the result occurred 0 = no carry-out from the most significant bit of the result occurred note 1: for borrow , the polarity is reversed. a subtraction is executed by adding the two?s complement of the second operand. for rotate ( rrf , rlf ) instructions, this bit is loaded with either the high-order or low-order bit of the source register.
? 2009 microchip technology inc. preliminary ds41364c-page 53 pic16f193x/lf193x 2.2.3.2 option register the option register, shown in register 2-2, is a readable and writable register, which contains various control bits to configure: ? external int interrupt ?timer0 ? weak pull-ups register 2-2: option_reg: option register r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 wpuen intedg t0cs t0se psa ps2 ps1 ps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 wpuen : weak pull-up enable bit 1 = all weak pull-ups are disabled (except mclr , if it is enabled) 0 = weak pull-ups are enabled by individual wpux latch values bit 6 intedg: interrupt edge select bit 1 = interrupt on rising edge of rb0/int pin 0 = interrupt on falling edge of rb0/int pin bit 5 t0cs: timer0 clock source select bit 1 = transition on ra4/t0cki pin 0 = internal instruction cycle clock (f osc /4) bit 4 t0se: timer0 source edge select bit 1 = increment on high-to-low transition on ra4/t0cki pin 0 = increment on low-to-high transition on ra4/t0cki pin bit 3 psa: prescaler assignment bit 1 = prescaler is inactive and has no effect on the timer0 interrupt rate 0 = prescaler is active and affects the timer0 interrupt rate bit 2-0 ps<2:0>: prescaler rate select bits 000 001 010 011 100 101 110 111 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 bit value timer0 rate
pic16f193x/lf193x ds41364c-page 54 preliminary ? 2009 microchip technology inc. 2.3 pcl and pclath the program counter (pc) is 15 bits wide. the low byte comes from the pcl register, which is a readable and writable register. the high byte (pc<14:8>) is not directly readable or writable and comes from pclath. on any reset, the pc is cleared. figure 2-4 shows the five situations for the loading of the pc. figure 2-4: loading of pc in different situations 2.3.1 modifying pcl executing any instruction with the pcl register as the destination simultaneously causes the program coun- ter pc<14:8> bits (pch) to be replaced by the contents of the pclath register. this allows the entire contents of the program counter to be changed by writing the desired upper 7 bits to the pclath register. when the lower 8 bits are written to the pcl register, all 15 bits of the program counter will change to the values con- tained in the pclath register and those being written to the pcl register. 2.3.2 computed goto a computed goto is accomplished by adding an offset to the program counter ( addwf pcl ). when performing a table read using a computed goto method, care should be exercised if the table location crosses a pcl memory boundary (each 256-byte block). refer to the application note an556, ?implementing a table read? (ds00556). 2.3.3 computed function calls a computed function call allows programs to maintain tables of functions and provide another way to execute state machines or look-up tables. when performing a table read using a computed function call , care should be exercised if the table location crosses a pcl memory boundary (each 256-byte block). if using the call instruction, the pch<2:0> and pcl registers are loaded with the operand of the call instruction. pch<6:3> is loaded with pclath<6:3>. the callw instruction enables computed calls by com- bining pclath and w to form the destination address. a computed callw is accomplished by loading the w register with the desired address and executing callw . the pcl register is loaded with the value of w and pch is loaded with pclath. 2.3.4 branching the branching instructions add an offset to the pc. this allows relocatable code and code that crosses page boundaries. there are two forms of branching, brw and bra . the pc will have incremented to fetch the next instruction in both cases. when using either branching instruction, a pcl memory boundary may be crossed. if using brw , load the w register with the desired unsigned address and execute brw . the entire pc will be loaded with the address pc + 1 + w. if using bra , the entire pc will be loaded with pc + 1 +, the signed value of the operand of the bra instruction. 2.4 stack all devices have a 16-level x 15-bit wide hardware stack (refer to figures 2-1 and 2-3). the stack space is not part of either program or data space. the pc is pushed onto the stack when call or callw instruc- tions are executed or an interrupt causes a branch. the stack is poped in the event of a return , retlw or a retfie instruction execution. pclath is not affected by a push or pop operation. the stack operates as a circular buffer, if the stvren bit = 0 (configuration word 2). this means that after the stack has been pushed sixteen times, the seven- teenth push overwrites the value that was stored from the first push. the eighteenth push overwrites the second push (and so on). pcl pch 0 14 pc 0 6 7 alu result 8 pclath pcl pch 0 14 pc 0 6 4 opcode <10:0> 11 pclath pcl pch 0 14 pc 0 6 7 w 8 pclath instruction with pcl as destination goto, call callw pcl pch 0 14 pc pc + w 15 brw pcl pch 0 14 pc pc + opcode <8:0> 15 bra note 1: there are no instructions/mnemonics called push or pop. these are actions that occur from the execution of the call, callw , return , retlw and retfie instructions or the vectoring to an interrupt address.
? 2009 microchip technology inc. preliminary ds41364c-page 55 pic16f193x/lf193x 2.4.1 accessing the stack the stack is available through the tosh, tosl and stkptr registers. stkptr is the current value of the stack pointer. tosh:tosl register pair points to the top of the stack. both registers are read/writable. tos is split into tosh and tosl due to the 15-bit size of the pc. to access the stack, adjust the value of stkptr, which will position tosh:tosl, then read/write to tosh:tosl. stkptr is 5 bits to allow detection of overflow and underflow. during normal program operation, call, callw and interrupts will increment stkptr while return and retfie will decrement stkptr. at any time stkptr can be inspected to see how much stack is left. the stkptr always points at the currently used place on the stack. therefore, a call or callw will write the pc and then increment the stkptr, and a return will decrement the pc and then unload the pc. 2.4.2 overflow/ underflow reset if the stvren bit in configuration word 2 is programmed, the device will be reset if the stack is pushed beyond the sixteenth level or poped beyond the first level, setting the appropriate bits (stkovf or stkunf, respectively) in the pcon register. 2.5 indirect addressing, indf and fsr registers the indfn registers are not physical registers. any instruction that accesses an indfn register actually accesses the register at the address specified by the file select registers (fsr). if the fsrn address specifies one of the two indfn registers, the read will return ? 0 ? and the write will not occur (though status bits may be affected). the fsrn register value is created by the pair fsrnh and fsrnl. the fsr registers form a 16-bit address that allows an addressing space with 65536 locations. these locations are divided into three memory regions: ? traditional data memory ? linear data memory ? program flash memory
pic16f193x/lf193x ds41364c-page 56 preliminary ? 2009 microchip technology inc. figure 2-5: indirect addressing 0x0000 0x0fff traditional fsr address range data memory 0x1000 reserved linear data memory reserved 0x2000 0x29af 0x29b0 0x7fff 0x8000 0xffff 0x0000 0x0fff 0x0000 0x7fff program flash memory note: not all memory regions are completely implemented. consult device memory tables for memory limits. 0x1fff
? 2009 microchip technology inc. preliminary ds41364c-page 57 pic16f193x/lf193x 2.5.1 traditional data memory the traditional data memory is a region from fsr address 0x000 to fsr address 0xfff. the addresses correspond to the absolute addresses of all sfr, gpr and common registers. figure 2-6: traditio nal data memory map indirect addressing direct addressing bank select location select 4 bsr 6 0 from opcode fsrxl 70 bank select location select 0000 0001 0010 1111 0x00 0x7f bank 0 bank 1 bank 2 bank 31 0 fsrxh 70 0000
pic16f193x/lf193x ds41364c-page 58 preliminary ? 2009 microchip technology inc. 2.5.2 linear data memory the linear data memory is the region from fsr address 0x2000 to fsr address 0x29af. this region is a virtual region that points back to the 80-byte blocks of gpr memory in all the banks. unimplemented memory reads as 0x00. use of the linear data memory region allows buffers to be larger than 80 bytes because incrementing the fsr beyond one bank will go directly to the gpr memory of the next bank. the 16 bytes of common memory are not included in the linear data memory region. figure 2-7: linear data memory map 2.5.3 program flash memory to make constant data access easier, the entire program flash memory is mapped to the upper half of the fsr address space. when the msb of fsrnh is set, the lower 15 bits are the address in program memory which will be accessed through indf. only the lower 8 bits of each memory location is accessible via indf. writing to the program flash memory cannot be accomplished via the fsr/indf interface. all instructions that access program flash memory via the fsr/indf interface will require one additional instruction cycle to complete. figure 2-8: program flash memory map 7 0 1 7 0 0 location select 0x2000 fsrnh fsrnl 0x020 bank 0 0x06f 0x0a0 bank 1 0x0ef 0x120 bank 2 0x16f 0xf20 bank 30 0xf6f 0x29af 0 7 1 7 0 0 location select 0x8000 fsrnh fsrnl 0x0000 0x7fff 0xffff program flash memory (low 8 bits)
? 2009 microchip technology inc. preliminary ds41364c-page 59 pic16f193x/lf193x 3.0 resets the pic16f193x/lf193x differentiates between various kinds of reset: a) power-on reset (por) b) wdt reset during normal operation c) m clr reset d) brown-out reset (bor) e) reset instruction f) stack overflow g) stack underflow some registers are not affected in any reset condition; their status is unknown on por and unchanged in any other reset. most other registers are reset to a ?reset state? on: ? power-on reset (por) ?mclr reset ?wdt reset ? brown-out reset (bor) most registers are not affected by a wdt wake-up since this is viewed as the resumption of normal operation. to and pd bits are set or cleared differently in different reset situations, as indicated in table 3-6. these bits are used in software to determine the nature of the reset. a simplified block diagram of the on-chip reset circuit is shown in figure 3-1. the mclr reset path has a noise filter to detect and ignore small pulses. see section 28.0 ?electrical specifications? for pulse width specifications. figure 3-1: simplified block di agram of on-chip reset circuit external reset mclr v dd osc1 wdt time-out v dd rise detect ost/pwrt lfintosc por pulse ost (2) 10-bit ripple counter pwrt (2) 11-bit ripple counter enable ost (1) enable pwrt note 1: see table 3-5 for time-out situations. 2: pwrt and ost counters are reset by por and bor. brown-out reset bor reset instruction stack pointer stack full/underflow reset sleep 1024 cycles 64 ms mclre s r q chip_reset enable
pic16f193x/lf193x ds41364c-page 60 preliminary ? 2009 microchip technology inc. table 3-1: status bits and their significance table 3-2: reset condition for special registers (2) stkovf stkunf rmclr ri por bor to pd condition 00110x11 power-on reset or ldo reset 00110x0x illegal, to is set on por 00110xx0 illegal, pd is set on por 0011u011 brown-out reset uuuuuu0u wdt reset uuuuuu00 wdt wake-up from sleep uuuuuu10 interrupt wake-up from sleep uu0uuuuu mclr reset during normal operation uu0uuu10 mclr reset during sleep u u u 0 u u u u reset instruction executed 1uuuuuuu stack overflow reset (stvren = 1 ) u1uuuuuu stack underflow reset (stvren = 1 ) condition program counter status register pcon register power-on reset 0000h ---1 1000 00-- 110x mclr reset during normal operation 0000h ---u uuuu uu-- 0uuu mclr reset during sleep 0000h ---1 0uuu uu-- 0uuu wdt reset 0000h ---0 uuuu uu-- uuuu wdt wake-up from sleep pc + 1 ---0 0uuu uu-- uuuu brown-out reset 0000h ---1 1uuu 00-- 11u0 interrupt wake-up from sleep pc + 1 (1) ---1 0uuu uu-- uuuu reset instruction executed 0000h ---u uuuu uu-- u0uu stack overflow reset (stvren = 1 ) 0000h ---u uuuu 1u-- uuuu stack underflow reset (stvren = 1 ) 0000h ---u uuuu u1-- uuuu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?. note 1: when the wake-up is due to an interrupt and global enable bit (gie) is set, the return address is pushed on the stack and pc is loaded with the interrupt vector (0004h) after execution of pc + 1. 2: if a status bit is not implemented, that bit will be read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 61 pic16f193x/lf193x 3.1 m clr the pic16f193x/lf193x has a noise filter in the mclr reset path. the filter will detect and ignore small pulses. it should be noted that a reset does not drive the m clr pin low. voltages applied to the pin that exceed its specification can result in both mclr resets and excessive current beyond the device specification during the esd event. for this reason, microchip recommends that the mclr pin no longer be tied directly to v dd . the use of an rc network, as shown in figure 3-2, is suggested. an internal mclr option is enabled by clearing the mclre bit in the configuration word register. when mclre = 0 , the reset signal to the chip is generated internally. when the mclre = 1 , the re3/mclr pin becomes an external reset input. in this mode, the re3/mclr pin has a weak pull-up to v dd . in-circuit serial programming is not affected by selecting the internal mclr option. low-voltage programming (lvp) mode will override mclre. figure 3-2: recommended mclr circuit 3.2 power-on reset (por) the on-chip por circuit holds the chip in reset until v dd has reached a high enough level for proper operation. a maximum rise time for v dd is required. see section 28.0 ?electrical specifications? for details. if the bor is enabled, the maximum rise time specification does not apply. the bor circuitry will keep the device in reset until v dd reaches v bor (see section 3.5 ?brown-out reset (bor)? ). when the device starts normal operation (exits the reset condition), device operating parameters (i.e., voltage, frequency, temperature, etc.) must be met to ensure operation. if these conditions are not met, the device must be held in reset until the operating conditions are met. for additional information, refer to application note an607, ?power-up trouble shooting? (ds00607). 3.3 power-up timer (pwrt) the power-up timer provides a fixed 64 ms (nominal) time-out on power-up only, from por or brown-out reset. the power-up timer operates from the wdt oscillator. for more information, see section 8.5 ?internal clock modes? . the chip is kept in reset as long as pwrt is active. the pwrt delay allows the v dd to rise to an acceptable level. a configuration bit, pwrte , can disable (if set) or enable (if cleared or pro- grammed) the power-up timer. the power-up timer should be enabled when brown-out reset is enabled, although it is not required. the power-up timer delay will vary from chip-to-chip and vary due to: ?v dd variation ? temperature variation ? process variation see dc parameters for details ( section 28.0 ?electrical specifications? ). 3.4 watchdog timer (wdt) the wdt has the following features: ? independent prescaler from timer0 ? time-out period is from 1.024 ms to 268 seconds, typical ? enabled by configuration bits wdte<1:0> ? can be disabled during sleep ? controlled by wdtcon register wdt is cleared under certain conditions described in table 3-3. 3.4.1 wdt oscillator the wdt derives its time base from the 31 khz internal oscillator. v dd pic ? mcu mclr r1 10 k c1 0.1 f note: the power-up timer is enabled by the pwrte bit in the configuration word. note: when the oscillator start-up timer (ost) is invoked, the wdt is held in reset. when the ost count has expired, the wdt will begin counting (if enabled).
pic16f193x/lf193x ds41364c-page 62 preliminary ? 2009 microchip technology inc. 3.4.2 wdt control the wdte<1:0> bits are located in the configuration word register 1. when set to ? 11 ?, the wdt runs continuously. when entering sleep the wdt is always cleared. when set to ? 10 ?, the wdt is enabled while running, and disabled during sleep. when ? 01 ? the wdt is under control of the swdten bit, and when ? 00 ? the wdt is always disabled. the wdtcon register contains the swdten bit and wdtps<4:0> bits. when the wdte<1:0> bits in the configuration word 1 register are anything but ? 01 ?, the swdten bit has no effect. when wdte = 01 , the swdten bit can be used to enable and disable the wdt. setting the bit will enable the wdt and clearing the bit will disable the wdt. the wdtps<4:0> bits control the prescaler. see register 3-1. the reset value of wdtcon gives a nominal wdt interval of ~2s. upon reset, the swdten value will leave the wdt disabled if wdte<1:0> is ? 01 ? in the configuration word. the prescaler will always be cleared on a reset. figure 3-3: watchdog ti mer block diagram lfintosc 23-bit programmable prescaler wdt wdt time-out wdte<1:0> = 00 wdtps<4:0> swdten sleep wdte<1:0> = 11 wdte<1:0> = 01 wdte<1:0> = 10 table 3-3: wdt status conditions wdt wdte<1:0> = 00 cleared wdte<1:0> = 01 and swdten = 0 wdte<1:0> = 10 and enter sleep clrwdt command oscillator fail detected exit sleep + system clock = t1osc, extrc, intosc, extclk exit sleep + system clock = xt, hs, lp cleared until the end of ost change intosc divider (ircf bits) unaffected
? 2009 microchip technology inc. preliminary ds41364c-page 63 pic16f193x/lf193x register 3-1: wdtcon: wat chdog timer control register u-0 u-0 r/w-0/0 r/w-1/1 r/w-0/0 r/w-1/1 r/w-1/1 r/w-0/0 ? ? wdtps4 wdtps3 wdtps2 wdtps1 wdtps0 swdten bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-6 unimplemented: read as ? 0 ? bit 5-1 wdtps<4:0>: watchdog timer period select bits bit value = prescale rate 00000 = 1:32 (interval 1 ms typ) 00001 = 1:64 (interval 2 ms typ) 00010 = 1:128 (interval 4 ms typ) 00011 = 1:256 (interval 8 ms typ) 00100 = 1:512 (interval 16 ms typ) 00101 = 1:1024 (interval 32 ms typ) 00110 = 1:2048 (interval 64 ms typ) 00111 = 1:4096 (interval 128 ms typ) 01000 = 1:8192 (interval 256 ms typ) 01001 = 1:16384 (interval 512 ms typ) 01010 = 1:32768 (interval 1s typ) 01011 = 1:65536 (interval 2s typ) (reset value) 01100 = 1:131072 (2 17 ) (interval 4s typ) 01101 = 1:262144 (2 18 ) (interval 8s typ) 01110 = 1:524288 (2 19 ) (interval 16s typ) 01111 = 1:1048576 (2 20 ) (interval 32s typ) 10000 = 1:2097152 (2 21 ) (interval 64s typ) 10001 = 1:4194304 (2 22 ) (interval 128s typ) 10010 = 1:8388608 (2 23 ) (interval 256s typ) 10011 = reserved. results in minimum interval (1:32) ? ? ? 11111 = reserved. results in minimum interval (1:32) bit 0 swdten: software enable/disable for watchdog timer bit if wdte<1:0> = 00 : this bit is ignored. if w dte<1:0> = 01 : 1 = wdt is turned on 0 = wdt is turned off if wdte<1:0> = 1x : this bit is ignored.
pic16f193x/lf193x ds41364c-page 64 preliminary ? 2009 microchip technology inc. 3.5 brown-out reset (bor) brown-out reset is enabled by programming the boren<1:0> bits in the configuration register. the brown-out trip point is selectable from two trip points via the borv bit in the configuration register. between the por and bor, complete voltage range coverage for execution protection can be imple- mented. two bits are used to enable the bor. when boren = 11 , the bor is always enabled. when boren = 10 , the bor is enabled, but disabled during sleep. when boren = 01 , the bor is controlled by the sboren bit of the borcon register. when boren = 00 , the bor is disabled. if v dd falls below v bor for greater than parameter (t bor ) (see section 28.0 ?electrical specifica- tions? ), the brown-out situation will reset the device. this will occur regardless of v dd slew rate. a reset is not ensured to occur if v dd falls below v bor for more than parameter (t bor ). if v dd drops below v bor while the power-up timer is running, the chip will go back into a brown-out reset and the power-up timer will be re-initialized. once v dd rises above v bor , the power-up timer will execute a 64 ms reset. table 3-4: bor operating modes figure 3-4: brown -out situations boren config bits sboren device mode bor mode device operation upon release of por device operation upon wake- up from sleep bor_on ( 11 ) x x active waits for bor ready (1) bor_nsleep ( 10) x awake active waits for bor ready bor_nsleep ( 10 ) x sleep disabled bor_sboren ( 01 ) 1 x active begins immediately bor_sboren ( 01 ) 0 x disabled begins immediately bor_off ( 00 ) x x disabled begins immediately note 1: even though this case specifically waits for the bor, the bor is already operating, so there is no delay in startup. 64 ms (1) v bor v dd internal reset v bor v dd internal reset 64 ms (1) < 64 ms 64 ms (1) v bor v dd internal reset note 1: 64 ms delay only if pwrte bit is programmed to ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 65 pic16f193x/lf193x register 3-2: borco n: brown-out reset control register r/w-1/u u-0 u-0 u-0 u-0 u-0 u-0 r/w-q/u sboren ? ? ? ? ? ? borrdy bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared q = value depends on condition bit 7 sboren: software brown-out reset enable bit if boren 01 : sboren is read/write, but has no effect on the bor. if boren = 01 : 1 =bor enabled 0 =bor disabled bit 6-1 unimplemented: read as ? 0 ? bit 0 borrdy: brown-out reset circuit ready status bit 1 = the brown-out reset circuit is active and armed 0 = the brown-out reset circuit is disabled or is warming up
pic16f193x/lf193x ds41364c-page 66 preliminary ? 2009 microchip technology inc. 3.5.1 bor hibernate/rearm the bor circuit has an output that feeds into the por circuit and rearms the por within the operating range of the bor. this early rearming of the por ensures that the device will remain in reset in the event that v dd falls below the operating range of the bor circuitry. 3.6 reset instruction a reset instruction will cause a device reset. the ri bit in the pcon register will be set to ? 0 ?. see table 3-6 for default conditions after a reset instruction has occurred. 3.7 stack overflow/underflow device resets on stack overflow and stack underflow conditions are enabled by setting the stvren bit in configuration word 2. when stvren is set, an overflow or underflow condition will set the appropriate stkovf or stkunf bit in the pcon register and then cause a device reset. when stvren is cleared, an overflow or underflow condition will set the appropriate stkovf or stkunf bit, but not cause a device reset. the stkovf or stkunf bit is cleared by user software or a power-on reset. 3.8 power-up time-out sequence on power-up, the time-out sequence is as follows: first, pwrt time-out is invoked after por or bor has expired, then ost is activated after the pwrt time-out has expired. the total time-out will vary based on oscil- lator configuration and pwrte bit status. for example, in ec mode with pwrte bit = 1 (pwrt disabled), there will be no time out at all. figure 3-5, figure 3-6 and figure 3-7 depict time-out sequences. since the time outs occur from the por pulse, if mclr is kept low long enough, the time-outs will expire. then, bringing mclr high will begin execution immediately (see figure 3-6). this is useful for testing purposes or to synchronize more than one pic16f193x/lf193x device operating in parallel. table 3-7 shows the reset conditions for some special registers.
? 2009 microchip technology inc. preliminary ds41364c-page 67 pic16f193x/lf193x 3.9 power control (pcon) register the power control (pcon) register has six status bits to indicate what type of reset that last occurred. 3.9.1 pcon register the power control (pcon) register contains flag bits (refer to table 3-6) to differentiate between a: ? power-on reset (por ) ? brown-out reset (bor ) ? reset instruction reset (ri ) ? stack overflow reset (stkovf) ? stack underflow reset (stkuvf) the pcon register also controls the software enable of the bor. the pcon register bits are shown in register 3-3. register 3-3: pcon: power control register r/w-0/q r/w-0/q u-0 u-0 r/w-1/q r/w-1/q r/w-q/u r/w-q/u stkovf stkunf ? ? rmclr ri por bor bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared q = value depends on condition bit 7 stkovf: stack overflow flag bit 1 = a stack overflow occurred (more call s than fit on the stack) 0 = a stack overflow has not occurred or set to ? 0 ? by firmware bit 6 stkunf: stack underflow flag bit 1 = a stack underflow occurred (more return s than call s) 0 = a stack underflow has not occurred or set to ? 0 ? by firmware bit 5-4 unimplemented: read as ? 0 ? bit 3 rmclr : m clr reset flag bit 1 = a mclr reset has not occurred or set to ? 1 ? by firmware 0 = a mclr reset has occurred (set to ? 0 ? in hardware when a mclr reset occurs) bit 2 ri : reset instruction flag bit 1 = a reset instruction has not been executed or set to ? 1 ? by firmware 0 = a reset instruction has been executed (set to ? 0 ? in hardware upon executing a reset instruction) bit 1 por : power-on reset status bit 1 = no power-on reset occurred 0 = a power-on reset occurred (must be set in software after a power-on reset occurs) bit 0 bor : brown-out reset status bit 1 = no brown-out reset occurred 0 = a brown-out reset occurred (must be set in software after a power-on reset or brown-out reset occurs)
pic16f193x/lf193x ds41364c-page 68 preliminary ? 2009 microchip technology inc. table 3-5: time-out in various situations table 3-6: reset bits and their significance figure 3-5: time-out sequence on power-up (delayed mclr ): case 1 oscillator configuration power-up and brown-out reset wake-up from sleep or oscillator switch pwrte = 0 pwrte = 1 xt, hs, lp 64 ms + 1024 ? t osc 1024 ? t osc 1024 ? t osc external rc 64 ms ? ? ec 64 ms ? ? intosc 64 ms 1 s1 s note 1: lp mode with t1osc disabled. stkovf stkunf rmclr ri por bor to pd condition 00110x11 power-on reset 00110x0x illegal, to is set on por 00110xx0 illegal, pd is set on por 001uu011 brown-out reset uuuuuu0u wdt reset uuuuuu00 wdt wake-up from sleep uuuuuu10 interrupt wake-up from sleep uu0uuuuu mclr reset during normal operation uu0uuu10 mclr reset during sleep uuu0uuuu reset instruction executed 1uuuuuuu stack overflow reset (stvren = 1 ) u1uuuuuu stack underflow reset (stvren = 1 ) legend: u = unchanged, x = unknown t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset
? 2009 microchip technology inc. preliminary ds41364c-page 69 pic16f193x/lf193x figure 3-6: time-out sequence on power-up (delayed mclr ): case 2 figure 3-7: time-out sequ ence on power-up (mclr with v dd ): case 3 v dd mclr internal por pwrt time-out ost time-out internal reset t pwrt t ost t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset
pic16f193x/lf193x ds41364c-page 70 preliminary ? 2009 microchip technology inc. table 3-7: reset condition for special registers (2) table 3-8: summary of registers associated with resets condition program counter status register pcon register power-on reset 0000h ---1 1000 00-- 110x mclr reset during normal operation 0000h ---u uuuu uu-- 0uuu mclr reset during sleep 0000h ---1 0uuu uu-- 0uuu wdt reset 0000h ---0 uuuu uu-- uuuu wdt wake-up from sleep pc + 1 ---0 0uuu uu-- uuuu brown-out reset 0000h ---1 1uuu 00-- 11u0 interrupt wake-up from sleep pc + 1 (1) ---1 0uuu uu-- uuuu reset instruction executed 0000h ---u uuuu uu-- u0uu stack overflow reset (stvren = 1 ) 0000h ---u uuuu 1u-- uuuu stack underflow reset (stvren = 1 ) 0000h ---u uuuu u1-- uuuu legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?. note 1: when the wake-up is due to an interrupt and global interrupt enable bit, gie, is set, the pc is loaded with the interrupt vector (0004h) after execution of pc + 1. 2: if a status bit is not implemented, that bit will be read as ? 0 ?. name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page borcon sboren ? ? ? ? ? ? borrdy 65 pcon stkovf stkunf ? ?rmclr ri por bor 67 status ? ? ?to pd z dc c52 wdtcon ? ? wdtps4 wdtps3 wdtps2 wdtps1 wdtps0 swdten 63 legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ? 0 ?, q = value depends on condition. shaded cells are not used by resets. note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation.
? 2009 microchip technology inc. preliminary ds41364c-page 71 pic16f193x/lf193x 4.0 interrupts the pic16f193x/lf193x device family features an interruptible core, allowing certain events to preempt normal program flow. an interrupt service routine (isr) is used to determine the source of the interrupt and act accordingly. some interrupts can be configured to wake the mcu from sleep mode. the pic16f193x/lf193x device family has 23 inter- rupt sources, differentiated by corresponding interrupt enable and flag bits: ? external edge detect on int pin interrupt ? interrupt-on-change interrupt ? a/d conversion complete interrupt ? eeprom write complete interrupt ? eusart receive interrupt ? eusart transmit interrupt ? lcd module interrupt ? oscillator fail interrupt ? timer0 overflow interrupt ? timer1 gate interrupt ? timer1 overflow interrupt ? timer2 match with pr2 interrupt ? timer4 match with pr4 interrupt ? timer6 match with pr6 interrupt ? comparator c1 interrupt ? comparator c2 interrupt ? ccp1 event interrupt ? ccp2 event interrupt ? ccp3 event interrupt ? ccp4 event interrupt ? ccp5 event interrupt ? mssp event interrupt ? mssp bus collision interrupt a block diagram of the interrupt logic is shown in figure 4-1. figure 4-1: interrupt logic tmr0if tmr0ie intf inte iocif iocie gie peie wake-up (if in sleep mode) interrupt to cpu from peripheral interrupt logic (figure 4-2)
pic16f193x/lf193x ds41364c-page 72 preliminary ? 2009 microchip technology inc. figure 4-2: peripheral interrupt logic tmr1gif tmr1gie adif adie rcif rcie txif txie sspif sspie osfif osfie c2if c2ie c1if c1ie eeif eeie bclif bclie lcdif lcdie tmr1if tmr1ie tmr6if tmr6ie ? ? ? ? ? ? ccp1if ccp1ie ccp5if ccp5ie ? ? ? ? ? ? to interrupt logic (figure 4-1)
? 2009 microchip technology inc. preliminary ds41364c-page 73 pic16f193x/lf193x 4.1 operation interrupts are disabled upon any device reset. they are enabled by setting the following bits: ? gie bit of the intcon register ? interrupt enable bit(s) for the specific interrupt event(s) ? peie bit of the intcon register (if the interrupt enable bit of the interrupt event is contained in the pie1, pie2 and pie3 registers) the intcon, pir1, pir2 and pir3 registers record individual interrupts via interrupt flag bits. interrupt flag bits will be set, regardless of the status of the gie, peie and individual interrupt enable bits. the following events happen when an interrupt event occurs while the gie bit is set: ? current prefetched instruction is flushed ? gie bit is cleared ? current program counter (pc) is pushed onto the stack ? pc is loaded with the interrupt vector 0004h the isr determines the source of the interrupt by polling the interrupt flag bits. the interrupt flag bits must be cleared before exiting the isr to avoid repeated interrupts. because the gie bit is cleared, any interrupt that occurs while executing the isr will be recorded through its interrupt flag, but will not cause the processor to redirect to the interrupt vector. the retfie instruction exits the isr by popping the previous address from the stack, restoring the saved context from the shadow registers and setting the gie bit. for additional information on a specific interrupt?s operation, refer to its peripheral chapter. 4.2 interrupt latency interrupt latency is defined as the time from when the interrupt event occurs to the time code execution at the interrupt vector begins. the latency for synchronous interrupts is 3 or 4 instruction cycles. for asynchronous interrupts, the latency is 3 to 5 instruction cycles, depending on when the interrupt occurs. see figure 4-3 for timing details. figure 4-3: int pin interrupt timing note 1: individual interrupt flag bits are set, regardless of the state of any other enable bits. 2: all interrupts will be ignored while the gie bit is cleared. any interrupt occurring while the gie bit is clear will be serviced when the gie bit is set again. q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 osc1 clkout int pin intf flag (intcon<1>) gie bit (intcon<7>) instruction flow pc instruction fetched instruction executed interrupt latency pc pc + 1 pc + 1 0004h 0005h inst (0004h) inst (0005h) dummy cycle inst (pc) inst (pc + 1) inst (pc ? 1) inst (0004h) dummy cycle inst (pc) ? note 1: intf flag is sampled here (every q1). 2: asynchronous interrupt latency = 3-5 t cy . synchronous latency = 3-4 t cy , where t cy = instruction cycle time. latency is the same whether inst (pc) is a single cycle or a 2-cycle instruction. 3: clkout is available only in intosc and rc oscillator modes. 4: for minimum width of int pulse, refer to ac specifications in section 28.0 ?electrical specifications? . 5: intf is enabled to be set any time during the q4-q1 cycles. (1) (2) (3) (4) (5) (1)
pic16f193x/lf193x ds41364c-page 74 preliminary ? 2009 microchip technology inc. 4.3 interrupts during sleep some interrupts can be used to wake from sleep. to wake from sleep, the peripheral must be able to operate without the system clock. the interrupt source must have the appropriate interrupt enable bit(s) set prior to entering sleep. on waking from sleep, if the gie bit is also set, the processor will branch to the interrupt vector. otherwise, the processor will continue executing instructions after the sleep instruction. the instruction directly after the sleep instruction will always be executed before branching to the isr. refer to the section 24.0 ?power-down mode (sleep)? for more details. 4.4 int pin the external interrupt, int pin, causes an asynchronous, edge-triggered interrupt. the intedg bit of the option register determines on which edge the interrupt will occur. when the intedg bit is set, the rising edge will cause the interrupt. when the intedg bit is clear, the falling edge will cause the interrupt. the intf bit of the intcon register will be set when a valid edge appears on the int pin. if the gie and inte bits are also set, the processor will redirect program execution to the interrupt vector. this interrupt is disabled by clearing the inte bit of the intcon register. 4.5 context saving upon entering an interrupt, the return pc address is saved on the stack. additionally, the following registers are automatically saved in the shadow registers: ? w register ? status register (except for to and pd ) ? bsr register ? fsr registers ? pclath register upon exit from the interrupt service routine, these reg- isters are automatically restored. any modifications to these registers during the isr will be lost. depending on the user?s application, other registers may also need to be saved.
? 2009 microchip technology inc. preliminary ds41364c-page 75 pic16f193x/lf193x 4.5.1 intcon register the intcon register is a readable and writable register, which contains the various enable and flag bits for tmr0 register overflow, interrupt-on-change and external int pin interrupts. note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie of the intcon register. user software should ensure the appropri- ate interrupt flag bits are clear prior to enabling an interrupt. register 4-1: intcon: interrupt control register r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r-0/0 gie peie tmr0ie inte iocie tmr0if (1) intf iocif bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 gie: global interrupt enable bit 1 = enables all unmasked interrupts 0 = disables all interrupts bit 6 peie: peripheral interrupt enable bit 1 = enables all unmasked peripheral interrupts 0 = disables all peripheral interrupts bit 5 tmr0ie: timer0 overflow interrupt enable bit 1 = enables the timer0 interrupt 0 = disables the timer0 interrupt bit 4 inte: rb0/int external interrupt enable bit 1 = enables the rb0/int external interrupt 0 = disables the rb0/int external interrupt bit 3 iocie: interrupt-on-change enable bit (1) 1 = enables the interrupt-on-change 0 = disables the interrupt-on-change bit 2 tmr0if: timer0 overflow interrupt flag bit (2) 1 = tmr0 register has overflowed (must be cleared in software) 0 = tmr0 register did not overflow bit 1 intf: int external interrupt flag bit 1 = the int external interrupt occurred (must be cleared in software) 0 = the int external interrupt did not occur bit 0 iocif: interrupt-on-change interrupt flag bit 1 = when at least one of the interrupt-on-change pins changed state (must be cleared in software) 0 = none of the interrupt-on-change pins have changed state note 1: tmr0if bit is set when timer0 rolls over. timer0 is unchanged on reset and should be initialized before clearing tmr0if bit.
pic16f193x/lf193x ds41364c-page 76 preliminary ? 2009 microchip technology inc. 4.5.2 pie1 register the pie1 register contains the interrupt enable bits, as shown in register 4-2. note: bit peie of the intcon register must be set to enable any peripheral interrupt. register 4-2: pie1: peripheral interrupt enable register 1 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 tmr1gie: timer1 gate interrupt enable bit 1 = enable the timer1 gate acquisition complete interrupt 0 = disable the timer1 gate acquisition complete interrupt bit 6 adie: a/d converter (adc) interrupt enable bit 1 = enables the adc interrupt 0 = disables the adc interrupt bit 5 rcie: usart receive interrupt enable bit 1 = enables the usart receive interrupt 0 = disables the usart receive interrupt bit 4 txie: usart transmit interrupt enable bit 1 = enables the usart transmit interrupt 0 = disables the usart transmit interrupt bit 3 sspie: synchronous serial port (ssp) interrupt enable bit 1 = enables the ssp interrupt 0 = disables the ssp interrupt bit 2 ccp1ie: ccp1 interrupt enable bit 1 = enables the ccp1 interrupt 0 = disables the ccp1 interrupt bit 1 tmr2ie: tmr2 to pr2 match interrupt enable bit 1 = enables the timer2 to pr2 match interrupt 0 = disables the timer2 to pr2 match interrupt bit 0 tmr1ie: timer1 overflow interrupt enable bit 1 = enables the timer1 overflow interrupt 0 = disables the timer1 overflow interrupt
? 2009 microchip technology inc. preliminary ds41364c-page 77 pic16f193x/lf193x 4.5.3 pie2 register the pie2 register contains the interrupt enable bits, as shown in register 4-3. note: bit peie of the intcon register must be set to enable any peripheral interrupt. register 4-3: pie2: peripheral interrupt enable register 2 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 u-0 r/w-0/0 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 osfie: oscillator fail interrupt enable bit 1 = enables the oscillator fail interrupt 0 = disables the oscillator fail interrupt bit 6 c2ie: comparator c2 interrupt enable bit 1 = enables the comparator c2 interrupt 0 = disables the comparator c2 interrupt bit 5 c1ie: comparator c1 interrupt enable bit 1 = enables the comparator c1 interrupt 0 = disables the comparator c1 interrupt bit 4 eeie: eeprom write completion interrupt enable bit 1 = enables the eeprom write completion interrupt 0 = disables the eeprom write completion interrupt bit 3 bclie: mssp bus collision interrupt enable bit 1 = enables the mssp bus collision interrupt 0 = disables the mssp bus collision interrupt bit 2 lcdie: lcd module interrupt enable bit 1 = enables the lcd module interrupt 0 = disables the lcd module interrupt bit 1 unimplemented: read as ? 0 ? bit 0 ccp2ie: ccp2 interrupt enable bit 1 = enables the ccp2 interrupt 0 = disables the ccp2 interrupt
pic16f193x/lf193x ds41364c-page 78 preliminary ? 2009 microchip technology inc. 4.5.4 pie3 register the pie3 register contains the interrupt enable bits, as shown in register 4-4. note: bit peie of the intcon register must be set to enable any peripheral interrupt. register 4-4: pie3: peripheral interrupt enable register 3 u-0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 u-0 r/w-0/0 u-0 ? ccp5ie ccp4ie ccp3ie tmr6ie ?tmr4ie ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 unimplemented: read as ? 0 ? bit 6 ccp5ie: ccp5 interrupt enable bit 1 = enables the ccp5 interrupt 0 = disables the ccp5 interrupt bit 5 ccp4ie: ccp4 interrupt enable bit 1 = enables the ccp4 interrupt 0 = disables the ccp4 interrupt bit 4 ccp3ie: ccp3 interrupt enable bit 1 = enables the ccp3 interrupt 0 = disables the ccp3 interrupt bit 3 tmr6ie: tmr6 to pr6 match interrupt enable bit 1 = enables the tmr6 to pr6 match interrupt 0 = disables the tmr6 to pr6 match interrupt bit 2 unimplemented: read as ? 0 ? bit 1 tmr4ie: tmr4 to pr4 match interrupt enable bit 1 = enables the tmr4 to pr4 match interrupt 0 = disables the tmr4 to pr4 match interrupt bit 0 unimplemented: read as ? 0 ?
? 2009 microchip technology inc. preliminary ds41364c-page 79 pic16f193x/lf193x 4.5.5 pir1 register the pir1 register contains the interrupt flag bits, as shown in register 4-5. note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie, of the intcon register. user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. register 4-5: pir1: peripheral interrupt request register 1 r/w-0/0 r/w-0/0 r-0/0 r-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 tmr1gif: timer1 gate interrupt flag bit 1 = timer1 gate is inactive 0 = timer1 gate is active bit 6 adif: a/d converter interrupt flag bit 1 = a/d conversion complete (must be cleared in software) 0 = a/d conversion has not completed or has not been started bit 5 rcif: usart receive interrupt flag bit 1 = the usart receive buffer is full (cleared by reading rcreg) 0 = the usart receive buffer is not full bit 4 txif: usart transmit interrupt flag bit 1 = the usart transmit buffer is empty (cleared by writing to txreg) 0 = the usart transmit buffer is full bit 3 sspif: synchronous serial port (ssp) interrupt flag bit 1 = the transmission/reception is complete (must be cleared in software) 0 = waiting to transmit/receive bit 2 ccp1if: ccp1 interrupt flag bit capture mode : 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode : 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode : unused in this mode bit 1 tmr2if: timer2 to pr2 interrupt flag bit 1 = a timer2 to pr2 match occurred (must be cleared in software) 0 = no timer2 to pr2 match occurred bit 0 tmr1if: timer1 overflow interrupt flag bit 1 = the tmr1 register overflowed (must be cleared in software) 0 = the tmr1 register did not overflow
pic16f193x/lf193x ds41364c-page 80 preliminary ? 2009 microchip technology inc. 4.5.6 pir2 register the pir2 register contains the interrupt flag bits, as shown in register 4-6. note: interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global enable bit, gie of the intcon register. user software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. register 4-6: pir2: peripheral interrupt request register 2 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 u-0 r/w-0/0 osfif c2if c1if eeif bclif lcdif ? ccp2if bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 osfif: oscillator fail interrupt flag 1 = system oscillator failed, clock input has changed to intosc (must be cleared in software) 0 = no oscillator failure has been detected bit 6 c2if: comparator c2 interrupt flag 1 = an enabled edge was detected on comparator c2 (must be cleared in software) 0 = no enabled edge was detected on comparator c2 bit 5 c1if: comparator c1 interrupt flag 1 = an enabled edge was detected on comparator c1 (must be cleared in software) 0 = no enabled edge was detected on comparator c1 bit 4 eeif: eeprom write completion interrupt flag bit 1 = the eeprom write operation has completed (must be cleared in software) 0 = the eeprom write operation has not completed or has not been started bit 3 bclif: mssp bus collision interrupt flag bit 1 = a bus collision was detected (must be cleared in software) 0 = no bus collision was detected bit 2 lcdif: lcd module interrupt flag bit 1 = the lcd module has completed displaying a frame (must be cleared in software). 0 = the lcd module has not completed displaying a frame bit 1 unimplemented: read as ? 0 ? bit 0 ccp2if: ccp2 interrupt flag bit capture mode 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode unused in this mode
? 2009 microchip technology inc. preliminary ds41364c-page 81 pic16f193x/lf193x 4.5.7 pir3 register the pir3 register contains the interrupt enable bits, as shown in register 4-7. register 4-7: pir3: peripheral interrupt request register 3 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 ? ccp5if ccp4if ccp3if tmr6if ?tmr4if ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 unimplemented: read as ? 0 ? bit 6 ccp5if: ccp5 interrupt flag bit capture mode 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode unused in this mode bit 5 ccp4if: ccp4 interrupt flag bit capture mode 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode unused in this mode bit 4 ccp3if: ccp3 interrupt flag bit capture mode 1 = a tmr1 register capture occurred (must be cleared in software) 0 = no tmr1 register capture occurred compare mode 1 = a tmr1 register compare match occurred (must be cleared in software) 0 = no tmr1 register compare match occurred pwm mode unused in this mode bit 3 tmr6if: tmr6 to pr6 match interrupt flag bit 1 = tmr6 to pr6 post-scaled match occurred (must be cleared in software) 0 = no tmr6 to pr6 match occurred bit 2 unimplemented: read as ? 0 ? bit 1 tmr4if: tmr4 to pr4 match interrupt flag bit 1 = tmr4 to pr4 post-scaled match occurred (must be cleared in software) 0 = no tmr4 to pr4 match occurred bit 0 unimplemented: read as ? 0 ?
pic16f193x/lf193x ds41364c-page 82 preliminary ? 2009 microchip technology inc. table 4-1: summary of registers associated with interrupts name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 option_reg wpuen intedg t0cs t0se psa ps2 ps1 ps0 53 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pie2 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie 77 pie3 ? ccp5ie ccp4ie ccp3ie tmr6ie ?tmr4ie ?78 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 pir2 osfif c2if c1if eeif bclif lcdif ? ccp2if 80 pir3 ? ccp5if ccp4if ccp3if tmr6if ?tmr4if ?81 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by interrupts.
? 2009 microchip technology inc. preliminary ds41364c-page 83 pic16f193x/lf193x 5.0 low dropout (ldo) voltage regulator the pic16f193x devices differ from the pic16lf193x devices due to an internal low dropout (ldo) voltage regulator. the pic16f193x contain an internal ldo, while the pic16lf193x do not. the lithography of the die allows a maximum operating voltage of 3.6v on the internal digital logic. in order to continue to support 5.0v designs, a ldo voltage regulator is integrated on the die. the ldo voltage regulator allows for the internal digital logic to operate at 3.2v, while i/o?s operate at 5.0v (v dd ). the ldo voltage regulator requires an external bypass capacitor for stability. one of three pins, denoted as v cap , can be configured for the external bypass capacitor. it is recommended that the capacitor be a ceramic cap between 0.1 to 1.0 f. the v cap pin is not intended to supply power to external loads. an external voltage regulator should be used if this functionality is required. in addition, external devices should not supply power to the v cap pin. on power-up, the external capacitor will look like a large load on the ldo voltage regulator. to prevent erroneous operation, the device is held in reset while a constant current source charges the external capacitor. after the cap is fully charged, the device is released from reset. for more information, refer to section 28.0 ?electrical specifications? . see configuration word 2 register (register 10-2) for v cap enable bits.
pic16f193x/lf193x ds41364c-page 84 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 85 pic16f193x/lf193x 6.0 i/o ports depending on the device selected and peripherals enabled, there are up to five ports available. in general, when a peripheral is enabled, that pin may not be used as a general purpose i/o pin. each port has three registers for its operation. these registers are: ? trisx registers (data direction register) ? portx registers (reads the levels on the pins of the device) ? latx registers (output latch) the data latch (latx registers) is useful for read-modify-write operations on the value that the i/o pins are driving. ports with analog functions also have an anselx register which can disable the digital input and save power. a simplified model of a generic i/o port, without the interfaces to other peripherals, is shown in figure 6-1. figure 6-1: generic i/o port operation q d ck write latx data register i/o pin read portx write portx trisx read latx data bus to peripherals anselx v dd v ss
pic16f193x/lf193x ds41364c-page 86 preliminary ? 2009 microchip technology inc. 6.1 alternate pin function the alternate pin function control (apfcon) register is used to steer specific peripheral input and output functions between different pins. the apfcon register is shown in register 6-1. for this device family, the following functions can be moved between different pins. ?ss (slave select) ? ccp2 ? ccp3 ?timer1 gate ? sr latch srnq output ? comparator c2 output these bits have no effect on the values of any tris register. port and tris overrides will be routed to the correct pin. the unselected pin will be unaffected. register 6-1: apfcon: alternate pin function co ntrol register u-0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 ? ccp3sel t1gsel p2bsel srnqsel c2outsel sssel ccp2sel bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 unimplemented: read as ? 0 ?. bit 6 ccp3sel: ccp3 input/output pin selection bit for 28-pin devices ( pic16f1933/1936/1938 ) : 0 = ccp3/p3a function is on rc6/tx/ck/ccp3/p3a/seg9 1 = ccp3/p3a function is on rb5/an13/cps5/ccp3/p3a/t1g/com1 for 40-pin devices ( pic16f1934/1937/1939 ) : 0 = ccp3/p3a function is on re0/an5/ccp3/p3a/seg21 1 = ccp3/p3a function is on rb5/an13/cps5/ccp3/p3a/t1g/com1 bit 5 t1gsel: timer1 gate input pin selection bit 0 = t1g function is on rb5/an13/cps5/ccp3/p3a/t1g/com1 1 = t1g function is on rc4/sdi/sda/t1g/seg11 bit 4 p2bsel: ccp2 pwm b output pin selection bit for 28 - pin devices ( pic16f1933/1936/1938 ) : 0 = p2b function is on rc0/t1oso/t1cki/p2b 1 = p2b function is on rb5/an13/p2b/cps5/t1g/com1 for 40 - pin devices ( pic16f1934/1937/1939 ) : 0 = p2b function is on rc0/t1oso/t1cki/p2b 1 = p2b function is on rd2/cps10/p2b bit 3 srnqsel: sr latch nq output pin selection bit 0 = srnq function is on ra5/an4/c2out/srnq/ss /cps7/seg5/v cap 1 = srnq function is on ra0/an0/c12in0-/c2out/srnq/ss /seg12/v cap bit 2 c2outsel: comparator c2 output pin selection bit 0 = c2out function is on ra5/an4/c2out/srnq/ss /cps7/seg5/v cap 1 = c2out function is on ra0/an0/c12in0-/c2out/srnq/ss /seg12/v cap bit 1 sssel: ss input pin selection bit 0 =ss function is on ra5/an4/c2out/srnq/ss /cps7/seg5/v cap 1 =ss function is on ra0/an0/c12in0-/c2out/srnq/ss /seg12/v cap bit 0 ccp2sel: ccp2 input/output pin selection bit 0 = ccp2/p2a function is on rc1/t1osi/ccp2/p2a 1 = ccp2/p2a function is on rb3/an9/c12in2-/cps3/ccp2/p2a/vlcd3
? 2009 microchip technology inc. preliminary ds41364c-page 87 pic16f193x/lf193x 6.2 porta registers porta is a 8-bit wide, bidirectional port. the corresponding data direction register is trisa (register 6-4). setting a trisa bit (= 1 ) will make the corresponding porta pin an input (i.e., disable the output driver). clearing a trisa bit (= 0 ) will make the corresponding porta pin an output (i.e., enables output driver and puts the contents of the output latch on the selected pin). example 6-1 shows how to initialize porta. reading the porta register (register 6-2) reads the status of the pins, whereas writing to it will write to the port latch. all write operations are read-modify-write operations. therefore, a write to a port implies that the port pins are read, this value is modified and then written to the port data latch (lata). the trisa register (register 6-4) controls the porta pin output drivers, even when they are being used as analog inputs. the user should ensure the bits in the trisa register are maintained set when using them as analog inputs. i/o pins configured as analog input always read ? 0 ?. example 6-1: initializing porta note: the ansela register must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. banksel porta ; clrf porta ;init porta banksel lata ;data latch clrf lata ; banksel ansela ; clrf ansela ;digital i/o banksel trisa ; movlw 0ch ;set ra<3:2> as inputs movwf trisa ;and set ra<7:4,1:0> ;as outputs register 6-2: porta: porta register r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 ra<7:0> : porta i/o value bits (1) note 1: writes to porta are actually written to corresponding lata register. reads from porta register is return of actual i/o pin values. register 6-3: lata: porta data latch register r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u lata7 lata6 lata5 lata4 lata3 lata2 lata1 lata0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 lata<7:0> : porta output latch value bits (1) note 1: writes to porta are actually written to corresponding lata register. reads from porta register is return of actual i/o pin values.
pic16f193x/lf193x ds41364c-page 88 preliminary ? 2009 microchip technology inc. 6.2.1 ansela register the ansela register (register 6-5) is used to configure the input mode of an i/o pin to analog. setting the appropriate ansela bit high will cause all digital reads on the pin to be read as ? 0 ? and allow analog functions on the pin to operate correctly. the state of the ansela bits has no affect on digital output functions. a pin with tris clear and ansel set will still operate as a digital output, but the input mode will be analog. this can cause unexpected behavior when executing read-modify-write instructions on the affected port. register 6-4: trisa: porta tri-state register r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 trisa<7:0>: porta tri-state control bit 1 = porta pin configured as an input (tri-stated) 0 = porta pin configured as an output register 6-5: ansela: porta analog select register u-0 u-0 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 ? ? ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-6 unimplemented: read as ? 0 ? bit 5-0 ansa<5:0> : analog select between analog or digital function on pins ra<5:0>, respectively 0 = digital i/o. pin is assigned to port or digital special function. 1 = analog input. pin is assigned as analog input (1) . digital input buffer disabled. note 1: when setting a pin to an analog input, the corresponding tris bit must be set to input mode in order to allow external control of the voltage on the pin.
? 2009 microchip technology inc. preliminary ds41364c-page 89 pic16f193x/lf193x 6.2.2 porta functions and output priorities each porta pin is multiplexed with other functions. the pins, their combined functions and their output priorities are briefly described here. for additional information, refer to the appropriate section in this data sheet. when multiple outputs are enabled, the actual pin control goes to the peripheral with the lowest number in the following lists. ra0 1. v cap (enabled by configuration word) 2. seg12 (lcd) 3. srnq (sr latch) 4. c2out (comparator) 5. ra0 ra1 1. seg7 (lcd) 2. ra1 ra2 1. com2 (lcd) 2. dacout (dac) 3. ra2 ra3 1. com3 (lcd), 28-pin only 2. seg15 (lcd) 3. ra3 ra4 1. seg4 (lcd) 2. srq (sr latch) 3. c1out (comparator) 4. ccp5 (ccp), 28-pin only 5. ra4 ra5 1. v cap (enabled by configuration word) 2. seg5 (lcd) 3. srnq (sr latch) 4. c2out (comparator) 5. ra5 ra6 1. v cap (enabled by configuration word) 2. osc2 (enabled by configuration word) 3. clkout (enabled by configuration word) 4. seg1 (lcd) 5. ra6 ra7 1. osc1/clkin (enabled by configuration word) 2. seg2 (lcd) 3. ra7
pic16f193x/lf193x ds41364c-page 90 preliminary ? 2009 microchip technology inc. table 6-1: summary of registers associated with porta name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page adcon0 ? chs4 chs3 chs2 chs1 chs0 go/done adon 139 adcon1 adfm adcs2 adcs1 adcs0 ? adref adref1 adref0 140 ansela ? ? ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 88 apfcon ? ccp3sel t1gsel p2bsel srnqsel c2outsel sssel ccp2sel 86 cm1con0 c1on c1out c1oe c1pol ? c1sp c1hys c1sync 150 cm2con0 c2on c2out c2oe c2pol ? c2sp c2hys c2sync 150 cpscon0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs 182 cpscon1 ? ? ? ? cpsch3 cpsch2 cpsch1 cpsch0 183 config2 (1) ? ? vcapen1 vcapen0 ? ? ? ? 130 daccon0 dacen daclps dacoe --- dacpss1 dacpss0 --- dacnss 155 lata lata7 lata6 lata5 lata4 lata3 lata2 lata1 lata0 87 lcdcon lcden slpen werr ? cs1 cs0 lmux1 lmux0 245 lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 249 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 249 option_reg wpuen intedg tmr0cs tmr0se psa ps2 ps1 ps0 53 porta ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 87 srcon0 srlen srclk2 srclk1 srclk0 srqen srnqen srps srpr 124 sspcon1 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 279 trisa trisa7trisa6trisa5trisa4trisa3trisa2trisa1trisa0 88 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by porta. note 1: pic16f193x only.
? 2009 microchip technology inc. preliminary ds41364c-page 91 pic16f193x/lf193x 6.3 portb and trisb registers portb is an 8-bit wide, bidirectional port. the corresponding data direction register is trisb (register 6-9). setting a trisb bit (= 1 ) will make the corresponding portb pin an input (i.e., put the corresponding output driver in a high-impedance mode). clearing a trisb bit (= 0 ) will make the corresponding portb pin an output (i.e., enable the output driver and put the contents of the output latch on the selected pin). example 6-2 shows how to initialize portb. reading the portb register (register 6-6) reads the status of the pins, whereas writing to it will write to the port latch. all write operations are read-modify-write operations. therefore, a write to a port implies that the port pins are read, this value is modified and then written to the port data latch. the trisb register (register 6-9) controls the portb pin output drivers, even when they are being used as analog inputs. the user should ensure the bits in the trisb register are maintained set when using them as analog inputs. i/o pins configured as analog input always read ? 0 ?. example 6-2 shows how to initialize portb. example 6-2: initializing portb 6.3.1 weak pull-ups each of the portb pins has an individually configurable internal weak pull-up. control bits wpub<7:0> enable or disable each pull-up (see register 6-8). each weak pull-up is automatically turned off when the port pin is configured as an output. all pull-ups are disabled on a power-on reset by the wpuen bit of the option register. 6.3.2 interrupt-on-change all of the portb pins are individually configurable as an interrupt-on-change pin. control bits iocb<7:0> enable or disable the interrupt function for each pin. the interrupt-on-change feature is disabled on a power-on reset. reference section 7.0 ?interrupt-on-change? for more information. note: the anselb register must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. banksel portb ; clrf portb ;init portb banksel anselb clrf anselb ;make rb<7:0> digital banksel trisb ; movlw b ? 11110000 ? ;set rb<7:4> as inputs ;and rb<3:0> as outputs movwf trisb ;
pic16f193x/lf193x ds41364c-page 92 preliminary ? 2009 microchip technology inc. register 6-6: port b: portb register r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 rb<7:0> : portb i/o pin bit 1 = port pin is > v ih 0 = port pin is < v il register 6-7: latb: portb data latch register r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u latb7 latb6 latb5 latb4 latb3 latb2 latb1 latb0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 latb<7:0> : portb output latch value bits (1) note 1: writes to portb are actually written to corresponding latb register. reads from portb register is return of actual i/o pin values. register 6-8: wpub: weak pull-up portb register r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 wpub7 wpub6 wpub5 wpub4 wpub3 wpub2 wpub1 wpub0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 wpub<7:0> : weak pull-up register bits 1 = pull-up enabled 0 = pull-up disabled note 1: global wpuen bit of the option register must be cleared for individual pull-ups to be enabled. 2: the weak pull-up device is automatically disabled if the pin is in configured as an output.
? 2009 microchip technology inc. preliminary ds41364c-page 93 pic16f193x/lf193x 6.3.3 anselb register the anselb register (register 6-10) is used to configure the input mode of an i/o pin to analog. setting the appropriate anselb bit high will cause all digital reads on the pin to be read as ? 0 ? and allow analog functions on the pin to operate correctly. the state of the anselb bits has no affect on digital output functions. a pin with tris clear and anselb set will still operate as a digital output, but the input mode will be analog. this can cause unexpected behavior when executing read-modify-write instructions on the affected port. register 6-9: trisb: po rtb tri-state register r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 trisb<7:0>: portb tri-state control bit 1 = portb pin configured as an input (tri-stated) 0 = portb pin configured as an output register 6-10: anselb: portb analog select register u-0 u-0 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-6 unimplemented: read as ? 0 ? bit 5-0 ansb<5:0> : analog select between analog or digital function on pins rb<5:0>, respectively 0 = digital i/o. pin is assigned to port or digital special function. 1 = analog input. pin is assigned as analog input (1) . digital input buffer disabled. note 1: when setting a pin to an analog input, the corresponding tris bit must be set to input mode in order to allow external control of the voltage on the pin.
pic16f193x/lf193x ds41364c-page 94 preliminary ? 2009 microchip technology inc. 6.3.4 portb functions and output priorities each portb pin is multiplexed with other functions. the pins, their combined functions and their output priorities are briefly described here. for additional information, refer to the appropriate section in this data sheet. when multiple outputs are enabled, the actual pin control goes to the peripheral with the lowest number in the following lists. rb0 1. seg0 (lcd) 2. ccp4, 28-pin only 3. rb0 rb1 1. p1c (eccp1), 28-pin only 2. rb1 rb2 1. p1b (eccp1), 28-pin only 2. rb2 rb3 1. ccp2/p2a 2. rb3 rb4 1. com0 2. p1d, 28-pin only 3. rb4 rb5 1. com1 2. p2b, 28-pin only 3. p3a 4. rb5 rb6 1. icspclk (programming) 2. icdclk (enabled by configuration word) 3. seg14 (lcd) 4. rb6 rb7 1. icspdat (programming) 2. icddat (enabled by configuration word) 3. seg13 (lcd) 4. rb7 table 6-2: summary of registers associated with portb name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page adcon0 ? chs4 chs3 chs2 chs1 chs0 go/done adon 139 anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 93 apfcon ?ccp3sel t1gsel p2bsel srnqsel c2outsel sssel ccp2sel 86 ccpxcon pxm1 pxm0 dcxb1 dcxb0 ccpxm3 ccpxm2 ccpxm1 ccpxm0 186 cpscon0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs 182 cpscon1 ? ? ? ? cpsch3 cpsch2 cpsch1 cpsch0 183 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 iocbp iocbp7 iocbp6 iocbp5 iocbp4 iocbp3 iocbp2 iocbp1 iocbp0 106 iocbn iocbn7 iocbn6 iocbn5 iocbn 4 iocbn3 iocbn2 iocbn1 iocbn0 106 iocbf iocbf7 iocbf6 iocbf5 iocbf4 iocbf3 iocbf2 iocbf1 iocbf0 106 latb latb7 latb6 latb5 latb4 latb3 latb2 latb1 latb0 92 lcdcon lcden slpen werr ? cs1 cs0 lmux1 lmux0 245 lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 249 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 249 option_reg wpuen intedg tmr0cs tmr0se psa ps2 ps1 ps0 53 portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 92 t1gcon tmr1ge t1gpol t1gtm t1gspm t1ggo/d one t1gval t1gss1 t1gss0 172 trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 93 wpub wpub7 wpub6 wpub5 wpub4 wpub3 wpub2 wpub1 wpub0 92 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by portb.
? 2009 microchip technology inc. preliminary ds41364c-page 95 pic16f193x/lf193x 6.4 portc and trisc registers portc is a 8-bit wide, bidirectional port. the corresponding data direction register is trisc (register 6-13). setting a trisc bit (= 1 ) will make the corresponding portc pin an input (i.e., put the corresponding output driver in a high-impedance mode). clearing a trisc bit (= 0 ) will make the corresponding portc pin an output (i.e., enable the output driver and put the contents of the output latch on the selected pin). example 6-3 shows how to initialize portc. reading the portc register (register 6-11) reads the status of the pins, whereas writing to it will write to the port latch. all write operations are read-modify-write operations. therefore, a write to a port implies that the port pins are read, this value is modified and then written to the port data latch. the trisc register (register 6-13) controls the portc pin output drivers, even when they are being used as analog inputs. the user should ensure the bits in the trisc register are maintained set when using them as analog inputs. i/o pins configured as analog input always read ? 0 ?. example 6-3: initializing portc the location of the ccp2 function is controlled by the ccp2sel bit in the apfcon register (refer to register 6-1). banksel portc ; clrf portc ;init portc banksel trisc ; movlw b?00001100? ;set rc<3:2> as inputs movwf trisc ;and set rc<7:4,1:0> ;as outputs register 6-11: portc: portc register r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u rc7 rc6 rc5 rc4 rc3 rc2 rc1 rc0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 rc<7:0> : portc general purpose i/o pin bits 1 = port pin is > v ih 0 = port pin is < v il register 6-12: latc: portc data latch register r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u latc7 latc6 latc5 latc4 latc3 latc2 latc1 latc0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 latc<7:0> : portc output latch value bits (1) note 1: writes to portc are actually written to corresponding latc register. reads from portc register is return of actual i/o pin values.
pic16f193x/lf193x ds41364c-page 96 preliminary ? 2009 microchip technology inc. register 6-13: trisc: po rtc tri-state register r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 trisc<7:0>: portc tri-state control bits 1 = portc pin configured as an input (tri-stated) 0 = portc pin configured as an output
? 2009 microchip technology inc. preliminary ds41364c-page 97 pic16f193x/lf193x 6.4.1 portc functions and output priorities each portc pin is multiplexed with other functions. the pins, their combined functions and their output priorities are briefly described here. for additional information, refer to the appropriate section in this data sheet. when multiple outputs are enabled, the actual pin control goes to the peripheral with the lowest number in the following lists. rc0 1. t1oso (timer1 oscillator) 2. p2b (ccp) 3. rc0 rc1 1. t1osi (timer1 oscillator) 2. p2a (ccp) 3. rc1 rc1 1. seg3 (lcd) 2. p1a (ccp) 3. rc2 rc3 1. seg6 (lcd) 2. scl (mssp) 3. sck (mssp) 4. rc3 rc4 1. seg11 (lcd) 2. sda (mssp) 3. rc4 rc5 1. seg10 (lcd) 2. sdl (mssp) 3. rc5 rc6 1. seg9 (lcd) 2. tx (eusart) 3. ck (eusart) 4. p3a (ccp), 28-pin only 5. rc6 rc7 1. seg8 (lcd) 2. dt (eusart) 3. p3b (ccp), 28 pin only 4. rc7 table 6-3: summary of regist ers associated with portc name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page apfcon ?ccp3sel t1gsel p2bsel srnqsel c2outsel sssel ccp2sel 86 ccpxcon pxm1 pxm0 dcxb1 dcxb0 ccpxm3 ccpxm2 ccpxm1 ccpxm0 186 latc latc7 latc6 latc5 latc4 latc3 latc2 latc1 latc0 95 lcdcon lcden slpen werr ? cs1 cs0 lmux1 lmux0 245 lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 249 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 249 portc rc7 rc6 rc5 rc4 rc3 rc2 rc1 rc0 95 rcsta spen rx9 sren cren adden ferr oerr rx9d 225 sspcon1 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 279 sspstat smp cke d/a p s r/w ua bf 278 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ? tmr1on 171 txsta csrc tx9 txen sync ? brgh trmt tx9d 224 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 legend: x = unknown, u = unchanged, - = unimplemented locations read as ? 0 ?. shaded cells are not used by portc.
pic16f193x/lf193x ds41364c-page 98 preliminary ? 2009 microchip technology inc. 6.5 portd and trisd registers portd (1) is a 8-bit wide, bidirectional port. the corresponding data direction register is trisd (register 6-16). setting a trisd bit (= 1 ) will make the corresponding portd pin an input (i.e., put the corresponding output driver in a high-impedance mode). clearing a trisd bit (= 0 ) will make the corresponding portd pin an output (i.e., enable the output driver and put the contents of the output latch on the selected pin). example 6-4 shows how to initialize portd. reading the portd register (register 6-14) reads the status of the pins, whereas writing to it will write to the port latch. all write operations are read-modify-write operations. therefore, a write to a port implies that the port pins are read, this value is modified and then written to the port data latch. the trisd register (register 6-16) controls the portd pin output drivers, even when they are being used as analog inputs. the user should ensure the bits in the trisd register are maintained set when using them as analog inputs. i/o pins configured as analog input always read ? 0 ?. example 6-4: initializing portd note 1: portd is available on pic16f1936 and pic16f1938 only. banksel portd ; clrf portd ;init portd banksel anseld clrf anseld ;make portd digital banksel trisd ; movlw b?00001100? ;set rd<3:2> as inputs movwf trisd ;and set rd<7:4,1:0> ;as outputs register 6-14: port d: portd register (1) r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u rd7 rd6 rd5 rd4 rd3 rd2 rd1 rd0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 rd<7:0> : portd general purpose i/o pin bits 1 = port pin is > v ih 0 = port pin is < v il note 1: portd is not implemented on pic16f1933/1936/1938 devices, read as ? 0 ?. register 6-15: latd: portd data latch register r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u latd7 latd6 latd5 latd4 latd3 latd2 latd1 latd0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 latd<7:0> : portd output latch value bits (1,2) note 1: writes to portd are actually written to corresponding latd register. reads from portd register is return of actual i/o pin values. 2: portd implemented on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only.
? 2009 microchip technology inc. preliminary ds41364c-page 99 pic16f193x/lf193x 6.5.1 anseld register the anseld register (register 6-17) is used to configure the input mode of an i/o pin to analog. setting the appropriate anseld bit high will cause all digital reads on the pin to be read as ? 0 ? and allow analog functions on the pin to operate correctly. the state of the anseld bits has no affect on digital output functions. a pin with tris clear and ansel set will still operate as a digital output, but the input mode will be analog. this can cause unexpected behavior when executing read-modify-write instructions on the affected port. note: the anseld register must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. register 6-16: trisd: po rtd tri-state register (1) r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 trisd7 trisd6 trisd5 trisd4 trisd3 trisd2 trisd1 trisd0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 trisd<7:0>: portd tri-state control bits 1 = portd pin configured as an input (tri-stated) 0 = portd pin configured as an output note 1: trisd is not implemented on pic16f1933/1936/1938 devices, read as ? 0 ?. 2: portd implemented on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only. register 6-17: anseld: portd analog select register (2) r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 ansd7 ansd6 ansd5 ansd4 ansd3 ansd2 ansd1 ansd0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 ansd<7:0> : analog select between analog or digital function on pins rd<7:0>, respectively 0 = digital i/o. pin is assigned to port or digital special function. 1 = analog input. pin is assigned as analog input (1) . digital input buffer disabled. note 1: when setting a pin to an analog input, the corresponding tris bit must be set to input mode in order to allow external control of the voltage on the pin. 2: anseld register is not implemented on the pic16f1933/1936/1938. read as ? 0 ?. 3: portd implemented on pic16f1934/1937/1939/pic16lf1934/1937/1939 devices only.
pic16f193x/lf193x ds41364c-page 100 preliminary ? 2009 microchip technology inc. 6.5.2 portd functions and output priorities each portd pin is multiplexed with other functions. the pins, their combined functions and their output priorities are briefly described here. for additional information, refer to the appropriate section in this data sheet. when multiple outputs are enabled, the actual pin control goes to the peripheral with the lowest number in the following lists. rd0 1. com3 (lcd) 2. rd0 rd1 1. ccp4 (ccp) 2. rd1 rd2 1. p2b (ccp) 2. rd2 rd3 1. seg16 (lcd) 2. p2c (ccp) 3. rd3 rd4 1. seg17 (lcd) 2. p2d (ccp) 3. rd4 rd5 1. seg18 (lcd) 2. p1b (ccp) 3. rd5 rd6 1. seg19 (lcd) 2. p1c (ccp) 3. rd6 rd7 1. seg20 (lcd) 2. p1d (ccp) 3. rd7 table 6-4: summary of registers associated with portd (1) name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page anseld ansd7 ansd6 ansd5 ansd4 ansd3 ansd2 ansd1 ansd0 99 ccpxcon pxm1 pxm0 dcxb1 dcxb0 ccpxm3 ccpxm2 ccpxm1 ccpxm0 186 cpscon0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs 182 cpscon1 ? ? ? ? cpsch3 cpsch2 cpsch1 cpsch0 183 latd latd7 latd6 latd5 latd4 latd3 latd2 latd1 latd0 98 lcdcon lcden slpen werr ? cs1 cs0 lmux1 lmux0 245 lcdse2 se23 se22 se21 se20 se19 se18 se17 se16 249 portd rd7 rd6 rd5 rd4 rd3 rd2 rd1 rd0 98 trisd trisd7 trisd6 trisd5 trisd4 trisd3 trisd2 trisd1 trisd0 99 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by portd. note 1: these registers are not implemented on the pic16f1933/1936/1938 devices, read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 101 pic16f193x/lf193x 6.6 porte and trise registers porte (1) is a 4-bit wide, bidirectional port. the corresponding data direction register is trise. setting a trise bit (= 1 ) will make the corresponding porte pin an input (i.e., put the corresponding output driver in a high-impedance mode). clearing a trise bit (= 0 ) will make the corresponding porte pin an output (i.e., enable the output driver and put the contents of the output latch on the selected pin). the exception is re3, which is input only and its tris bit will always read as ? 1 ?. example 6-5 shows how to initialize porte. reading the porte register (register 6-18) reads the status of the pins, whereas writing to it will write to the port latch. all write operations are read-modify-write operations. therefore, a write to a port implies that the port pins are read, this value is modified and then written to the port data latch. re3 reads ? 0 ? when mclre = 1. example 6-5: initializing porte note 1: re<2:0> and trise<2:0> pins are available on pic16f1936 and pic16f1938 only. banksel porte ; clrf porte ;init porte banksel ansele ; clrf ansele ;digital i/o banksel trise ; movlw b?00001100? ;set re<3:2> as inputs movwf trise ;and set re<1:0> ;as outputs register 6-18: port e: porte register u-0 u-0 u-0 u-0 r-x/u r/w-x/u r/w-x/u r/w-x/u ? ? ? ? re3 re2 (1) re1 (1) re0 (1) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-4 unimplemented : read as ? 0 ? bit 3-0 re<3:0> : porte i/o pin bits (1) 1 = port pin is > v ih 0 = port pin is < v il note 1: re<2:0> are not implemented on the pic16f1933/1936/1938. read as ? 0 ?. register 6-19: late: porte data latch register u-0 u-0 u-0 u-0 r/w-x/u r/w-x/u r/w-x/u r/w-x/u ? ? ? ? late3 late2 late1 late0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-4 unimplemented : read as ? 0 ? bit 3-0 late<3:0> : porte output latch value bits (1) note 1: writes to porte are actually written to corresponding late register. reads from porte register is return of actual i/o pin values.
pic16f193x/lf193x ds41364c-page 102 preliminary ? 2009 microchip technology inc. register 6-20: wpue: weak pull-up porte register u-0 u-0 u-0 u-0 r/w-1/1 u-0 u-0 u-0 ? ? ? ? wpue3 ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-4 unimplemented: read as ? 0 ? bit 3 wpue: weak pull-up register bit 1 = pull-up enabled 0 = pull-up disabled bit 2-0 unimplemented: read as ? 0 ? note 1: global wpuen bit of the option register must be cleared for individual pull-ups to be enabled. 2: the weak pull-up device is automatically disabled if the pin is in configured as an output.
? 2009 microchip technology inc. preliminary ds41364c-page 103 pic16f193x/lf193x 6.6.1 ansele register the ansele register (register 6-22) is used to configure the input mode of an i/o pin to analog. setting the appropriate ansele bit high will cause all digital reads on the pin to be read as ? 0 ? and allow analog functions on the pin to operate correctly. the state of the ansele bits has no affect on digital output functions. a pin with tris clear and ansel set will still operate as a digital output, but the input mode will be analog. this can cause unexpected behavior when executing read-modify-write instructions on the affected port. the trise register (register 6-21) controls the porte pin output drivers, even when they are being used as analog inputs. the user should ensure the bits in the trise register are maintained set when using them as analog inputs. i/o pins configured as analog input always read ? 0 ?. note: the ansele register must be initialized to configure an analog channel as a digital input. pins configured as analog inputs will read ? 0 ?. register 6-21: trise: porte tri-state register u-0 u-0 u-0 u-0 r-1 r/w-1 r/w-1 r/w-1 ? ? ? ? trise3 trise2 (1) trise1 (1) trise0 (1) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-4 unimplemented : read as ? 0 ? bit 3 trise3: re3 port tri-state control bit this bit is always ? 1 ? as re3 is an input only bit 2-0 trise<2:0>: re<2:0> tri-state control bits (1) 1 = porte pin configured as an input (tri-stated) 0 = porte pin configured as an output note 1: trise<2:0> are not implemented on the pic16f1933/1936/1938/pic16lf1933/1936/1938. read as ? 0 ?. register 6-22: ansele: po rte analog select register u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-1 r/w-1 ? ? ? ? ? anse2 (2) anse1 (2) anse0 (2) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-3 unimplemented: read as ? 0 ? bit 2-0 anse<2:0> : analog select between analog or digital function on pins re<2:0>, respectively 0 = digital i/o. pin is assigned to port or digital special function. 1 = analog input. pin is assigned as analog input (1) . digital input buffer disabled. note 1: when setting a pin to an analog input, the corresponding tris bit must be set to input mode in order to allow external control of the voltage on the pin. 2: ansele register is not implemented on the pic16f1933/1936/1938/pic16lf1933/1936/1938. read as ? 0 ?
pic16f193x/lf193x ds41364c-page 104 preliminary ? 2009 microchip technology inc. 6.6.2 porte functions and output priorities each porte pin is multiplexed with other functions. the pins, their combined functions and their output priorities are briefly described here. for additional information, refer to the appropriate section in this data sheet. when multiple outputs are enabled, the actual pin control goes to the peripheral with the lowest number in the following lists. re0 1. seg21 (lcd) 2. ccp3/p3a (ccp) 3. re0 re1 1. seg22 (lcd) 2. p3b (ccp) 3. re1 re2 1. seg23 (lcd) 2. ccp5 (ccp) 3. re2 table 6-5: summary of registers associated with porte (1) name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page adcon0 ? chs4 chs3 chs2 chs1 chs0 go/done adon 139 ansele ? ? ? ? ? anse2 anse1 anse0 103 ccpxcon pxm1 pxm0 dcxb1 dcxb0 ccpxm3 ccpxm2 ccpxm1 ccpxm0 186 late ? ? ? ? late3 late2 late1 late0 101 lcdcon lcden slpen werr ? cs1 cs0 lmux1 lmux0 245 lcdse2 se23 se22 se21 se20 se19 se18 se17 se16 249 porte ? ? ? ? re3 re2 re1 re0 101 trise ? ? ? ? trise3 trise2 trise1 trise0 103 wpue ? ? ? ? wpue3 ? ? ? 102 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by porte. note 1: these registers are not implemented on the pic16f1933/1936/1938 devices, read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 105 pic16f193x/lf193x 7.0 interrupt-on-change the portb pins can be configured to operate as interrupt-on-change (ioc) pins. an interrupt can be generated by detecting a signal that has either a rising edge or a falling edge. any individual portb pin, or combination of portb pins, can be configured to generate an interrupt. the interrupt-on-change module has the following features: ? interrupt-on-change enable (master switch) ? individual pin configuration ? rising and falling edge detection ? individual pin interrupt flags figure 7-1 is a block diagram of the ioc module. 7.1 enabling the module to allow individual portb pins to generate an interrupt, the iocie bit of the intcon register must be set. if the iocie bit is disabled, the edge detection on the pin will still occur, but an interrupt will not be generated. 7.2 individual pin configuration for each portb pin, a rising edge detector and a falling edge detector are present. to enable a pin to detect a rising edge, the associated iocbpx bit of the iocbp register is set. to enable a pin to detect a falling edge, the associated iocbnx bit of the iocbn register is set. a pin can be configured to detect rising and falling edges simultaneously by setting both the iocbpx bit and the iocbnx bit of the iocbp and iocbn registers, respectively. 7.3 interrupt flags the iocbfx bits located in the iocbf register are status flags that correspond to the interrupt-on-change pins of portb. if an expected edge is detected on an appropriately enabled pin, then the status flag for that pin will be set, and an interrupt will be generated if the iocie bit is set. the iocif bit of the intcon register reflects the status of all iocbfx bits. 7.4 clearing interrupt flags the individual status flags, (iocbfx bits), can be cleared by resetting them to zero. if another edge is detected during this clearing operation, the associated status flag will be set at the end of the sequence, regardless of the value actually being written. in order to ensure that no detected edge is lost while clearing flags, only and operations masking out known changed bits should be performed. the following sequence is an example of what should be performed. example 7-1: 7.5 operation in sleep the interrupt-on-change interrupt sequence will wake the device from sleep mode, if the iocie bit is set. if an edge is detected while in sleep mode, the iocbf register will be updated prior to the first instruction executed out of sleep. movlw 0xff xorwf iocbf, w andwf iocbf, f
pic16f193x/lf193x ds41364c-page 106 preliminary ? 2009 microchip technology inc. register 7-1: iocbp: interrupt-on- change positive edge register r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 iocbp7 iocbp6 iocbp5 iocbp4 iocbp3 iocbp2 iocbp1 iocbp0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 iocbp<7:0>: interrupt-on-change positive edge enable bits 1 = interrupt-on-change enabled on the pin for a positive going edge. associated status bit and interrupt flag will be set upon detecting an edge. 0 = interrupt-on-change disabled for the associated pin. register 7-2: iocbn: interrupt-on-change negative edge register r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 iocbn7 iocbn6 iocbn5 iocbn4 iocbn3 iocbn2 iocbn1 iocbn0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 iocbn<7:0>: interrupt-on-change negative edge enable bits 1 = interrupt-on-change enabled on the pin for a negative going edge. associated status bit and interrupt flag will be set upon detecting an edge. 0 = interrupt-on-change disabled for the associated pin. register 7-3: iocbf: interrupt-on-change flag register r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 iocbf7 iocbf6 iocbf5 iocbf4 iocbf3 iocbf2 iocbf1 iocbf0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 iocbf<7:0>: interrupt-on-change flag bits 1 = an enabled change was detected on the associated pin. set when iocbpx = 1 and a rising edge was detected on rbx, or when iocbnx = 1 and a falling edge was detected on rbx. 0 = no change was detected, or the user cleared the detected change.
? 2009 microchip technology inc. preliminary ds41364c-page 107 pic16f193x/lf193x figure 7-1: interrupt-on -change block diagram table 7-1: summary of registers as sociated with interrupt-on-change name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 93 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 iocbf iocbf7 iocbf6 iocbf5 iocbf4 iocbf3 iocbf2 iocbf1 iocbf0 106 iocbn iocbn7 iocbn6 iocbn5 iocbn4 iocbn3 iocbn2 iocbn1 iocbn0 106 iocbp iocbp7 iocbp6 iocbp5 ioc bp4 iocbp3 iocbp2 iocbp1 iocbp0 106 trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 93 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by interrupt-on-change. rbx from all other iocbfx individual pin detectors dq ck r dq ck r iocbnx iocbpx q2 clock cycle iocie ioc interrupt to cpu core iocbfx
pic16f193x/lf193x ds41364c-page 108 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 109 pic16f193x/lf193x 8.0 oscillator module (with fail-safe clock monitor) 8.1 overview the oscillator module has a wide variety of clock sources and selection features that allow it to be used in a wide range of applications while maximizing perfor- mance and minimizing power consumption. figure 8-1 illustrates a block diagram of the oscillator module. clock sources can be configured from external oscillators, quartz crystal resonators, ceramic resonators and resistor-capacitor (rc) circuits. in addition, the system clock source can be configured from one of three internal oscillators, with a choice of speeds selectable via software. additional clock features include: ? selectable system clock source between external or internal via software. ? two-speed start-up mode, which minimizes latency between external oscillator start-up and code execution. ? fail-safe clock monitor (fscm) designed to detect a failure of the external clock source (lp, xt, hs, ec or rc modes) and switch automatically to the internal oscillator. the oscillator module can be configured in one of six clock modes. 1. ec ? external clock. 2. lp ? 32 khz low-power crystal mode. 3. xt ? medium gain crystal or ceramic resonator oscillator mode. 4. hs ? high gain crystal or ceramic resonator mode. 5. rc ? external resistor-capacitor (rc). 6. intosc ? internal oscillator. clock source modes are configured by the fosc<2:0> bits in the configuration word register 1 (config1). the internal clock can be generated from two internal oscillators. the hfintosc is a calibrated high-frequency oscillator. the mfintosc is a calibrated medium-frequency oscillator. the lfintosc is an uncalibrated low-frequency oscillator. figure 8-1: simplified pic ? mcu clock source block diagram 4 x pll fosc<2:0> oscillator t1oscen enable oscillator t1oso t1osi clock source option for other modules osc1 osc2 sleep lp, xt, hs, rc, ec t1osc cpu and postscaler mux mux 16 mhz 8 mhz 4 mhz 2 mhz 1 mhz 250 khz 500 khz ircf<3:0> 31 khz 31 khz source internal oscillator block wdt, pwrt, fail-safe clock monitor 16 mhz internal oscillator (hfintosc) clock control scs<1:0> source 16 mhz 31 khz (lfintosc) two-speed start-up and other modules oscillator 500 khz source 500 khz (mfintosc) 125 khz 31.25 khz 62.5 khz fosc<2:0> = 100 peripherals sleep external timer1
pic16f193x/lf193x ds41364c-page 110 preliminary ? 2009 microchip technology inc. 8.2 oscillator control the oscillator control (osccon) register (figure 8-1) controls the system clock and frequency selection options. the osccon register contains the following bits: ? frequency selection bits (ircf) ? system clock select bits (scs) ? software pll enable bit (spllen) register 8-1: osccon: os cillator control register r/w-0/0 r/w-0/0 r/w-1/1 r/w-1/1 r/w-1/1 u-0 r/w-0/0 r/w-0/0 spllen ircf3 ircf2 ircf1 ircf0 ? scs1 scs0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 spllen: software pll enable bit if pllen = 1 : spllen bit is ignored. 4x pll is always enabled (subject to oscillator requirements) if pllen = 0 : 1 = 4x pll is enabled 0 = 4x pll is disabled bit 6-3 ircf<3:0>: internal oscillator frequency select bits 000x =31khz lf 0010 = 31.25 khz mf 0011 = 31.25 khz hf (2) 0100 = 62.5 khz mf 0101 = 125 khz mf 0110 = 250 khz mf 0111 = 500 khz mf (default upon reset) 1000 = 125 khz hf (2) 1001 = 250 khz hf (2) 1010 = 500 khz hf (2) 1011 =1mhz hf 1100 =2mhz hf 1101 =4mhz hf 1110 =8mhz hf 1111 = 16 mhz hf bit 2 unimplemented: read as ? 0 ? bit 1-0 scs<1:0>: system clock select bits 1x = internal oscillator block 01 = timer1 oscillator 00 = clock determined by config1[fosc<2:0>]. note 1: reset state depends on state of the ieso configuration bit. 2: duplicate frequency derived from hfintosc.
? 2009 microchip technology inc. preliminary ds41364c-page 111 pic16f193x/lf193x 8.3 clock source modes clock source modes can be classified as external or internal. ? external clock modes rely on external circuitry for the clock source. examples are: oscillator mod- ules (ec mode), quartz crystal resonators or ceramic resonators (lp, xt and hs modes) and resistor-capacitor (rc) mode circuits. ? internal clock sources are contained internally within the oscillator module. the oscillator module has two internal oscillators: the 16 mhz high-frequency internal oscillator (hfintosc), 500 khz (mfintosc) and the 31 khz low-frequency internal oscillator (lfintosc). the system clock can be selected between external or internal clock sources via the system clock select (scs) bit of the osccon register. see section 8.6 ?clock switching? for additional information. when switching between clock sources, a delay is required to allow the new clock to stabilize. these oscillator delays are shown in table 8-1. 8.4 external clock modes 8.4.1 oscillator start-up timer (ost) if the oscillator module is configured for lp, xt or hs modes, the oscillator start-up timer (ost) counts 1024 oscillations from osc1. this occurs following a power-on reset (por) and when the power-up timer (pwrt) has expired (if configured), or a wake-up from sleep. during this time, the program counter does not increment and program execution is suspended. the ost ensures that the oscillator circuit, using a quartz crystal resonator or ceramic resonator, has started and is providing a stable system clock to the oscillator module. in order to minimize latency between external oscillator start-up and code execution, the two-speed clock start-up mode can be selected (see section 8.6.3 ?timer1 oscillator ready (t1oscr) bit? ). table 8-1: oscillator switching delays 8.4.2 ec mode the external clock (ec) mode allows an externally generated logic level as the system clock source. when operating in this mode, an external clock source is connected to the osc1 input. osc2/clkout is available for general purpose i/o or clkout. figure 8-2 shows the pin connections for ec mode. the oscillator start-up timer (ost) is disabled when ec mode is selected. therefore, there is no delay in operation after a power-on reset (por) or wake-up from sleep. because the pic ? mcu design is fully static, stopping the external clock input will have the effect of halting the device while leaving all data intact. upon restarting the external clock, the device will resume operation as if no time had elapsed. figure 8-2: external clock (ec) mode operation switch from switch to frequency oscillator delay sleep/por lfintosc (1) mfintosc (1) hfintosc (1) 31 khz 31.25 khz-500 khz 31.25khz-16mhz oscillator warm-up delay (t warm ) sleep/por ec, rc (1) dc ? 32 mhz 2 cycles lfintosc ec, rc (1) dc ? 32 mhz 1 cycle of each sleep/por timer1 oscillator lp, xt, hs (1) 32 khz-20 mhz 1024 clock cycles (ost) any clock source mfintosc (1) hfintosc (1) 31.25 khz-500 khz 31.25khz-16mhz 2 s (approx.) any clock source lfintosc (1) 31 khz 1 cycle of each any clock source timer1 oscillator 32 khz 1024 clock cycles (ost) pll inactive pll active 16-32 mhz 2 ms (approx.) note 1: pll inactive. osc1/clkin osc2/clkout (1) clock from ext. system pic ? mcu f osc /4 or i/o (1) note 1: output depends upon clkouten bit of the configuration word 1.
pic16f193x/lf193x ds41364c-page 112 preliminary ? 2009 microchip technology inc. 8.4.3 lp, xt, hs modes the lp, xt and hs modes support the use of quartz crystal resonators or ceramic resonators connected to osc1 and osc2 (figure 8-3). the mode selects a low, medium or high gain setting of the internal inverter-amplifier to support various resonator types and speed. lp oscillator mode selects the lowest gain setting of the internal inverter-amplifier. lp mode current consumption is the least of the three modes. this mode is designed to drive only 32.768 khz tuning-fork type crystals (watch crystals). xt oscillator mode selects the intermediate gain setting of the internal inverter-amplifier. xt mode current consumption is the medium of the three modes. this mode is best suited to drive resonators with a medium drive level specification. hs oscillator mode selects the highest gain setting of the internal inverter-amplifier. hs mode current consumption is the highest of the three modes. this mode is best suited for resonators that require a high drive setting. figure 8-3 and figure 8-4 show typical circuits for quartz crystal and ceramic resonators, respectively. figure 8-3: quartz crystal operation (lp, xt or hs mode) figure 8-4: ceramic resonator operation (xt or hs mode) note 1: a series resistor (r s ) may be required for quartz crystals with low drive level. 2: the value of r f varies with the oscillator mode selected (typically between 2 m to 10 m ) . c1 c2 quartz r s (1) osc1/clkin r f (2) sleep to internal logic pic ? mcu crystal osc2/clkout note 1: quartz crystal characteristics vary according to type, package and manufacturer. the user should consult the manufacturer data sheets for specifications and recommended application. 2: always verify oscillator performance over the v dd and temperature range that is expected for the application. 3: for oscillator design assistance, reference the following microchip applications notes: ? an826, ? crystal oscillator basics and crystal selection for rfpic ? and pic ? devices ? (ds00826) ? an849, ? basic pic ? oscillator design ? (ds00849) ? an943, ? practical pic ? oscillator analysis and design ? (ds00943) ? an949, ? making your oscillator work ? (ds00949) note 1: a series resistor (r s ) may be required for ceramic resonators with low drive level. 2: the value of r f varies with the oscillator mode selected (typically between 2 m to 10 m ) . 3: an additional parallel feedback resistor (r p ) may be required for proper ceramic resonator operation. c1 c2 ceramic r s (1) osc1/clkin r f (2) sleep to internal logic pic ? mcu r p (3) resonator osc2/clkout
? 2009 microchip technology inc. preliminary ds41364c-page 113 pic16f193x/lf193x 8.4.4 external rc mode the external resistor-capacitor (rc) modes support the use of an external rc circuit. this allows the designer maximum flexibility in frequency choice while keeping costs to a minimum when clock accuracy is not required. the rc circuit connects to osc1. osc2/clkout is available for general purpose i/o or clkout. figure 8-5 shows the external rc mode connections. figure 8-5: external rc modes the rc oscillator frequency is a function of the supply voltage, the resistor (r ext ) and capacitor (c ext ) values and the operating temperature. other factors affecting the oscillator frequency are: ? threshold voltage variation ? component tolerances ? packaging variations in capacitance the user also needs to take into account variation due to tolerance of external rc components used. 8.5 internal clock modes the oscillator module has three independent, internal oscillators that can be configured or selected as the system clock source. 1. the hfintosc (high-frequency internal oscillator) is factory calibrated and operates at 16 mhz. the frequency of the hfintosc can be user-adjusted via software using the osctune register (register 8-3). 2. the mfintosc (medium-frequency internal oscillator) is factory calibrated and operates at 500 khz. the frequency of the mfintosc can be user-adjusted via software using the osctune register (register 8-3). 3. the lfintosc (low-frequency internal oscillator) is uncalibrated and operates at 31 khz. the system clock speed can be selected via software using the internal oscillator frequency select bits ircf<2:0> of the osccon register. the system clock can be selected between external or internal clock sources via the system clock selection (scs) bits of the osccon register. see section 8.6 ?clock switching? for more information. 8.5.1 intosc mode the intosc mode configures the internal oscillators as the system clock source when the device is programmed using the oscillator selection or the fosc<2:0> bits in the configuration word register 1 (config1). in intosc mode, osc1/clkin is available for general purpose i/o. osc2/clkout is available for general purpose i/o or clkout. osc2/clkout c ext r ext pic ? mcu osc1/clkin f osc /4 or internal clock v dd v ss recommended values: 10 k r ext 100 k , <3v 3 k r ext 100 k , 3-5v c ext > 20 pf, 2-5v note 1: output depends upon clkouten bit of the configuration word 1. i/o (1)
pic16f193x/lf193x ds41364c-page 114 preliminary ? 2009 microchip technology inc. 8.5.2 hfintosc the high-frequency internal oscillator (hfintosc) is a factory calibrated 16 mhz internal clock source. the frequency of the hfintosc can be altered via software using the osctune register (register 8-3). the output of the hfintosc connects to a postscaler and multiplexer (see figure 8-1). one of nine frequencies derived from the hfintosc can be selected via software using the ircf<3:0> bits of the osccon register. see section 8.5.7 ?frequency select bits (ircf)? for more information. the hfintosc is enabled by: ? configure the ircf<3:0> bits for the desired hf frequency (see register 8-1), and ?fosc<2:0> = 100 , or ? set the system clock source (scs) bits of the osccon register to ? 1x ? the high frequency internal oscillator ready bit (hfiofr) of the oscstat register indicates when the hfintosc is running and can be utilized. the high frequency internal oscillator status locked bit (hfiofl) of the oscstat register indicates when the hfintosc is running within 2% of its final value. the high frequency internal oscillator status stable bit (hfiofs) of the oscstat register indicates when the hfintosc is running within 0.5% of its final value. 8.5.3 mfintosc the medium-frequency internal oscillator (mfintosc) is a factory calibrated 500 khz internal clock source. the frequency of the mfintosc can be altered via software using the osctune register (register 8-3). the output of the mfintosc connects to a postscaler and multiplexer (see figure 8-1). one of nine frequencies derived from the mfintosc can be selected via software using the ircf<3:0> bits of the osccon register. see section 8.5.7 ?frequency select bits (ircf)? for more information. the mfintosc is enabled by: ? configure the ircf<3:0> bits for the desired hf frequency (see register 8-1), and ?fosc<2:0> = 100 , or ? set the system clock source (scs) bits of the osccon register to ? 1x ? the medium frequency internal oscillator ready bit (mfiofr) of the oscstat register indicates when the mfintosc is running and can be utilized. 8.5.4 lfintosc the low-frequency internal oscillator (lfintosc) is an uncalibrated 31 khz internal clock source. the output of the lfintosc connects to a postscaler and multiplexer (see figure 8-1). select 31 khz, via software, using the ircf<2:0> bits of the osccon register. see section 8.5.7 ?frequency select bits (ircf)? for more information. the lfintosc is also the frequency for the power-up timer (pwrt), watchdog timer (wdt) and fail-safe clock monitor (fscm). the lfintosc is enabled by selecting 31 khz (ircf<3:0> bits of the osccon register = 000) as the system clock source (scs bits of the osccon register = 1x ), or when any of the following are enabled: ? configure the ircf<3:0> bits for the desired lf frequency (see register 8-1), and ?fosc<2:0> = 100 , or ? set the system clock source (scs) bits of the osccon register to ? 1x ? peripherals that use the lfintosc are: ?lcd ? power-up timer (pwrt) ? watchdog timer (wdt) ? fail-safe clock monitor (fscm) the low frequency internal oscillator ready bit (lfiofr) of the oscstat register indicates when the lfintosc is running and can be utilized.
? 2009 microchip technology inc. preliminary ds41364c-page 115 pic16f193x/lf193x 8.5.5 oscstat register the oscstat register contains flags that represent the current status of the oscillators module. register 8-2: oscstat: oscillator status register r-0/q r-0/q r-q/q r-0/q r-0/q r-q/q r-0/0 r-0/q t1oscr pllr osts hfiofr hfiofl mfiofr lfiofr hfiofs bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 t1oscr: timer1 oscillator ready bit if the timer1 oscillator is enabled (t1oscen = 1 ) 1 = timer1 oscillator is ready and can be switched to 0 = timer1 oscillator is not ready else timer1 oscillator is disabled - clock source is t1cki 1 = timer1 oscillator is always ready bit 6 pllr 4x pll ready bit 1 = 4x pll is ready and can be switched to 0 = 4x pll oscillator is not ready bit 5 osts: oscillator start-up time-out status bit 1 = device running from the clock defined by fosc<3:0> of the config1 register 0 = device running from the internal osci llator (hfintosc, mfintosc or lfintosc) bit 4 hfiofr: high frequency internal oscillator ready bit 1 = 16 mhz internal oscillator (hfintosc) is ready and can be switched to 0 = 16 mhz internal oscillator (hfintosc) is not ready bit 3 hfiofl: high frequency internal oscillator status locked bit (2% stable) 1 = 16 mhz internal oscillator (hfintosc) is in lock 0 = 16 mhz internal oscillator (hfintosc) has not yet locked bit 2 mfiofr: medium frequency internal oscillator (500 khz hfintosc output) ready bit 1 = 500 khz internal oscillator (mfintosc) is ready and can be switched to 0 = 500 khz internal oscillator (mfintosc) is not ready bit 1 lfiofr: low frequency internal oscillator ready bit 1 = 31 khz internal oscillator (lfintosc) is ready and can be switched to 0 = 31 khz internal oscillator (lfintosc) is not ready bit 0 hfiofs: high frequency internal oscillator stable bit (0.5% stable) 1 = 16 mhz internal oscillator (hfintosc) is in communications stable 0 = 16 mhz internal oscillator (hfintosc) is not yet communications stable
pic16f193x/lf193x ds41364c-page 116 preliminary ? 2009 microchip technology inc. 8.5.6 osctune register the hfintosc and mfintosc are factory calibrated but can be adjusted in software by writing to the osctune register (register 8-3). the default value of the osctune register is ? 0 ?. the value is a 5-bit two?s complement number. when the osctune register is modified, the oscillator frequency will begin shifting to the new frequency. code execution continues during this shift. there is no indication that the shift has occurred. the osctune register applies the same adjustment to both the hfintosc and the mfintosc simultaneously. osctune does not affect the lfintosc frequency. operation of features that depend on the lfintosc clock source frequency, such as the power-up timer (pwrt), watchdog timer (wdt), fail-safe clock monitor (fscm) and peripherals, are not affected by the change in frequency. register 8-3: osctune: osci llator tuning register u-0 u-0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 ? ? tun5 tun4 tun3 tun2 tun1 tun0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-6 unimplemented: read as ? 0 ? bit 5-0 tun<4:0>: frequency tuning bits 011111 = maximum frequency 011110 = ? ? ? 000001 = 000000 = oscillator module is running at the factory-calibrated frequency. 111111 = ? ? ? 100000 = minimum frequency
? 2009 microchip technology inc. preliminary ds41364c-page 117 pic16f193x/lf193x 8.5.7 frequency select bits (ircf) the output of the 16 mhz hfintosc and 31 khz lfintosc connects to a postscaler and multiplexer (see figure 8-1). the internal oscillator frequency select bits ircf<2:0> of the osccon register select the frequency output of the internal oscillators. one of eight frequencies can be selected via software: ?16 mhz ?8 mhz ?4 mhz ?2 mhz ?1 mhz ? 500 khz (default after reset) ? 250 khz ? 125 khz ? 31 khz (lfintosc) 8.5.8 internal oscillator clock switch timing when switching between the hfintosc, mfintosc and the lfintosc, the new oscillator may already be shut down to save power (see figure 8-6). if this is the case, there is a delay after the ircf<3:0> bits of the osccon register are modified before the frequency selection takes place. the oscstat register will reflect the current active status of the hfintosc, mfintosc and lfintosc oscillators. the sequence of a frequency selection is as follows: 1. ircf<3:0> bits of the osccon register are modified. 2. if the new clock is shut down, a clock start-up delay is started. 3. clock switch circuitry waits for a falling edge of the current clock. 4. the current clock is held low and the clock switch circuitry waits for a rising edge in the new clock. 5. the new clock is now active. 6. the oscstat register is updated as required. 7. clock switch is complete. see figure 8-6 for more details. if the internal oscillator speed is switched between two clocks of the same source, there is no start-up delay before the new frequency is selected. clock switching time delays are shown in table 8-1. start-up delay specifications are located in the oscillator tables of section 28.0 ?electrical specifications? . note: following any reset, the ircf<2:0> bits of the osccon register are set to ? 110 ? and the frequency selection is set to 4 mhz. the user can modify the ircf bits to select a different frequency.
pic16f193x/lf193x ds41364c-page 118 preliminary ? 2009 microchip technology inc. figure 8-6: internal oscillator switch timing hfintosc/ lfintosc ircf <3:0> system clock hfintosc/ lfintosc ircf <3:0> system clock 0 = 0 0 = 0 start-up time 2-cycle sync running 2-cycle sync running hfintosc/ lfintosc (fscm and wdt disabled) hfintosc/ lfintosc (either fscm or wdt enabled) lfintosc hfintosc/ ircf <3:0> system clock = 0 0 start-up time 2-cycle sync running lfintosc hfintosc/mfintosc lfintosc turns off unless wdt or fscm is enabled mfintosc mfintosc mfintosc mfintosc mfintosc
? 2009 microchip technology inc. preliminary ds41364c-page 119 pic16f193x/lf193x 8.6 clock switching the system clock source can be switched between external and internal clock sources via software using the system clock select (scs) bits of the osccon register. 8.6.1 system clock select (scs) bit the system clock select (scs) bits of the osccon register selects the system clock source that is used for the cpu and peripherals. ? when the scs bits of the osccon register = 00 , the system clock source is determined by configuration of the fosc<2:0> bits in the configuration word register 1 (config1). ? when the scs bits of the osccon register = 01 , the system clock source is the timer1 oscillator. ? when the scs bits of the osccon register = 1x , the system clock source is chosen by the internal oscillator frequency selected by the ircf<3:0> bits of the osccon register. after a reset, the scs bit of the osccon register is always cleared. 8.6.2 oscillator start-up time-out status (osts) bit the oscillator start-up time-out status (osts) bit of the oscstat register indicates whether the system clock is running from the external clock source, as defined by the fosc<2:0> bits in the configuration word register 1 (config1), or from the internal clock source. in particular, osts indicates that the oscillator start-up timer (ost) has timed out for lp, xt or hs modes. 8.6.3 timer1 oscillator ready (t1oscr) bit the timer1 oscillator ready (t1oscr) bit of the oscstat register indicates whether the timer1 oscillator is ready to be used. after the t1oscr bit is set, the scs bits can be configured to select the timer1 oscillator. 8.7 two-speed clock start-up mode two-speed start-up mode provides additional power savings by minimizing the latency between external oscillator start-up and code execution. in applications that make heavy use of the sleep mode, two-speed start-up will remove the external oscillator start-up time from the time spent awake and can reduce the overall power consumption of the device. this mode allows the application to wake-up from sleep, perform a few instructions using the intosc as the clock source and go back to sleep without waiting for the external oscillator to become stable. when the oscillator module is configured for lp, xt or hs modes, the oscillator start-up timer (ost) is enabled (see section 8.4.1 ?oscillator start-up timer (ost)? ). the ost will suspend program execu- tion until 1024 oscillations are counted. two-speed start-up mode minimizes the delay in code execution by operating from the internal oscillator as the ost is counting. when the ost count reaches 1024 and the osts bit of the oscstat register is set, program exe- cution switches to the external oscillator. 8.7.1 two-speed start-up mode configuration two-speed start-up mode is configured by the following settings: ? ieso (of the configuration word register 1) = 1 ; internal/external switchover bit (two-speed start-up mode enabled). ? scs (of the osccon register) = 00 . ? fosc<2:0> bits in the configuration word register 1 (config1) configured for lp, xt or hs mode. two-speed start-up mode is entered after: ? power-on reset (por) and, if enabled, after power-up timer (pwrt) has expired, or ? wake-up from sleep. if the external clock oscillator is configured to be anything other than lp, xt or hs mode, then two-speed start-up is disabled. this is because the external clock oscillator does not require any stabilization time after por or an exit from sleep. note: any automatic clock switch, which may occur from two-speed start-up or fail-safe clock monitor, does not update the scs bits of the osccon register. the user can monitor the osts bit of the oscstat register to determine the current system clock source. note: executing a sleep instruction will abort the oscillator start-up time and will cause the osts bit of the oscstat register to remain clear.
pic16f193x/lf193x ds41364c-page 120 preliminary ? 2009 microchip technology inc. 8.7.2 two-speed start-up sequence 1. wake-up from power-on reset or sleep. 2. instructions begin execution by the internal oscillator at the frequency set in the ircf<3:0> bits of the osccon register. 3. ost enabled to count 1024 clock cycles. 4. ost timed out, wait for falling edge of the internal oscillator. 5. osts is set. 6. system clock held low until the next falling edge of new clock (lp, xt or hs mode). 7. system clock is switched to external clock source. 8.7.3 checking two-speed clock status checking the state of the osts bit of the oscstat register will confirm if the microcontroller is running from the external clock source, as defined by the fosc<2:0> bits in the configuration word register 1 (config1), or the internal oscillator. figure 8-7: two-speed start-up 0 1 1022 1023 pc + 1 t ost t intosc osc1 osc2 program counter system clock pc - n pc
? 2009 microchip technology inc. preliminary ds41364c-page 121 pic16f193x/lf193x 8.8 fail-safe clock monitor the fail-safe clock monitor (fscm) allows the device to continue operating should the external oscillator fail. the fscm can detect oscillator failure any time after the oscillator start-up timer (ost) has expired. the fscm is enabled by setting the fcmen bit in the configuration word register 1 (config1). the fscm is applicable to all external oscillator modes (lp, xt, hs, ec, timer1 oscillator and rc). figure 8-8: fscm block diagram 8.8.1 fail-safe detection the fscm module detects a failed oscillator by comparing the external oscillator to the fscm sample clock. the sample clock is generated by dividing the lfintosc by 64. see figure 8-8. inside the fail detector block is a latch. the external clock sets the latch on each falling edge of the external clock. the sample clock clears the latch on each rising edge of the sample clock. a failure is detected when an entire half-cycle of the sample clock elapses before the external clock goes low. 8.8.2 fail-safe operation when the external clock fails, the fscm switches the device clock to an internal clock source and sets the bit flag osfif of the pir2 register. setting this flag will generate an interrupt if the osfie bit of the pie2 register is also set. the device firmware can then take steps to mitigate the problems that may arise from a failed clock. the system clock will continue to be sourced from the internal clock source until the device firmware successfully restarts the external oscillator and switches back to external operation. the internal clock source chosen by the fscm is determined by the ircf<3:0> bits of the osccon register. this allows the internal oscillator to be configured before a failure occurs. 8.8.3 fail-safe condition clearing the fail-safe condition is cleared after a reset, executing a sleep instruction or changing the scs bits of the osccon register. when the scs bits are changed, the ost is restarted. while the ost is running, the device continues to operate from the intosc selected in osccon. when the ost times out, the fail-safe condition is cleared and the device will be operating from the external clock source. the fail-safe condition must be cleared before the osfif flag can be cleared. 8.8.4 reset or wake-up from sleep the fscm is designed to detect an oscillator failure after the oscillator start-up timer (ost) has expired. the ost is used after waking up from sleep and after any type of reset. the ost is not used with the ec or rc clock modes so that the fscm will be active as soon as the reset or wake-up has completed. when the fscm is enabled, the two-speed start-up is also enabled. therefore, the device will always be executing code while the ost is operating. external lfintosc 64 s r q 31 khz (~32 s) 488 hz (~2 ms) clock monitor latch clock failure detected oscillator clock q sample clock note: due to the wide range of oscillator start-up times, the fail-safe circuit is not active during oscillator start-up (i.e., after exiting reset or sleep). after an appropriate amount of time, the user should check the status bits in the oscstat register to verify the oscillator start-up and that the system clock switchover has successfully completed.
pic16f193x/lf193x ds41364c-page 122 preliminary ? 2009 microchip technology inc. figure 8-9: fscm timing diagram table 8-2: summary of registers asso ciated with clock sources oscfif system clock output sample clock failure detected oscillator failure note: the system clock is normally at a much higher frequency than the sample clock. the relative frequencies in this example have been chosen for clarity. (q) te s t test test clock monitor output name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page config1 (2) cpd cp mclre pwrte wdte fosc2 fosc1 fosc0 128 osccon spllen ircf3 ircf2 ircf1 ircf0 ? scs1 scs0 110 oscstat t1oscr pllr osts hfiofr hfiofl mfiofr lfiofr hfiofs 115 osctune ? ? tun5 tun4 tun3 tun2 tun1 tun0 116 pie2 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie 77 pir2 osfif c2if c1if eeif bclif lcdif ? ccp2if 80 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ? tmr1on 171 legend: x = unknown, u = unchanged, ? = unimplemented locations read as ? 0 ?. shaded cells are not used by oscillators. note 1: other (non power-up) resets include mclr reset and watchdog timer reset during normal operation. 2: see configuration word register 1 (register 10-1) for operation of all register bits.
? 2009 microchip technology inc. preliminary ds41364c-page 123 pic16f193x/lf193x 9.0 sr latch the module consists of a single sr latch with multiple set and reset inputs as well as separate latch outputs. the sr latch module includes the following features: ? programmable input selection ? sr latch output is available internally/externally ? separate q and q outputs ? firmware set and reset 9.1 latch operation the latch is a set-reset latch that does not depend on a clock source. each of the set and reset inputs are active-high. the latch can be set or reset by cxout, sri pin, or variable clock. additionally the srps and the srpr bits of the srcon0 register may be used to set or reset the sr latch, respectively. the latch is reset-dominant, therefore, if both set and reset inputs are high the latch will go to the reset state. both the srps and srpr bits are self resetting which means that a single write to either of the bits is all that is necessary to complete a latch set or reset operation. 9.2 latch output the srqen and srnqen bits of the srcon0 regis- ter control the q and q latch outputs. both of the sr latch outputs may be directly output to an i/o pin at the same time. the applicable tris bit of the corresponding port must be cleared to enable the port pin output driver. 9.3 effects of a reset upon any device reset, the sr latch is not initialized. the user?s firmware is responsible to initialize the latch output before enabling it to the output pins. figure 9-1: sr latch simplified block diagram srps s r q q note 1: if r = 1 and s = 1 simultaneously, q = 0 , q = 1 2: pulse generator causes a 1 q-state pulse width. 3: name denotes the connection point at the comparator output. pulse gen ( 2 ) sr latch (1) srqen srspe srsc2e srscke srclk syncc2out (3) srsc1e syncc1out (3) srpr pulse gen ( 2 ) srrpe srrc2e srrcke srclk syncc2out (3) srrc1e syncc1out (3) srlen srnqen srlen srq srnq sri sri
pic16f193x/lf193x ds41364c-page 124 preliminary ? 2009 microchip technology inc. table 9-1: srclk frequency table srclk divider f osc = 32 mhz f osc = 20 mhz f osc = 16 mhz f osc = 4 mhz f osc = 1 mhz 111 512 62.5 khz 39.0 khz 31.3 khz 7.81 khz 1.95 khz 110 256 125 khz 78.1 khz 62.5 khz 15.6 khz 3.90 khz 101 128 250 khz 156 khz 125 khz 31.25 khz 7.81 khz 100 64 500 khz 313 khz 250 khz 62.5 khz 15.6 khz 011 32 1 mhz 625 khz 500 khz 125 khz 31.3 khz 010 16 2 mhz 1.25 mhz 1 mhz 250 khz 62.5 khz 001 8 4 mhz 2.5 mhz 2 mhz 500 khz 125 khz 000 4 8 mhz 5 mhz 4 mhz 1 mhz 250 khz register 9-1: srcon0: sr latch control 0 register r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/s-0/0 r/s-0/0 srlen srclk2 srclk1 srclk0 srqen srnqen srps srpr bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared s = bit is set only - bit 7 srlen: sr latch enable bit 1 = sr latch is enabled 0 = sr latch is disabled bit 6-4 srclk<2:0>: sr latch clock divider bits 000 = generates a 1 f osc wide pulse every 4th f osc cycle clock 001 = generates a 1 f osc wide pulse every 8th f osc cycle clock 010 = generates a 1 f osc wide pulse every 16th f osc cycle clock 011 = generates a 1 f osc wide pulse every 32th f osc cycle clock 100 = generates a 1 f osc wide pulse every 64th f osc cycle clock 101 = generates a 1 f osc wide pulse every 128th f osc cycle clock 110 = generates a 1 f osc wide pulse every 256th f osc cycle clock 111 = generates a 1 f osc wide pulse every 512th f osc cycle clock bit 3 srqen: sr latch q output enable bit if srlen = 1 : 1 = q is present on the srq pin 0 = q is internal only if srlen = 0 : sr latch is disabled bit 2 srnqen: sr latch q output enable bit if srlen = 1 : 1 =q is present on the srnq pin 0 =q is internal only if srlen = 0 : sr latch is disabled bit 1 srps: pulse set input of the sr latch bit 1 = pulse input for 1 q-clock period 0 = do not generate pulse. always reads back ? 0 ?. bit 0 srpr: pulse reset input of the sr latch bit 1 = pulse input for 1 q-clock period 0 = do not generate pulse. always reads back ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 125 pic16f193x/lf193x register 9-2: srcon1: sr latch control 1 register r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 srspe srscke srsc2e srsc1e srrpe srrcke srrc2e srrc1e bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 srspe: sr latch peripheral set enable bit 1 = sri pin status sets sr latch 0 = sri pin status has no effect on sr latch bit 6 srscke: sr latch set clock enable bit 1 = set input of sr latch is pulsed with srclk 0 = set input of sr latch is not pulsed with srclk bit 5 srsc2e: sr latch c2 set enable bit 1 = c2 comparator output sets sr latch 0 = c2 comparator output has no effect on sr latch bit 4 srsc1e: sr latch c1 set enable bit 1 = c1 comparator output sets sr latch 0 = c1 comparator output has no effect on sr latch bit 3 srrpe: sr latch peripheral reset enable bit 1 = sri pin resets sr latch 0 = sri pin has no effect on sr latch bit 2 srrcke: sr latch reset clock enable bit 1 = reset input of sr latch is pulsed with srclk 0 = reset input of sr latch is not pulsed with srclk bit 1 srrc2e: sr latch c2 reset enable bit 1 = c2 comparator output resets sr latch 0 = c2 comparator output has no effect on sr latch bit 0 srrc1e: sr latch c1 reset enable bit 1 = c1 comparator output resets sr latch 0 = c1 comparator output has no effect on sr latch
pic16f193x/lf193x ds41364c-page 126 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 127 pic16f193x/lf193x 10.0 device configuration device configuration consists of configuration word 1 and configuration word 2 registers, code protection and device id. 10.1 configuration words there are several configuration word bits that allow different oscillator and memory protection options. these are implemented as configuration word 1 register at 8007h and configuration word 2 register at 8008h.
pic16f193x/lf193x ds41364c-page 128 preliminary ? 2009 microchip technology inc. register 10-1: co nfiguration word 1 r/p-1/1 r/p-1/1 r/p-1/1 r/p-1/1 r/p-1/1 r/p-1/1 r/p-1/1 fcmen ieso clkouten boren1 boren0 cpd cp bit 13 bit 7 r/p-1/1 r/p-1/1 r/p-1/1 r/p-1/1 r/p-1/1 r/p-1/1 r/p-1/1 mclre pwrte wdte1 wdte0 fosc2 fosc1 fosc0 bit 6 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 13 fcmen: fail-safe clock monitor enable bit 1 = fail-safe clock monitor is enabled 0 = fail-safe clock monitor is disabled bit 12 ieso: internal external switchover bit 1 = internal/external switchover mode is enabled 0 = internal/external switchover mode is disabled bit 11 clkouten : clock out enable bit 1 = clkout function is disabled. i/o or oscillator function on ra6/clkout 0 = clkout function is enabled on ra6/clkout bit 10-9 boren<1:0>: brown-out reset enable bits (1) 11 = bor enabled 10 = bor enabled during operation and disabled in sleep 01 = bor controlled by sboren bit of the pcon register 00 = bor disabled bit 8 cpd : data code protection bit (2) 1 = data memory code protection is disabled 0 = data memory code protection is enabled bit 7 cp : code protection bit (3) 1 = program memory code protection is disabled 0 = program memory code protection is enabled bit 6 mclre: re3/mclr /v pp pin function select bit if lvp bit = 1 : this bit is ignored. if lvp bit = 0 : 1 =re3/mclr /v pp pin function is mclr ; weak pull-up enabled. 0 = re3/mclr /v pp pin function is digital input; mclr internally disabled; weak pull-up under control of wpue3 bit.. bit 5 pwrte : power-up timer enable bit (1) 1 = pwrt disabled 0 = pwrt enabled bit 4-3 wdte<1:0>: watchdog timer enable bit 11 = wdt enabled 10 = wdt enabled while running and disabled in sleep 01 = wdt controlled by the swdten bit in the wdtcon register 00 = wdt disabled note 1: enabling brown-out reset does not automatically enable power-up timer. 2: the entire data eeprom will be erased when the c ode protection is tur ned off during an erase. 3: the entire program memory will be erased when the code protection is turned off.
? 2009 microchip technology inc. preliminary ds41364c-page 129 pic16f193x/lf193x bit 2-0 fosc<2:0>: oscillator selection bits 111 = ech: external clock, high-power mode: clkin on ra7/osc1/clkin 110 = ecm: external clock, medium-power mode: clkin on ra7/osc1/clkin 101 = ecl: external clock, low-power mode: clkin on ra7/osc1/clkin 100 = intosc oscillator: i/o function on ra7/osc1/clkin 011 = extrc oscillator: rc function on ra7/osc1/clkin 010 = hs oscillator: high-speed crystal/resonator on ra6/osc2/clkout pin and ra7/osc1/clkin 001 = xt oscillator: crystal/resonator on ra6/osc2/clkout pin and ra7/osc1/clkin 000 = lp oscillator: low-power crystal on ra6/osc2/clkout pin and ra7/osc1/clkin register 10-1: configurat ion word 1 (continued) note 1: enabling brown-out reset does not automatically enable power-up timer. 2: the entire data eeprom will be erased when the c ode protection is tur ned off during an erase. 3: the entire program memory will be erased when the code protection is turned off.
pic16f193x/lf193x ds41364c-page 130 preliminary ? 2009 microchip technology inc. register 10-2: co nfiguration word 2 r/p-1/1 r/p-1/1 u-1 r/p-1/1 r/p-1/1 r/p-1/1 u-1 lvp debug ? borv stvren pllen ? bit 13 bit 7 u-1 r/p-1/1 r/p-1/1 u-1 u-1 r/p-1/1 r/p-1/1 ? vcapen1 vcapen0 ? ?wrt1wrt0 bit 6 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 13 lvp: low-voltage programming enable bit (1) 1 = low-voltage programming enabled 0 = high-voltage on mclr /v pp must be used for programming bit 12 debug : in-circuit debugger mode bit 1 = in-circuit debugger disabled, rb6/icspclk and rb7/icspdat are general purpose i/o pins 0 = in-circuit debugger enabled, rb6/icspclk and rb7/icspdat are dedicated to the debugger bit 11 unimplemented: read as ? 1 ? bit 10 borv: brown-out reset voltage selection bit 1 = brown-out reset voltage set to 1.9v 0 = brown-out reset voltage set to 2.7v bit 9 stvren: stack overflow/underflow reset enable bit 1 = stack overflow or underflow will cause a reset 0 = stack overflow or underflow will not cause a reset bit 8 pllen: pll enable bit 1 = 4xpll enabled 0 = 4xpll disabled bit 7-6 unimplemented: read as ? 1 ? bit 5-4 vcapen<1:0>: voltage regulator capacitor enable bits (2) 00 =v cap functionality is enabled on ra0 01 =v cap functionality is enabled on ra5 10 =v cap functionality is enabled on ra6 11 = no capacitor on v cap pin bit 3-2 unimplemented: read as ? 1 ? bit 1-0 wrt<1:0>: flash memory self-write protection bits 4 kw flash memory (pic16f1933/pic16lf1933 and pic16f1934/pic16lf1934 only) : 11 = write protection off 10 = 000h to 1ffh write-protected, 200h to fffh may be modified by eecon control 01 = 000h to 7ffh write-protected, 800h to fffh may be modified by eecon control 00 = 000h to fffh write-protected, no addre sses may be modified by eecon control 8 kw flash memory (pic16f1936/pic16lf1936 and pic16f1937/pic16lf1937 only) : 11 = write protection off 10 = 000h to 1ffh write-protected, 200h to 1fffh may be modified by eecon control 01 = 000h to fffh write-protected, 1000h to 1fffh may be modified by eecon control 00 = 000h to 1fffh write-protected, no addresses may be modified by eecon control 16 kw flash memory (pic16f1938/pic16lf1938 and pic16f1939/pic16lf1939 only) : 11 = write protection off 10 = 000h to 1ffh write-protected, 200h to 3fffh may be modified by eecon control 01 = 000h to 1fffh write-protected, 2000h to 3fffh may be modified by eecon control 00 = 000h to 3fffh write-protected, no addresses may be modified by eecon control note 1: the lvp bit cannot be programmed to ? 0 ? when programming mode is entered via lvp. 2: reads as ? 11 ? on pic16lf193x only.
? 2009 microchip technology inc. preliminary ds41364c-page 131 pic16f193x/lf193x 10.2 code protection code protection is controlled using the cp bit in configuration word 1. when code protection is enabled, all program memory locations (0000h-7fffh) read as all ? 0 ?. further programming is disabled for the program memory (0000h-7fffh). data memory is protected with its own code-protect bit (cpd ). when data code protection is enabled (cpd = 0 ), all data memory locations read as ? 0 ?. further programming is disabled for the data memory. data memory can still be programmed and read during program execution. the user id locations and configuration words can be programmed and read out regardless of the code protection settings. 10.3 user id four memory locations (8000h-8003h) are designated as id locations where the user can store checksum or other code identification numbers. these locations are not accessible during normal execution, but are read- able and writable during program/verify mode. only the least significant 7 bits of the id locations are reported when using mplab ? ide. see the ? pic16193x/pic16lf193x memory programming specification ? (ds41360a) for more information.
pic16f193x/lf193x ds41364c-page 132 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 133 pic16f193x/lf193x 11.0 analog-to-digital converter (adc) module the analog-to-digital converter (adc) allows conversion of an analog input signal to a 10-bit binary representation of that signal. this device uses analog inputs, which are multiplexed into a single sample and hold circuit. the output of the sample and hold is connected to the input of the converter. the converter generates a 10-bit binary result via successive approximation and stores the conversion result into the adc result register (adres). figure 11-1 shows the block diagram of the adc. the adc voltage reference is software selectable to be either internally generated or externally supplied. the adc can generate an interrupt upon completion of a conversion. this interrupt can be used to wake-up the device from sleep. figure 11-1: adc block diagram dac (2) av dd v ref + adpref = 10 adpref = 0x adpref = 11 temp sens fvr buffer1 av ss v ref - adnref = 1 adnref = 0 note 1: when adon = 0 , all multiplexer inputs are disconnected. 2: see section 10.0 ?fixed voltage reference? for more information. adon go/done v ss adc 00000 00001 00010 00011 00100 00101 00111 00110 01000 01001 01010 01011 01100 01101 11101 11110 chs<4:0> an0 an1 an2 an4 an5 an6 an7 an3 an8 an9 an10 an11 an12 an13 11111 adresh adresl 10 16 adfm 0 = left justify 1 = right justify
pic16f193x/lf193x ds41364c-page 134 preliminary ? 2009 microchip technology inc. 11.1 adc configuration when configuring and using the adc the following functions must be considered: ? port configuration ? channel selection ? adc voltage reference selection ? adc conversion clock source ? interrupt control ? results formatting 11.1.1 port configuration the adc can be used to convert both analog and digital signals. when converting analog signals, the i/o pin should be configured for analog by setting the associated tris and ansel bits. refer to section 6.0 ?i/o ports? for more information. 11.1.2 channel selection the chs bits of the adcon0 register determine which channel is connected to the sample and hold circuit. when changing channels, a delay is required before starting the next conversion. refer to section 11.2 ?adc operation? for more information. 11.1.3 adc v oltage reference the adpref bits of the adcon1 register provides control of the positive voltage reference. the positive voltage reference can be: ?v ref + ?av dd ? fvr (fixed voltage reference) the adnref bits of the adcon1 register provides control of the negative voltage reference. the negative voltage reference can be: ?v ref - ?av ss see section 14.0 ?fixed voltage reference? for more details on the fixed voltage reference. 11.1.4 conversion clock the source of the conversion clock is software select- able via the adcs bits of the adcon1 register. there are seven possible clock options: ?f osc /2 ?f osc /4 ?f osc /8 ?f osc /16 ?f osc /32 ?f osc /64 ?f rc (dedicated internal oscillator) the time to complete one bit conversion is defined as t ad . one full 10-bit conversion requires 11.5 t ad peri- ods as shown in figure 11-2. for correct conversion, the appropriate t ad specifica- tion must be met. refer to the a/d conversion require- ments in section 28.0 ?electrical specifications? for more information. table 11-1 gives examples of appro- priate adc clock selections. note: analog voltages on any pin that is defined as a digital input may cause the input buf- fer to conduct excess current. note: unless using the f rc , any changes in the system clock frequency will change the adc clock frequency, which may adversely affect the adc result.
? 2009 microchip technology inc. preliminary ds41364c-page 135 pic16f193x/lf193x table 11-1: adc clock period (t ad ) v s . device operating frequencies figure 11-2: analog-to-digital conversion t ad cycles adc clock period (t ad ) device frequency (f osc ) device frequency (f osc ) adc clock source adcs<2:0> 32 mhz 20 mhz 16 mhz 8 mhz 4 mhz 1 mhz fosc/2 000 62.5ns (2) 100 ns (2) 125 ns (2) 250 ns (2) 500 ns (2) 2.0 s fosc/4 100 125 ns (2) 200 ns (2) 250 ns (2) 500 ns (2) 1.0 s4.0 s fosc/8 001 0.5 s (2) 400 ns (2) 0.5 s (2) 1.0 s2.0 s 8.0 s (3) fosc/16 101 800 ns 800 ns 1.0 s2.0 s4.0 s 16.0 s (3) fosc/32 010 1.0 s1.6 s2.0 s4.0 s 8.0 s (3) 32.0 s (3) fosc/64 110 2.0 s3.2 s4.0 s 8.0 s (3) 16.0 s (3) 64.0 s (3) f rc x11 1.0-6.0 s (1,4) 1.0-6.0 s (1,4) 1.0-6.0 s (1,4) 1.0-6.0 s (1,4) 1.0-6.0 s (1,4) 1.0-6.0 s (1,4) legend: shaded cells are outside of recommended range. note 1: the f rc source has a typical t ad time of 1.6 s for v dd . 2: these values violate the minimum required t ad time. 3: for faster conversion times, the selection of another clock source is recommended. 4: when the device frequency is greater than 1 mhz, the f rc clock source is only recommended if the conversion will be performed during sleep. t ad 1 t ad 2 t ad 3 t ad 4 t ad 5 t ad 6 t ad 7 t ad 8 t ad 11 set go bit holding capacitor is disconnected from analog input (typically 100 ns) t ad 9 t ad 10 t cy - t ad adresh:adresl is loaded, go bit is cleared, adif bit is set, holding capacitor is connected to analog input. conversion starts b0 b9 b6 b5 b4 b3 b2 b1 b8 b7 on the following cycle:
pic16f193x/lf193x ds41364c-page 136 preliminary ? 2009 microchip technology inc. 11.1.5 interrupts the adc module allows for the ability to generate an interrupt upon completion of an analog-to-digital conversion. the adc interrupt flag is the adif bit in the pir1 register. the adc interrupt enable is the adie bit in the pie1 register. the adif bit must be cleared in software. this interrupt can be generated while the device is operating or while in sleep. if the device is in sleep, the interrupt will wake-up the device. upon waking from sleep, the next instruction following the sleep instruc- tion is always executed. if the user is attempting to wake-up from sleep and resume in-line code execu- tion, the gie and peie bits of the intcon register must be disabled. if the gie and peie bits of the intcon register are enabled, execution will switch to the interrupt service routine. please refer to section 11.1.5 ?interrupts? for more information. 11.1.6 result formatting the 10-bit a/d conversion result can be supplied in two formats, left justified or right justified. the adfm bit of the adcon1 register controls the output format. figure 11-3 shows the two output formats. figure 11-3: 10-bit a/d conversion result format note 1: the adif bit is set at the completion of every conversion, regardless of whether or not the adc interrupt is enabled. 2: the adc operates during sleep only when the f rc oscillator is selected. adresh adresl (adfm = 0 )msb lsb bit 7 bit 0 bit 7 bit 0 10-bit a/d result unimplemented: read as ? 0 ? (adfm = 1 ) msb lsb bit 7 bit 0 bit 7 bit 0 unimplemented: read as ? 0 ? 10-bit a/d result
? 2009 microchip technology inc. preliminary ds41364c-page 137 pic16f193x/lf193x 11.2 adc operation 11.2.1 starting a conversion to enable the adc module, the adon bit of the adcon0 register must be set to a ? 1 ?. setting the go/ done bit of the adcon0 register to a ? 1 ? will start the analog-to-digital conversion. 11.2.2 completion of a conversion when the conversion is complete, the adc module will: ? clear the go/done bit ? set the adif interrupt flag bit ? update the adresh and adresl registers with new conversion result 11.2.3 terminating a conversion if a conversion must be terminated before completion, the go/done bit can be cleared in software. the adresh and adresl registers will be updated with the partially complete analog-to-digital conversion sample. incomplete bits will match the last bit converted. 11.2.4 adc operation during sleep the adc module can operate during sleep. this requires the adc clock source to be set to the f rc option. when the f rc clock source is selected, the adc waits one additional instruction before starting the conversion. this allows the sleep instruction to be executed, which can reduce system noise during the conversion. if the adc interrupt is enabled, the device will wake-up from sleep when the conversion completes. if the adc interrupt is disabled, the adc module is turned off after the conversion completes, although the adon bit remains set. when the adc clock source is something other than f rc , a sleep instruction causes the present conver- sion to be aborted and the adc module is turned off, although the adon bit remains set. 11.2.5 special event trigger the special event trigger of the ccp5 module allows periodic adc measurements without software inter- vention. when this trigger occurs, the go/done bit is set by hardware and the timer1 counter resets to zero. using the special event trigger does not assure proper adc timing. it is the user?s responsibility to ensure that the adc timing requirements are met. refer to section 19.0 ?capture/compare/pwm mod- ules (eccp1, eccp2, eccp3, ccp4, ccp5)? for more information. note: the go/done bit should not be set in the same instruction that turns on the adc. refer to section 11.2.6 ?a/d conversion procedure? . note: a device reset forces all registers to their reset state. thus, the adc module is turned off and any pending conversion is terminated.
pic16f193x/lf193x ds41364c-page 138 preliminary ? 2009 microchip technology inc. 11.2.6 a/d conversion procedure this is an example procedure for using the adc to perform an analog-to-digital conversion: 1. configure port: ? disable pin output driver (refer to the tris register) ? configure pin as analog (refer to the ansel register) 2. configure the adc module: ? select adc conversion clock ? configure voltage reference ? select adc input channel ? turn on adc module 3. configure adc interrupt (optional): ? clear adc interrupt flag ? enable adc interrupt ? enable peripheral interrupt ? enable global interrupt (1) 4. wait the required acquisition time (2) . 5. start conversion by setting the go/done bit. 6. wait for adc conversion to complete by one of the following: ? polling the go/done bit ? waiting for the adc interrupt (interrupts enabled) 7. read adc result. 8. clear the adc interrupt flag (required if interrupt is enabled). example 11-1: a/d conversion note 1: the global interrupt can be disabled if the user is attempting to wake-up from sleep and resume in-line code execution. 2: refer to section 11.3 ?a/d acquisition requirements? . ;this code block configures the adc ;for polling, vdd reference, frc clock ;and an0 input. ; ;conversion start & polling for completion ; are included. ; banksel adcon1 ; movlw b?01110000? ;adc frc clock movwf adcon1 ; banksel trisa ; bsf trisa,0 ;set ra0 to input banksel ansel ; bsf ansel,0 ;set ra0 to analog banksel adcon0 ; movlw b?10000001? ;right justify, movwf adcon0 ;vdd vref, an0, on call sampletime ;acquisiton delay bsf adcon0,go ;start conversion btfsc adcon0,go ;is conversion done? goto $-1 ;no, test again banksel adresh ; movf adresh,w ;read upper 2 bits movwf resulthi ;store in gpr space banksel adresl ; movf adresl,w ;read lower 8 bits movwf resultlo ;store in gpr space
? 2009 microchip technology inc. preliminary ds41364c-page 139 pic16f193x/lf193x 11.2.7 adc register definitions the following registers are used to control the operation of the adc. register 11-1: adcon0: a/d control register 0 u-0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 ? chs4 chs3 chs2 chs1 chs0 go/done adon bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 unimplemented: read as ? 0 ? bit 6-2 chs<4:0>: analog channel select bits 00000 =an0 00001 =an1 00010 =an2 00011 =an3 00100 =an4 00101 =an5 00110 =an6 00111 =an7 01000 =an8 01001 =an9 01010 =an10 01011 =an11 01100 =an12 01101 =an13 01110 = reserved. no channel connected. . . . 11100 = reserved. no channel connected. 11101 = temperature reference from band gap 11110 = dac output (aka cv ref output) 11111 = fixed voltage reference (fvr) buffer 1 output bit 1 go/done : a/d conversion status bit 1 = a/d conversion cycle in progress. setting this bit starts an a/d conversion cycle. this bit is automatically cleared by hardware when the a/d conversion has completed. 0 = a/d conversion completed/not in progress bit 0 adon: adc enable bit 1 = adc is enabled 0 = adc is disabled and consumes no operating current note 1: see section 10.0 ?fixed voltage reference? for more information.
pic16f193x/lf193x ds41364c-page 140 preliminary ? 2009 microchip technology inc. register 11-2: adcon1: a/d control register 1 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 u-0 r/w-0/0 r/w-0/0 r/w-0/0 adfm adcs2 adcs1 adcs0 ? adnref adpref1 adpref0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 adfm: a/d result format select bit 1 = right justified. six most significant bits of adresh are set to ? 0 ? when the conversion result is loaded. 0 = left justified. six least significant bits of adresl are set to ? 0 ? when the conversion result is loaded. bit 6-4 adcs<2:0>: a/d conversion clock select bits 000 =f osc /2 001 =f osc /8 010 =f osc /32 011 =f rc (clock supplied from a dedicated rc oscillator) 100 =f osc /4 101 =f osc /16 110 =f osc /64 111 =f rc (clock supplied from a dedicated rc oscillator) bit 3 unimplemented: read as ? 0 ? bit 2 adnref: a/d negative voltage reference configuration bit 0 =v ref - is connected to av ss 1 =v ref - is connected to external v ref - bit 1-0 adpref<1:0>: a/d positive voltage reference configuration bits 00 =v ref + is connected to av dd 01 = reserved 10 =v ref + is connected to external v ref + 11 =v ref + is connected to internal fixed voltage reference register 11-3: adresh: adc result register high (adresh) adfm = 0 r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u adres9 adres8 adres7 adres6 adres5 adres4 adres3 adres2 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 adres<9:2> : adc result register bits upper 8 bits of 10-bit conversion result
? 2009 microchip technology inc. preliminary ds41364c-page 141 pic16f193x/lf193x register 11-4: adresl: adc result register low (adresl) adfm = 0 r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u adres1 adres0 ? ? ? ? ? ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-6 adres<1:0> : adc result register bits lower 2 bits of 10-bit conversion result bit 5-0 reserved : do not use. register 11-5: adresh: adc result register high (adresh) adfm = 1 r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u ? ? ? ? ? ? adres9 adres8 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-2 reserved : do not use. bit 1-0 adres<9:8> : adc result register bits upper 2 bits of 10-bit conversion result register 11-6: adresl: adc result register low (adresl) adfm = 1 r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u adres7 adres6 adres5 adres4 adres3 adres2 adres1 adres0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 adres<7:0> : adc result register bits lower 8 bits of 10-bit conversion result
pic16f193x/lf193x ds41364c-page 142 preliminary ? 2009 microchip technology inc. 11.3 a/d acquisition requirements for the adc to meet its specified accuracy, the charge holding capacitor (c hold ) must be allowed to fully charge to the input channel voltage level. the analog input model is shown in figure 11-4. the source impedance (r s ) and the internal sampling switch (r ss ) impedance directly affect the time required to charge the capacitor c hold . the sampling switch (r ss ) impedance varies over the device voltage (v dd ), refer to figure 11-4. the maximum recommended impedance for analog sources is 10 k . as the source impedance is decreased, the acquisition time may be decreased. after the analog input channel is selected (or changed), an a/d acquisition must be done before the conversion can be started. to calculate the minimum acquisition time, equation 11-1 may be used. this equation assumes that 1/2 lsb error is used (256 steps for the adc). the 1/2 lsb error is the maximum error allowed for the adc to meet its specified resolution. equation 11-1: acquisition time example t acq amplifier settling time hold capacitor charging time temperature coefficient ++ = t amp t c t coff ++ = 2s t c temperature - 25c () 0.05s/c () [] ++ = t c c hold r ic r ss r s ++ () ln(1/511) ? = 10pf 1k 7k 10k ++ () ? ln(0.001957) = 1.12 = s t acq 2 s 1.12 s 50c- 25c () 0.05 s /c () [] ++ = 4.42 s = v applied 1e tc ? rc --------- ? ?? ?? ?? v applied 1 1 2 n1 + () 1 ? -------------------------- ? ?? ?? = v applied 1 1 2 n1 + () 1 ? -------------------------- ? ?? ?? v chold = v applied 1e t c ? rc --------- - ? ?? ?? ?? v chold = ;[1] v chold charged to within 1/2 lsb ;[2] v chold charge response to v applied ;combining [1] and [2] the value for t c can be approximated with the following equations: solving for t c : therefore: temperature 50c and external impedance of 10k 5.0v v dd = assumptions: note: where n = number of bits of the adc. note 1: the reference voltage (v ref ) has no effect on the equation, since it cancels itself out. 2: the charge holding capacitor (c hold ) is not discharged after each conversion. 3: the maximum recommended impedance for analog sources is 10 k . this is required to meet the pin leakage specification.
? 2009 microchip technology inc. preliminary ds41364c-page 143 pic16f193x/lf193x figure 11-4: analog input model figure 11-5: adc transfer function c pin va rs anx 5 pf v dd v t 0.6v v t 0.6v i leakage (1) r ic 1k sampling switch ss rss c hold = 10 pf v ss /v ref - 6v sampling switch 5v 4v 3v 2v 567891011 (k ) v dd legend: c pin v t i leakage r ic ss c hold = input capacitance = threshold voltage = leakage current at the pin due to = interconnect resistance = sampling switch = sample/hold capacitance various junctions r ss note 1: refer to section 28.0 ?electrical specifications? . r ss = resistance of sampling switch ffh feh adc output code fdh fch 04h 03h 02h 01h 00h full-scale fbh 1 lsb ideal v ss zero-scale transition v ref transition 1 lsb ideal full-scale range analog input voltage
pic16f193x/lf193x ds41364c-page 144 preliminary ? 2009 microchip technology inc. table 11-2: summary of associated adc registers name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page adcon0 ? chs4 chs3 chs2 chs1 chs0 go/done adon 139 adcon1 adfm adcs2 adcs1 adcs0 ? adnref adpref1 adpref0 140 adresh a/d result register high 140 adresl a/d result register low 141 ansela ? ?ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 88 anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 93 ansele ? ? ? ? ? anse2 anse1 anse0 103 ccp2con p1m1 p1m0 dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 186 intcon gie peie tmr0ie inte rbie tmr0if intf rbif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 88 trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 93 trise ? ? ? ? trise3 trise2 trise1 trise0 103 fvrcon fvren fvrrdy tsen tsrng cdafvr1 cdafvr0 adfvr1 adfvr0 158 daccon0 dacen daclps dacoe --- dacpss1 dacpss0 --- dacnss 155 daccon1 --- --- --- dacr4 dacr3 dacr2 dacr1 dacr0 155 legend: x = unknown, u = unchanged, ? = unimplemented read as ? 0 ?, q = value depends on condition. shaded cells are not used for adc module.
? 2009 microchip technology inc. preliminary ds41364c-page 145 pic16f193x/lf193x 12.0 comparator module comparators are used to interface analog circuits to a digital circuit by comparing two analog voltages and providing a digital indication of their relative magnitudes. comparators are very useful mixed signal building blocks because they provide analog functionality independent of program execution. the analog comparator module includes the following features: ? independent comparator control ? programmable input selection ? comparator output is available internally/externally ? programmable output polarity ? interrupt-on-change ? wake-up from sleep ? programmable speed/power optimization ?pwm shutdown ? programmable and fixed voltage reference 12.1 comparator overview a single comparator is shown in figure 12-1 along with the relationship between the analog input levels and the digital output. when the analog voltage at v in + is less than the analog voltage at v in -, the output of the comparator is a digital low level. when the analog voltage at v in + is greater than the analog voltage at v in -, the output of the comparator is a digital high level. figure 12-1: single comparator ? + v in + v in - output output v in + v in - note: the black areas of the output of the comparator represents the uncertainty due to input offsets and response time.
pic16f193x/lf193x ds41364c-page 146 preliminary ? 2009 microchip technology inc. figure 12-2: comparat or module simplified block diagram note 1: when cxon = 0 , the comparator will produce a ? 0 ? at the output 2: when cxon = 0 , all multiplexer inputs are disconnected. 3: output of comparator can be frozen during debugging. mux cx (3) 0 1 2 3 cxon (1) cxnch<1:0> 2 0 1 c x pch<1:0> c x in1- c x in2- c x in3- c x in+ mux - + cxvn cxvp c x out to eccp pwm logic q1 d en q c x pol mc x out set cxif 0 1 c x sync c x oe c x out dq syncc x out dac fvr buffer2 c x in0- 2 cxsp cxhys det interrupt det interrupt to timer1 cxintn cxintp to d a ta b u s 2 3 v ss tris bit cxon (2) (2) (from timer1) t1clk
? 2009 microchip technology inc. preliminary ds41364c-page 147 pic16f193x/lf193x 12.2 comparator control each comparator has 2 control registers: cmxcon0 and cmxcon1. the cmxcon0 registers (see register 12-1) contain control and status bits for the following: ? enable ?output selection ? output polarity ? speed/power selection ? hysteresis enable ? output synchronization the cmxcon1 registers (see register 12-2) contain control bits for the following: ? interrupt enable ? interrupt edge polarity ? positive input channel selection ? negative input channel selection 12.2.1 comparator enable setting the cxon bit of the cmxcon0 register enables the comparator for operation. clearing the cxon bit disables the comparator resulting in minimum current consumption. 12.2.2 comparator output selection the output of the comparator can be monitored by reading either the cxout bit of the cmxcon0 register or the mcxout bit of the cmout register. in order to make the output available for an external connection, the following conditions must be true: ? cxoe bit of the cmxcon0 register must be set ? corresponding tris bit must be cleared ? cxon bit of the cmxcon0 register must be set 12.2.3 comparator output polarity inverting the output of the comparator is functionally equivalent to swapping the comparator inputs. the polarity of the comparator output can be inverted by setting the cxpol bit of the cmxcon0 register. clearing the cxpol bit results in a non-inverted output. table 12-1 shows the output state versus input conditions, including polarity control. 12.2.4 comparator speed/power selection the trade-off between speed or power can be opti- mized during program execution with the cxsp control bit. the default state for this bit is ? 1 ? which selects the normal speed mode. device power consumption can be optimized at the cost of slower comparator propaga- tion delay by clearing the cxsp bit to ? 0 ?. note 1: the cxoe bit overrides the port data latch. setting the cxon has no impact on the port override. 2: the internal output of the comparator is latched with each instruction cycle. unless otherwise specified, external outputs are not latched. table 12-1: comparator output state vs. input conditions input condition cxpol cxout cxv n > cxv p 00 cxv n < cxv p 01 cxv n > cxv p 10 cxv n < cxv p 11
pic16f193x/lf193x ds41364c-page 148 preliminary ? 2009 microchip technology inc. 12.3 comparator hysteresis a selectable amount of separation voltage can be added to the input pins of each comparator to provide a hysteresis function to the overall operation. these hysteresis levels change as a function of the comparator?s speed/power mode selection. table 12-2 shows the hysteresis levels. these levels are approximate. see section 28.0 ?electrical specifications? for more information. 12.4 timer1 gate operation the output resulting from a comparator operation can be used as a source for gate control of timer1. see section 16.6 ?timer1 gate? for more information. this feature is useful for timing the duration or interval of an analog event. it is recommended that the comparator output be syn- chronized to timer1. this ensures that timer1 does not increment while a change in the comparator is occur- ring. 12.4.1 comparator output synchronization the output from either comparator, c1 or c2, can be synchronized with timer1 by setting the cxsync bit of the cmxcon0 register. once enabled, the comparator output is latched on the falling edge of the timer1 source clock. if a prescaler is used with timer1, the comparator output is latched after the prescaling function. to prevent a race condition, the comparator output is latched on the falling edge of the timer1 clock source and timer1 increments on the rising edge of its clock source. see the comparator block diagram (figure 12-2) and the timer1 block diagram (figure 16-1) for more information. 12.5 comparator interrupt an interrupt can be generated upon a change in the output value of the comparator for each comparator, a rising edge detector and a falling edge detector are present. when either edge detector is triggered and its associ- ated enable bit is set (cxintp and/or cxintn bits of the cmxcon1 register), the corresponding interrupt flag bit (cxif bit of the pir2 register) will be set. to enable the interrupt, you must set the following bits: ? cxon, cxpol and cxsp bits of the cmxcon0 register ? cxie bit of the pie2 register ? cxintp bit of the cmxcon1 register (for a rising edge detection) ? cxintn bit of the cmxcon1 register (for a falling edge detection) ? peie and gie bits of the intcon register the associated interrupt flag bit, cxif bit of the pir2 register, must be cleared in software. if another edge is detected while this flag is being cleared, the flag will still be set at the end of the sequence. 12.6 comparator positive input selection configuring the cxpch<1:0> bits of the cmxcon1 register directs an internal voltage reference or an analog pin to the non-inverting input of the comparator: ? cxin+ analog pin ?dac ? fvr (fixed voltage reference) ?av ss (analog ground) see section 14.0 ?fixed voltage reference? for more information on the fixed voltage reference module. see section 11.0 ?analog-to-digital converter (adc) module? for more information on the cv dac input signal. any time the comparator is disabled (cxon = 0 ), all comparator inputs are disabled. 12.7 comparator negative input selection the cxnch<1:0> bits of the cmxcon0 register direct one of four analog pins to the comparator inverting input. table 12-2: hysteresis levels cxsp cxhys enabled cxhys disabled 0 3mv << 1mv 1 20mv 3mv note: although a comparator is disabled, an interrupt can be generated by changing the output polarity with the cxpol bit of the cmxcon0 register, or by switching the comparator on or off with the cxon bit of the cmxcon0 register. note: to use cxin+ and cxinx- pins as analog input, the appropriate bits must be set in the ansel register and the corresponding tris bits must also be set to disable the output drivers.
? 2009 microchip technology inc. preliminary ds41364c-page 149 pic16f193x/lf193x 12.8 comparator response time the comparator output is indeterminate for a period of time after the change of an input source or the selection of a new reference voltage. this period is referred to as the response time. the response time of the comparator differs from the settling time of the voltage reference. therefore, both of these times must be considered when determining the total response time to a comparator input change. see the comparator and voltage refer- ence specifications in section 28.0 ?electrical specifi- cations? for more details. 12.9 interaction with eccp logic the c1 and c2 comparators can be used as general purpose comparators. their outputs can be brought out to the c1out and c2out pins. however, when the eccp auto-shutdown is active it can use one or both comparators. if auto-restart is also enabled the comparators can be configured as a closed loop analog feedback to the eccp thereby, creating an analog controlled pwm. 12.10 analog input connection considerations a simplified circuit for an analog input is shown in figure 12-3. since the analog input pins share their connection with a digital input, they have reverse biased esd protection diodes to v dd and v ss . the analog input, therefore, must be between v ss and v dd . if the input voltage deviates from this range by more than 0.6v in either direction, one of the diodes is for- ward biased and a latch-up may occur. a maximum source impedance of 10 k is recommended for the analog sources. also, any external component connected to an analog input pin, such as a capacitor or a zener diode, should have very little leakage current to minimize inaccuracies introduced. figure 12-3: analog input model note 1: when reading a port register, all pins configured as analog inputs will read as a ? 0 ?. pins configured as digital inputs will convert as an analog input, according to the input specification. 2: analog levels on any pin defined as a digital input, may cause the input buffer to consume more current than is specified. v a rs < 10k c pin 5 pf v dd v t 0.6v v t 0.6v r ic i leakage (1) vss a in legend: c pin = input capacitance i leakage = leakage current at the pin due to various junctions r ic = interconnect resistance r s = source impedance v a = analog voltage v t = threshold voltage to comparator note 1: see section 28.0 ?electrical specifications?
pic16f193x/lf193x ds41364c-page 150 preliminary ? 2009 microchip technology inc. register 12-1: cmxcon0: comparator x control register 0 r/w-0/0 r-0/0 r/w-0/0 r/w-0/0 u-0 r/w-1/1 r/w-0/0 r/w-0/0 cxon cxout cxoe cxpol ? cxsp cxhys cxsync bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 cxon: comparator enable bit 1 = comparator is enabled and consumes no active power 0 = comparator is disabled bit 6 cxout: comparator output bit if cxpol = 1 (inverted polarity): 1 = cxvp < cxvn 0 = cxvp > cxvn if cxpol = 0 (non-inverted polarity): 1 = cxvp > cxvn 0 = cxvp < cxvn bit 5 cxoe: comparator output enable bit 1 = cxout is present on the cxout pin. requires that the associated tris bit be cleared to actually drive the pin. not affected by cxon. 0 = cxout is internal only bit 4 cxpol: comparator output polarity select bit 1 = comparator output is inverted 0 = comparator output is not inverted bit 3 unimplemented: read as ? 0 ? bit 2 cxsp: comparator speed/power select bit 1 = comparator operates in normal power, higher speed mode 0 = comparator operates in low-power, low-speed mode bit 1 cxhys: comparator hysteresis enable bit 1 = comparator hysteresis enabled 0 = comparator hysteresis disabled bit 0 cxsync: comparator output synchronous mode bit 1 = comparator output to timer1 and i/o pin is synchronous to changes on tmr1_clk. output updated on the falling edge of tmr1_clk. 0 = comparator output to timer1 and i/o pin is asynchronous. refer to figure 12-2.
? 2009 microchip technology inc. preliminary ds41364c-page 151 pic16f193x/lf193x register 12-2: cmxcon1: compa rator cx control register 1 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 u-0 u-0 r/w-0/0 r/w-0/0 cxintp cxintn cxpch1 cxpch0 ? ? cxnch1 cxnch0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 cxintp: comparator interrupt on positive going edge enable bits 1 = the cxif interrupt flag will be set upon a positive going edge of the cxout bit 0 = no interrupt flag will be set on a positive going edge of the cxout bit bit 6 cxintn: comparator interrupt on negative going edge enable bits 1 = the cxif interrupt flag will be set upon a negative going edge of the cxout bit 0 = no interrupt flag will be set on a negative going edge of the cxout bit bit 5-4 cxpch<1:0>: comparator positive input channel select bits 00 = cxvp connects to cxin+ pin 01 = cxvp connects to cv dac 10 = cxvp connects to fvr voltage reference 11 = cxvp connects to av ss bit 3-2 unimplemented: read as ? 0 ? bit 1-0 cxnch<1:0>: comparator negative input channel select bits 00 = cxvn connects to cxin0- pin 01 = cxvn connects to cxin1- pin 10 = cxvn connects to cxin2- pin 11 = cxvn connects to cxin3- pin note 1: comparator output requires the following three conditions: c2oe = 1 , c2on = 1 and corresponding port tris bit = 0 . register 12-3: cmout: comparator output register u-0 u-0 u-0 u-0 u-0 u-0 r/w-0/0 r/w-0/0 ? ? ? ? ? ? mc2out mc1out bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-2 unimplemented: read as ? 0 ? bit 1 mc2out: mirror copy of c2out bit bit 0 mc1out: mirror copy of c1out bit
pic16f193x/lf193x ds41364c-page 152 preliminary ? 2009 microchip technology inc. table 12-3: registers associated with comparator module name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page cm1con0 c1on c1out c1oe c1pol --- c1sp c1hys c1sync 150 cm2con0 c2on c2out c2oe c2pol ? c2sp c2hys c2sync 150 cm1con1 c1ntp c1intn c1pch1 c1pch0 ? ? c1nch1 c1nch0 151 cm2con1 c2ntp c2intn c2pch1 c2pch0 ? ? c2nch1 c2nch0 151 cmout ? ? ? ? ? ? mc2out mc1out 151 fvrcon fvren fvrrdy tsen tsrng cdafvr1 cdafvr0 adfvr1 adfvr0 158 daccon0 dacen daclps dacoe ? dacpss1 dacpss0 ? dacnss 155 daccon1 ? ? ? dacr4 dacr3 dacr2 dacr1 dacr0 155 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pir2 osfif c2if c1if eeif bclif lcdif ? ccp2if 80 pie2 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie 77 portc rc7 rc6 rc5 rc4 rc3 rc2 rc1 rc0 95 latc latc7 latc6 latc5 latc4 latc3 latc2 latc1 latc0 95 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 ansela ? ? ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 88 anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 93 legend: ? = unimplemented, read as ? 0 ?. shaded cells are unused by the comparator module.
? 2009 microchip technology inc. preliminary ds41364c-page 153 pic16f193x/lf193x 13.0 digital-to-analog converter (dac) module the digital-to-analog converter supplies a variable voltage reference, ratiometric with v dd , with 32 select- able output levels. the output of the dac can be con- figured to supply a reference voltage to the following: ? comparator positive input ? adc input channel ? dacout device pin the digital-to-analog converter (dac) can be enabled by setting the dacen bit of the daccon0 register. 13.1 output voltage selection the dac has 32 voltage level ranges. the 32 levels are set with the dacr<4:0> bits of the daccon1 register. the dac output voltage is determined by the following equations: equation 13-1: 13.2 output clamped to v ss the dac output voltage can be set to vss with no power consumption by setting the dacen bit of the daccon0 register to ? 0 ?: this allows the comparator to detect a zero-crossing while not consuming additional current from the dac. 13.3 output ratiometric to v dd the dac is v dd derived and therefore, the dac output changes with fluctuations in v dd . the tested absolute accuracy of the dac can be found in section 28.0 ?electrical specifications? . 13.4 voltage reference output the dac can be output to the device dacout pin by setting the dacoe bit of the daccon0 register to ? 1 ?. selecting the reference voltage for output on the dacout pin automatically overrides the digital output buffer and digital input threshold detector functions of that pin. reading the dacout pin when it has been configured for reference voltage output will always return a ? 0 ?. due to the limited current drive capability, a buffer must be used on the voltage reference output for external connections to dacout. figure 13-1 shows an exam- ple buffering technique. 13.5 operation during sleep when the device wakes up from sleep through an interrupt or a watchdog timer time-out, the contents of the daccon0 register are not affected. to minimize current consumption in sleep mode, the voltage reference should be disabled. 13.6 effects of a reset a device reset affects the following: ? voltage reference is disabled ? fixed voltage reference is disabled ? dac is removed from the dacout pin ? the dacr<4:0> range select bits are cleared v out v source +v source - ? () dacr<4:0> 25 ------------------------------ - ?? ?? = + v source - v source + = v dd , v ref + or fvr1 v source ? = v ss or v ref -
pic16f193x/lf193x ds41364c-page 154 preliminary ? 2009 microchip technology inc. figure 13-1: digital-to-analog co nverter block diagram 32-to-1 mux dacr<4:0> r v ref - dacnss r r r r r r 32 dac dacout 5 (to comparator and adc modules) dacoe v dd v ref + dacpss<1:0> 2 dacen steps digital-to-analog converter (dac) fvr buffer2 r v src - v src + v ss daclps
? 2009 microchip technology inc. preliminary ds41364c-page 155 pic16f193x/lf193x register 13-1: daccon0: voltage re ference control register 0 r/w-0/0 r/w-0/0 r/w-0/0 u-0 r/w-0/0 r/w-0/0 u-0 r/w-0/0 dacen daclps dacoe --- dacpss1 dacpss0 --- dacnss bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 dacen: dac enable bit 0 = dac is disabled 1 = dac is enabled bit 6 daclps: dac low-power voltage state select bit 0 =v dac = dac negative reference source selected 1 =v dac = dac positive reference source selected bit 5 dacoe: dac voltage output enable bit 1 = dac voltage level is also an output on the dacout pin 0 = dac voltage level is disconnected from the dacout pin bit 4 unimplemented: read as ? 0 ? bit 3-2 dacpss<1:0>: dac positive source select bits 00 =v dd 01 =v ref + 10 = fvr1 output 11 = reserved, do not use bit 1 unimplemented: read as ? 0 ? bit 0 dacnss: dac negative source select bits 0 =v ss 1 =v ref - register 13-2: daccon1: voltage re ference control register 1 u-0 u-0 u-0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 --- --- --- dacr4 dacr3 dacr2 dacr1 dacr0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-5 unimplemented: read as ? 0 ? bit 4-0 dacr<4:0>: dac voltage output select bits v out = ((v source +) - (v source -))*(dacr<4:0>/(2^5)) + v source - note 1: the output select bits are always right justified to ensure that any number of bits can be used without affecting the register layout.
pic16f193x/lf193x ds41364c-page 156 preliminary ? 2009 microchip technology inc. table 13-1: registers associated with th e digital-to-analog converter name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page fvrcon fvren fvrrdy tsen tsrng cdafvr1 cdafvr0 adfvr1 adfvr0 158 daccon0 dacen daclps dacoe --- dacpss1 dacpss0 --- dacnss 155 daccon1 --- --- --- dacr4 dacr3 dacr2 dacr1 dacr0 155 legend: shaded cells are not used with the dac.
? 2009 microchip technology inc. preliminary ds41364c-page 157 pic16f193x/lf193x 14.0 fixed voltage reference the fixed voltage reference, or fvr, is a stable voltage reference, independent of v dd , with 1.024v, 2.048v or 4.096v selectable output levels. the output of the fvr can be configured to supply a reference voltage to the following: ? adc input channel ? adc positive reference ? comparator positive input ? programmable voltage reference ? lcd bias generator the fvr can be enabled by setting the fvren bit of the fvrcon register. 14.1 independent gain amplifiers the output of the fvr supplied to the adc and comparator modules is routed through two independent programmable gain amplifiers. each amplifier can be configured to amplify the reference voltage by 1x, 2x or 4x. the adfvr<1:0> bits of the fvrcon register are used to enable and configure the gain amplifier settings for the reference supplied to the adc module. refer- ence section 11.0 ?analog-to-digital converter (adc) module? for additional information on selecting the appropriate input channel. the cdafvr<1:0> bits of the fvrcon register are used to enable and configure the gain amplifier settings for the reference supplied to the comparator module. reference section 12.0 ?comparator module? for additional information on selecting the appropriate input channel. 14.2 fvr stabilization period when the fixed voltage reference module is enabled, it requires time for the reference and amplifier circuits to stabilize. once the circuits stabilize and are ready for use, the fvrrdy bit of the fvrcon register will be set. see section 28.0 ?electrical specifications? for the minimum delay requirement. figure 14-1: voltage reference block diagram figure 14-2: voltage reference ou tput buffer example adfvr<1:0> cdafvr<1:0> x 1 x 2 x 4 x 1 x 2 x 4 2 2 fvr_buffer1 (to adc module) fvr_buffer2 (to comparators, dac) fvr_vref (to lcd bias generator) + _ fvren fvrrdy 1.024v fixed reference buffered cv ref output + ? cv ref module voltage reference output impedance r cv ref pic16f193x/ pic16lf193x
pic16f193x/lf193x ds41364c-page 158 preliminary ? 2009 microchip technology inc. table 14-1: registers associated with voltage reference register 14-1: fvrcon: fixed voltage reference control register r/w-0/0 r-q/q r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 fvren fvrrdy (1) ? ? cdafvr1 cdafvr0 adfvr1 adfvr0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared q = value depends on condition bit 7 fvren: fixed voltage reference enable bit 0 = fixed voltage reference is disabled 1 = fixed voltage reference is enabled bit 6 fvrrdy: fixed voltage reference ready flag bit (1) 0 = fixed voltage reference output is not active or stable 1 = fixed voltage reference output is ready for use bit 5-4 reserved: read as ? 0 ?. maintain these bits clear. bit 3-2 cdafvr<1:0>: comparator and d/a converter fixed voltage reference selection bit 00 = comparator and d/a converter fixed voltage reference peripheral output is off. 01 = comparator and d/a converter fixed voltage reference peripheral output is 1x (1.024v) 10 = comparator and d/a converter fixed voltage reference peripheral output is 2x (2.048v) (2) 11 = comparator and d/a converter fixed voltage reference peripheral output is 4x (4.096v) (2) bit 1-0 adfvr<1:0>: a/d converter fixed voltage reference selection bit 00 = a/d converter fixed voltage reference peripheral output is off. 01 = a/d converter fixed voltage reference peripheral output is 1x (1.024v) 10 = a/d converter fixed voltage reference peripheral output is 2x (2.048v) (2) 11 = a/d converter fixed voltage reference peripheral output is 4x (4.096v) (2) note 1: fvrrdy is always ? 1 ? on regulated parts (pic16f193x). 2: fixed voltage reference output cannot exceed v dd . name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page fvrcon fvren fvrrdy tsen tsrng cdafvr1 cdafvr0 adfvr1 adfvr0 158 legend: shaded cells are not used with the voltage reference.
? 2009 microchip technology inc. preliminary ds41364c-page 159 pic16f193x/lf193x 15.0 timer0 module the timer0 module is an 8-bit timer/counter with the following features: ? 8-bit timer/counter register (tmr0) ? 8-bit prescaler (independent of watchdog timer) ? programmable internal or external clock source ? programmable external clock edge selection ? interrupt on overflow ? tmr0 can be used to gate timer1 figure 15-1 is a block diagram of the timer0 module. 15.1 timer0 operation the timer0 module can be used as either an 8-bit timer or an 8-bit counter. 15.1.1 8-bit timer mode the timer0 module will increment every instruction cycle, if used without a prescaler. 8-bit timer mode is selected by clearing the tmr0cs bit of the option register. when tmr0 is written, the increment is inhibited for two instruction cycles immediately following the write. 15.1.2 8-bit counter mode in 8-bit counter mode, the timer0 module will increment on every rising or falling edge of the t0cki pin or the capacitive sensing oscillator (cpsclk) signal. 8-bit counter mode using the t0cki pin is selected by setting the tmr0cs bit in the option register to ? 1 ? and resetting the t0xcs bit in the cpscon0 register to ? 0 ?. 8-bit counter mode using the capacitive sensing oscillator (cpsclk) signal is selected by setting the tmr0cs bit in the option register to ? 1 ? and setting the t0xcs bit in the cpscon0 register to ? 1 ?. the rising or falling transition of the incrementing edge for either input source is determined by the tmr0se bit in the option register. figure 15-1: block diagra m of the timer0 note: the value written to the tmr0 register can be adjusted, in order to account for the two instruction cycle delay when tmr0 is written. t0cki tmr0se tmr0 ps<2:0> data bus set flag bit tmr0if on overflow tmr0cs 0 1 0 1 8 8 8-bit prescaler f osc /4 psa sync 2 t cy overflow to timer1 1 0 from cpsclk t0xcs
pic16f193x/lf193x ds41364c-page 160 preliminary ? 2009 microchip technology inc. 15.1.3 software programmable prescaler a software programmable prescaler is available for exclusive use with timer0. the prescaler is enabled by clearing the psa bit of the option register. there are 8 prescaler options for the timer0 module ranging from 1:2 to 1:256. the prescale values are selectable via the ps<2:0> bits of the option register. in order to have a 1:1 prescaler value for the timer0 module, the prescaler must be disabled by setting the psa bit of the option register. the prescaler is not readable or writable. all instructions writing to the tmr0 register will clear the prescaler. 15.1.4 timer0 interrupt timer0 will generate an interrupt when the tmr0 register overflows from ffh to 00h. the tmr0if interrupt flag bit of the intcon register is set every time the tmr0 register overflows, regardless of whether or not the timer0 interrupt is enabled. the tmr0if bit can only be cleared in software. the timer0 interrupt enable is the tmr0ie bit of the intcon register. 15.1.5 8-bit counter mode synchronization when in 8-bit counter mode, the incrementing edge on the t0cki pin must be synchronized to the instruction clock. synchronization can be accomplished by sampling the prescaler output on the q2 and q4 cycles of the instruction clock. the high and low periods of the external clocking source must meet the timing requirements as shown in section 28.0 ?electrical specifications? . 15.1.6 operation during sleep timer0 cannot operate while the processor is in sleep mode. the contents of the tmr0 register will remain unchanged while the processor is in sleep mode. note: the watchdog timer (wdt) uses its own independent prescaler. note: the timer0 interrupt cannot wake the processor from sleep since the timer is frozen during sleep.
? 2009 microchip technology inc. preliminary ds41364c-page 161 pic16f193x/lf193x table 15-1: summary of registers associated with timer0 register 15-1: option_reg: option register r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 wpuen intedg tmr0cs tmr0se psa ps2 ps1 ps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 wpuen : weak pull-up enable bit 1 = all weak pull-ups are disabled (except mclr , if it is enabled) 0 = weak pull-ups are enabled by individual wpux latch values bit 6 intedg: interrupt edge select bit 1 = interrupt on rising edge of rb0/int pin 0 = interrupt on falling edge of rb0/int pin bit 5 tmr0cs: timer0 clock source select bit 1 = transition on ra4/t0cki pin 0 = internal instruction cycle clock (f osc /4) bit 4 tmr0se: timer0 source edge select bit 1 = increment on high-to-low transition on ra4/t0cki pin 0 = increment on low-to-high transition on ra4/t0cki pin bit 3 psa: prescaler assignment bit 1 = prescaler is assigned to the wdt 0 = prescaler is assigned to the timer0 module bit 2-0 ps<2:0>: prescaler rate select bits 000 001 010 011 100 101 110 111 1 : 2 1 : 4 1 : 8 1 : 16 1 : 32 1 : 64 1 : 128 1 : 256 bit value timer0 rate name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page cpscon0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs 182 intcon gie peie tmr0ie inte rbie tmr0if intf rbif 75 option_reg wpuen intedg tmr0cs tmr0se psa ps2 ps1 ps0 53 tmr0 timer0 module register 159* trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 88 legend: ? = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the timer0 module. * page provides register information.
pic16f193x/lf193x ds41364c-page 162 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 163 pic16f193x/lf193x 16.0 timer1 module with gate control the timer1 module is a 16-bit timer/counter with the following features: ? 16-bit timer/counter register pair (tmr1h:tmr1l) ? programmable internal or external clock source ? 3-bit prescaler ? dedicated lp oscillator circuit ? optionally synchronized comparator out ? multiple timer1 gate (count enable) sources ? interrupt on overflow ? wake-up on overflow (external clock, asynchronous mode only) ? time base for the capture/compare function ? special event trigger (with ccp) ? selectable gate source polarity ? gate toggle mode ? gate single-pulse mode ? gate value status ? gate event interrupt figure 16-1 is a block diagram of the timer1 module. figure 16-1: timer1 block diagram tmr1h tmr1l t1sync t1ckps<1:0> prescaler 1, 2, 4, 8 0 1 synchronized clock input 2 set flag bit tmr1if on overflow tmr1 (2) tmr1on note 1: st buffer is high speed type when using t1cki. 2: timer1 register increments on rising edge. 3: synchronize does not operate while in sleep. t1g t1osc f osc /4 internal clock t1oso t1osi t1oscen 1 0 t1cki tmr1cs<1:0> (1) synchronize (3) det sleep input tmr1ge 0 1 00 01 10 11 t1gpol d q ck q 0 1 t1gval t1gtm single pulse acq. control t1gspm t1ggo/done t1gss<1:0> en out 10 11 00 01 f osc internal clock cap. sensing r d en q q1 rd t1gcon data bus det interrupt tmr1gif set t1clk f osc /2 internal clock d en q t1g_in tmr1on oscillator from timer0 comparator 1 overflow comparator 2 syncc2out syncc1out to comparator module to lcd and clock switching modules
pic16f193x/lf193x ds41364c-page 164 preliminary ? 2009 microchip technology inc. 16.1 timer1 operation the timer1 module is a 16-bit incrementing counter which is accessed through the tmr1h:tmr1l register pair. writes to tmr1h or tmr1l directly update the counter. when used with an internal clock source, the module is a timer and increments on every instruction cycle. when used with an external clock source, the module can be used as either a timer or counter and incre- ments on every selected edge of the external source. timer1 is enabled by configuring the tmr1on and tmr1ge bits in the t1con and t1gcon registers, respectively. table 16-1 displays the timer1 enable selections. 16.2 clock source selection the tmr1cs<1:0> and t1oscen bits of the t1con register are used to select the clock source for timer1. table 16-2 displays the clock source selections. 16.2.1 internal clock source when the internal clock source is selected the tmr1h:tmr1l register pair will increment on multiples of f osc as determined by the timer1 prescaler. 16.2.2 external clock source when the external clock source is selected, the timer1 module may work as a timer or a counter. when enabled to count, timer1 is incremented on the rising edge of the external clock input t1cki or the capacitive sensing oscillator signal. either of these external clock sources can be synchronized to the microcontroller system clock or they can run asynchronously. when used as a timer with a clock oscillator, an external 32.768 khz crystal can be used in conjunction with the dedicated internal oscillator circuit. table 16-1: timer1 enable selections tmr1on tmr1ge timer1 operation 00 off 01 off 10 always on 11 count enabled note: in counter mode, a falling edge must be registered by the counter prior to the first incrementing rising edge after any one or more of the following conditions: ? timer1 enabled after por ? write to tmr1h or tmr1l ? timer1 is disabled ? timer1 is disabled (tmr1on = 0 ) when t1cki is high then timer1 is enabled (tmr1on= 1 ) when t1cki is low. table 16-2: clock source selections tmr1cs1 tmr1cs0 t1oscen clock source 01x system clock (f osc ) 00x instruction clock (f osc /4) 11x capacitive sensing oscillator 100 external clocking on t1cki pin 101 osc.circuit on t1osi/t1oso pins
? 2009 microchip technology inc. preliminary ds41364c-page 165 pic16f193x/lf193x 16.3 timer1 prescaler timer1 has four prescaler options allowing 1, 2, 4 or 8 divisions of the clock input. the t1ckps bits of the t1con register control the prescale counter. the prescale counter is not directly readable or writable; however, the prescaler counter is cleared upon a write to tmr1h or tmr1l. 16.4 timer1 oscillator a dedicated low-power 32.768 khz oscillator circuit is built-in between pins t1osi (input) and t1oso (amplifier output). this internal circuit is to be used in conjunction with an external 32.768 khz crystal. the oscillator circuit is enabled by setting the t1oscen bit of the t1con register. the oscillator will continue to run during sleep. 16.5 timer1 operation in asynchronous counter mode if control bit t1sync of the t1con register is set, the external clock input is not synchronized. the timer increments asynchronously to the internal phase clocks. if external clock source is selected then the timer will continue to run during sleep and can generate an interrupt on overflow, which will wake-up the processor. however, special precautions in software are needed to read/write the timer (see section 16.5.1 ?reading and writing timer1 in asynchronous counter mode? ). 16.5.1 reading and writing timer1 in asynchronous counter mode reading tmr1h or tmr1l while the timer is running from an external asynchronous clock will ensure a valid read (taken care of in hardware). however, the user should keep in mind that reading the 16-bit timer in two 8-bit values itself, poses certain problems, since the timer may overflow between the reads. for writes, it is recommended that the user simply stop the timer and write the desired values. a write contention may occur by writing to the timer registers, while the register is incrementing. this may produce an unpredictable value in the tmr1h:tmr1l register pair. 16.6 timer1 gate timer1 can be configured to count freely or the count can be enabled and disabled using timer1 gate circuitry. this is also referred to as timer1 gate enable. timer1 gate can also be driven by multiple selectable sources. 16.6.1 timer1 gate enable the timer1 gate enable mode is enabled by setting the tmr1ge bit of the t1gcon register. the polarity of the timer1 gate enable mode is configured using the t1gpol bit of the t1gcon register. when timer1 gate enable mode is enabled, timer1 will increment on the rising edge of the timer1 clock source. when timer1 gate enable mode is disabled, no incrementing will occur and timer1 will hold the current count. see figure 16-3 for timing details. 16.6.2 timer1 gate source selection the timer1 gate source can be selected from one of four different sources. source selection is controlled by the t1gss bits of the t1gcon register. the polarity for each available source is also selectable. polarity selection is controlled by the t1gpol bit of the t1gcon register. table 16-4: timer1 gate sources note: the oscillator requires a start-up and stabilization time before use. thus, t1oscen should be set and a suitable delay observed prior to enabling timer1. note: when switching from synchronous to asynchronous operation, it is possible to skip an increment. when switching from asynchronous to synchronous operation, it is possible to produce an additional increment. table 16-3: timer1 gate enable selections t1clk t1gpol t1g timer1 operation 00 counts 01 holds count 10 holds count 11 counts t1gss timer1 gate source 00 timer1 gate pin 01 overflow of timer0 (tmr0 increments from ffh to 00h) 10 comparator 1 output syncc1out (optionally synchronized out) 11 comparator 2 output syncc2out (optionally synchronized out)
pic16f193x/lf193x ds41364c-page 166 preliminary ? 2009 microchip technology inc. 16.6.2.1 t1g pin gate operation the t1g pin is one source for timer1 gate control. it can be used to supply an external source to the timer1 gate circuitry. 16.6.2.2 timer0 overflow gate operation when timer0 increments from ffh to 00h, a low-to-high pulse will automatically be generated and internally supplied to the timer1 gate circuitry. 16.6.2.3 comparator c1 gate operation the output resulting from a comparator 1 operation can be selected as a source for timer1 gate control. the comparator 1 output (syncc1out) can be synchronized to the timer1 clock or left asynchronous. for more information see section 12.4.1 ?comparator output synchronization? . 16.6.2.4 comparator c2 gate operation the output resulting from a comparator 2 operation can be selected as a source for timer1 gate control. the comparator 2 output (syncc2out) can be synchronized to the timer1 clock or left asynchronous. for more information see section 12.4.1 ?comparator output synchronization? . 16.6.3 timer1 gate toggle mode when timer1 gate toggle mode is enabled, it is possi- ble to measure the full-cycle length of a timer1 gate signal, as opposed to the duration of a single level pulse. the timer1 gate source is routed through a flip-flop that changes state on every incrementing edge of the signal. see figure 16-4 for timing details. timer1 gate toggle mode is enabled by setting the t1gtm bit of the t1gcon register. when the t1gtm bit is cleared, the flip-flop is cleared and held clear. this is necessary in order to control which edge is measured. 16.6.4 timer1 gate single-pulse mode when timer1 gate single-pulse mode is enabled, it is possible to capture a single pulse gate event. timer1 gate single-pulse mode is first enabled by setting the t1gspm bit in the t1gcon register. next, the t1ggo/done bit in the t1gcon register must be set. the timer1 will be fully enabled on the next incrementing edge. on the next trailing edge of the pulse, the t1ggo/done bit will automatically be cleared. no other gate events will be allowed to increment timer1 until the t1ggo/done bit is once again set in software. clearing the t1gspm bit of the t1gcon register will also clear the t1ggo/done bit. see figure 16-5 for timing details. enabling the toggle mode and the single-pulse mode simultaneously will permit both sections to work together. this allows the cycle times on the timer1 gate source to be measured. see figure 16-6 for timing details. 16.6.5 timer1 gate value status when timer1 gate value status is utilized, it is possible to read the most current level of the gate control value. the value is stored in the t1gval bit in the t1gcon register. the t1gcon bit is valid even when the timer1 gate is not enabled (tmr1ge bit is cleared). 16.6.6 timer1 gate event interrupt when timer1 gate event interrupt is enabled, it is pos- sible to generate an interrupt upon the completion of a gate event. when the falling edge of t1gval occurs, the tmr1gif flag bit in the pir1 register will be set. if the tmr1gie bit in the pie1 register is set, then an interrupt will be recognized. the tmr1gif flag bit operates even when the timer1 gate is not enabled (tmr1ge bit is cleared). note: enabling toggle mode at the same time as changing the gate polarity may result in indeterminate operation.
? 2009 microchip technology inc. preliminary ds41364c-page 167 pic16f193x/lf193x 16.7 timer1 interrupt the timer1 register pair (tmr1h:tmr1l) increments to ffffh and rolls over to 0000h. when timer1 rolls over, the timer1 interrupt flag bit of the pir1 register is set. to enable the interrupt on rollover, you must set these bits: ? tmr1on bit of the t1con register ? tmr1ie bit of the pie1 register ? peie bit of the intcon register ? gie bit of the intcon register the interrupt is cleared by clearing the tmr1if bit in the interrupt service routine. 16.8 timer1 operation during sleep timer1 can only operate during sleep when setup in asynchronous counter mode. in this mode, an external crystal or clock source can be used to increment the counter. to set up the timer to wake the device: ? tmr1on bit of the t1con register must be set ? tmr1ie bit of the pie1 register must be set ? peie bit of the intcon register must be set ? t1sync bit of the t1con register must be set ? tmr1cs bits of the t1con register must be configured ? t1oscen bit of the t1con register must be configured the device will wake-up on an overflow and execute the next instructions. if the gie bit of the intcon register is set, the device will call the interrupt service routine (0004h). timer1 oscillator will continue to operate in sleep regardless of the t1sync bit setting. 16.9 eccp/ccp capture/compare time base the ccp modules uses the tmr1h:tmr1l register pair as the time base when operating in capture or compare mode. in capture mode, the value in the tmr1h:tmr1l register pair is copied into the ccpr1h:ccpr1l register pair on a configured event. in compare mode, an event is triggered when the value ccpr1h:ccpr1l register pair matches the value in the tmr1h:tmr1l register pair. this event can be a special event trigger. for more information, see section 19.0 ?capture/compare/pwm modules (eccp1, eccp2, eccp3, ccp4, ccp5)? . 16.10 eccp/ccp special event trigger when any of the ccp?s are configured to trigger a spe- cial event, the trigger will clear the tmr1h:tmr1l reg- ister pair. this special event does not cause a timer1 interrupt. the ccp module may still be configured to generate a ccp interrupt. in this mode of operation, the ccpr1h:ccpr1l register pair becomes the period register for timer1. timer1 should be synchronized to the f osc /4 to utilize the special event trigger. asynchronous operation of timer1 can cause a special event trigger to be missed. in the event that a write to tmr1h or tmr1l coincides with a special event trigger from the ccp, the write will take precedence. for more information, see section 11.2.5 ?special event trigger? . figure 16-2: timer1 incrementing edge note: the tmr1h:tmr1l register pair and the tmr1if bit should be cleared before enabling interrupts. t1cki = 1 when tmr1 enabled t1cki = 0 when tmr1 enabled note 1: arrows indicate counter increments. 2: in counter mode, a falling edge must be registered by the count er prior to the first incrementing rising edge of the clock.
pic16f193x/lf193x ds41364c-page 168 preliminary ? 2009 microchip technology inc. figure 16-3: timer1 gate enable mode figure 16-4: timer1 gate toggle mode tmr1ge t1gpol t1g_in t1cki t1gval timer1 n n + 1 n + 2 n + 3 n + 4 tmr1ge t1gpol t1gtm t1g_in t1cki t1gval timer1 n n + 1 n + 2 n + 3 n + 4 n + 5 n + 6 n + 7 n + 8
? 2009 microchip technology inc. preliminary ds41364c-page 169 pic16f193x/lf193x figure 16-5: timer1 gate single-pulse mode tmr1ge t1gpol t1g_in t1cki t1gval timer1 n n + 1 n + 2 t1gspm t1ggo/ done set by software cleared by hardware on falling edge of t1gval set by hardware on falling edge of t1gval cleared by software cleared by software tmr1gif counting enabled on rising edge of t1g
pic16f193x/lf193x ds41364c-page 170 preliminary ? 2009 microchip technology inc. figure 16-6: timer1 gate single-pulse and toggle combined mode tmr1ge t1gpol t1g_in t1cki t1gval timer1 nn + 1 n + 2 t1gspm t1ggo/ done set by software cleared by hardware on falling edge of t1gval set by hardware on falling edge of t1gval cleared by software cleared by software tmr1gif t1gtm counting enabled on rising edge of t1g n + 4 n + 3
? 2009 microchip technology inc. preliminary ds41364c-page 171 pic16f193x/lf193x 16.11 timer1 control register the timer1 control register (t1con), shown in register 16-1, is used to control timer1 and select the various features of the timer1 module. register 16-1: t1con: ti mer1 control register r/w-0/u r/w-0/u r/w-0/u r/w-0/u r/w-0/u r/w-0/u u-0 r/w-0/u tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-6 tmr1cs<1:0>: timer1 clock source select bits 11 = timer1 clock source is capacitive sensing oscillator (caposc) 10 = timer1 clock source is pin or oscillator: if t1oscen = 0 : external clock from t1cki pin (on the rising edge) if t1oscen = 1 : crystal oscillator on t1osi/t1oso pins 01 = timer1 clock source is system clock (f osc ) 00 = timer1 clock source is instruction clock (f osc /4) bit 5-4 t1ckps<1:0>: timer1 input clock prescale select bits 11 = 1:8 prescale value 10 = 1:4 prescale value 01 = 1:2 prescale value 00 = 1:1 prescale value bit 3 t1oscen: lp oscillator enable control bit 1 = dedicated timer1 oscillator circuit enabled 0 = dedicated timer1 oscillator circuit disabled bit 2 t 1sync : timer1 external clock input synchronization control bit tmr1cs<1:0> = 1x 1 = do not synchronize external clock input 0 = synchronize external clock input with system clock (f osc ) tmr1cs<1:0> = 0x this bit is ignored. timer1 uses the internal clock when tmr1cs<1:0> = 1x . bit 1 unimplemented: read as ? 0 ? bit 0 tmr1on: timer1 on bit 1 = enables timer1 0 = stops timer1 clears timer1 gate flip-flop
pic16f193x/lf193x ds41364c-page 172 preliminary ? 2009 microchip technology inc. 16.12 timer1 gate control register the timer1 gate control register (t1gcon), shown in register 16-2, is used to control timer1 gate. register 16-2: t1gcon: timer1 gate control register r/w-0/u r/w-0/u r/w-0/u r/w-0/u r/w-0/u r-x/x r/w-0/u r/w-0/u tmr1ge t1gpol t1gtm t1gspm t1ggo/ done t1gval t1gss1 t1gss0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 tmr1ge: timer1 gate enable bit if tmr1on = 0 : this bit is ignored if tmr1on = 1 : 1 = timer1 counting is controlled by the timer1 gate function 0 = timer1 counts regardless of timer1 gate function bit 6 t1gpol: timer1 gate polarity bit 1 = timer1 gate is active-high (timer1 counts when gate is high) 0 = timer1 gate is active-low (timer1 counts when gate is low) bit 5 t1gtm: timer1 gate toggle mode bit 1 = timer1 gate toggle mode is enabled 0 = timer1 gate toggle mode is disabled and toggle flip flop is cleared timer1 gate flip-flop toggles on every rising edge. bit 4 t1gspm: timer1 gate single-pulse mode bit 1 = timer1 gate single-pulse mode is enabled and is controlling timer1 gate 0 = timer1 gate single-pulse mode is disabled bit 3 t1ggo/done : timer1 gate single-pulse acquisition status bit 1 = timer1 gate single-pulse acquisition is ready, waiting for an edge 0 = timer1 gate single-pulse acquisition has completed or has not been started this bit is automatically cleared when t1gspm is cleared. bit 2 t1gval: timer1 gate current state bit indicates the current state of the timer1 gate that could be provided to tmr1h:tmr1l. unaffected by timer1 gate enable (tmr1ge). bit 1-0 t1gss<1:0>: timer1 gate source select bits 00 = timer1 gate pin 01 = timer0 overflow output 10 = comparator 1 optionally synchronized output (syncc1out) 11 = comparator 2 optionally synchronized output (syncc2out)
? 2009 microchip technology inc. preliminary ds41364c-page 173 pic16f193x/lf193x table 16-5: summary of registers associated with timer1 name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 93 ccp1con ? ? dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 186 ccp2con ? ? dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 186 intcon gie peie tmr0ie inte rbie tmr0if intf rbif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 portb rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 92 tmr1h holding register for the most significant byte of the 16-bit tmr1 register 167* tmr1l holding register for the least significant byte of the 16-bit tmr1 register 167* trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 93 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on 171 t1gcon tmr1ge t1gpol t1gtm t1gspm t1ggo/ done t1gval t1gss1 t1gss0 172 legend: x = unknown, u = unchanged, ? = unimplemented, read as ? 0 ?. shaded cells are not used by the timer1 module. * page provides register information.
pic16f193x/lf193x ds41364c-page 174 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 175 pic16f193x/lf193x 17.0 timer2/4/6 modules there are three identical timer2-type modules available. to maintain pre-existing naming conventions, the timers are called timer2, timer4 and timer6 (also timer2/4/6). the timer2/4/6 modules incorporate the following features: ? 8-bit timer and period registers (tmrx and prx, respectively) ? readable and writable (both registers) ? software programmable prescaler (1:1, 1:4, 1:16, and 1:64) ? software programmable postscaler (1:1 to 1:16) ? interrupt on tmrx match with prx, respectively ? optional use as the shift clock for the msspx modules (timer2 only) see figure 17-1 for a block diagram of timer2/4/6. figure 17-1: timer2/4/6 block diagram comparator tmrx sets flag tmrx output reset postscaler prescaler prx 2 f osc /4 1:1 to 1:16 1:1, 1:4, 1:16, 1:64 eq 4 bit tmrxif txoutps<3:0> txckps<1:0>
pic16f193x/lf193x ds41364c-page 176 preliminary ? 2009 microchip technology inc. 17.1 timer2/4/6 operation the clock input to the timer2/4/6 modules is the system instruction clock (f osc /4). tmrx increments from 00h on each clock edge. a 4-bit counter/prescaler on the clock input allows direct input, divide-by-4 and divide-by-16 prescale options. these options are selected by the prescaler control bits, txckps<1:0> of the txcon register. the value of tmrx is compared to that of the period register, prx, on each clock cycle. when the two values match, the comparator generates a match signal as the timer output. this signal also resets the value of tmrx to 00h on the next cycle and drives the output counter/postscaler (see section 17.2 ?timer2/4/6 interrupt? ). the tmrx and prx registers are both directly readable and writable. the tmrx register is cleared on any device reset, whereas the prx register initializes to ffh. both the prescaler and postscaler counters are cleared on the following events: ? a write to the tmrx register ? a write to the txcon register ? power-on reset (por) ? brown-out reset (bor) ?mclr reset ? watchdog timer (wdt) reset ? stack overflow reset ? stack underflow reset ? reset instruction 17.2 timer2/4/6 interrupt timer2/4/6 can also generate an optional device interrupt. the timer2/4/6 output signal (tmrx-to-prx match) provides the input for the 4-bit counter/postscaler. this counter generates the tmrx match interrupt flag which is latched in tmrxif of the pirx register. the interrupt is enabled by setting the tmrx match interrupt enable bit, tmrxie of the piex register. a range of 16 postscale options (from 1:1 through 1:16 inclusive) can be selected with the postscaler control bits, txoutps<3:0>, of the txcon register. 17.3 timer2/4/6 output the unscaled output of tmrx is available primarily to the ccp modules, where it is used as a time base for operations in pwm mode. timer2 can be optionally used as the shift clock source for the msspx modules operating in spi mode. additional information is provided in section 17.0 ?ssp module overview? 17.4 timer2/4/6 operation during sleep the timerx timers cannot be operated while the processor is in sleep mode. the contents of the tmrx and prx registers will remain unchanged while the processor is in sleep mode. note: tmrx is not cleared when txcon is written.
? 2009 microchip technology inc. preliminary ds41364c-page 177 pic16f193x/lf193x register 17-1: txcon: timer2 -type timer control register u-0 r/w-0/u r/w-0/u r/w-0/u r/w-0/u r/w-0/u r/w-0/u r/w-0/u ? toutps3 toutps2 toutps1 toutps0 tmrxon txckps1 txckps0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 unimplemented: read as ? 0 ? bit 6-3 toutps<3:0>: timer output postscaler select bits 0000 = 1:1 postscaler 0001 = 1:2 postscaler 0010 = 1:3 postscaler 0011 = 1:4 postscaler 0100 = 1:5 postscaler 0101 = 1:6 postscaler 0110 = 1:7 postscaler 0111 = 1:8 postscaler 1000 = 1:9 postscaler 1001 = 1:10 postscaler 1010 = 1:11 postscaler 1011 = 1:12 postscaler 1100 = 1:13 postscaler 1101 = 1:14 postscaler 1110 = 1:15 postscaler 1111 = 1:16 postscaler bit 2 tmrxon: timerx on bit 1 =timerx is on 0 =timerx is off bit 1-0 txckps<1:0>: timer2-type clock prescale select bits 00 = prescaler is 1 01 = prescaler is 4 10 = prescaler is 16 11 = prescaler is 64
pic16f193x/lf193x ds41364c-page 178 preliminary ? 2009 microchip technology inc. table 17-1: summary of registers associated with timer2/4/6 name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page ccp1con ? ? dc1b1 dc1b0 ccp1m3 ccp1m2 ccp1m1 ccp1m0 186 ccp2con ? ? dc2b1 dc2b0 ccp2m3 ccp2m2 ccp2m1 ccp2m0 186 intcon gie peie tmr0ie inte rbie tmr0if intf rbif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 pie3 ? ccp5ie ccp4ie ccp3ie tmr6ie ?tmr4ie ? 78 pir3 ? ccp5if ccp4if ccp3if tmr6if ?tmr4if ? 81 pr2 timer2 module period register 175* tmr2 holding register for the 8-bit tmr2 register 175* t2con ? toutps3 toutps2 toutps1 toutps0 tmr2on t2ckps1 t2ckps0 177 legend: x = unknown, u = unchanged, - = unimplemented read as ? 0 ?. shaded cells are not used for timer2 module. * page provides register information.
? 2009 microchip technology inc. preliminary ds41364c-page 179 pic16f193x/lf193x 18.0 capacitive sensing module the capacitive sensing module allows for an interaction with an end user without a mechanical interface. in a typical application, the capacitive sensing module is attached to a pad on a printed circuit board (pcb), which is electrically isolated from the end user. when the end user places their finger over the pcb pad, a capacitive load is added, causing a frequency shift in the capacitive sensing module. the capacitive sensing module requires software and at least one timer resource to determine the change in frequency. key features of this module include: ? analog mux for monitoring multiple inputs ? capacitive sensing oscillator ? multiple timer resources ? software control ? operation during sleep figure 18-1: capacitive sensing block diagram tmr0cs cps0 cps1 cps2 cps3 cps4 cps5 cps6 cps7 cps8 (1) cps9 (1) cps10 (1) cpsch<3:0> (2) capacitive sensing oscillator cpsosc cpson cpsrng<1:0> tmr0 0 1 set tmr0if overflow t0xcs 0 1 t0cki t1cs<1:0> t1osc/ t1cki tmr1h:tmr1l en t1gsel<1:0> timer1 gate control logic t1g cpsout cps11 (1) cps12 (1) cps13 (1) cps14 (1) cps15 (1) cpsclk note 1: reference register 18-2 for channels implemented on each device 2: cpsch3 is not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938. 3: if cpson = 0 , disabling capacitive sensing, no channel is selected. f osc /4 f osc f osc /4 timer0 module timer1 module cpson (3) cps16 (1) syncc1out syncc2out
pic16f193x/lf193x ds41364c-page 180 preliminary ? 2009 microchip technology inc. 18.1 analog mux the capacitive sensing module can monitor up to 16 inputs. the capacitive sensing inputs are defined as cps<15:0>. to determine if a frequency change has occurred the user must: ? select the appropriate cps pin by setting the cpsch<3:0> bits of the cpscon1 register ? set the corresponding ansel bit ? set the corresponding tris bit ? run the software algorithm selection of the cpsx pin while the module is enabled will cause the capacitive sensing oscillator to be on the cpsx pin. failure to set the corresponding ansel and tris bits can cause the capacitive sensing oscillator to stop, leading to false frequency readings. 18.2 capacitive sensing oscillator the capacitive sensing oscillator consists of a constant current source and a constant current sink, to produce a triangle waveform. the cpsout bit of the cpscon0 register shows the status of the capacitive sensing oscillator, whether it is a sinking or sourcing current. the oscillator is designed to drive a capacitive load (single pcb pad) and at the same time, be a clock source to either timer0 or timer1. the oscillator has three different current settings as defined by cpsrng<1:0> of the cpscon0 register. the different current settings for the oscillator serve two purposes: ? maximize the number of counts in a timer for a fixed time base ? maximize the count differential in the timer during a change in frequency 18.3 timer resources to measure the change in frequency of the capacitive sensing oscillator, a fixed time base is required. for the period of the fixed time base, the capacitive sensing oscillator is used to clock either timer0 or timer1. the frequency of the capacitive sensing oscillator is equal to the number of counts in the timer divided by the period of the fixed time base. 18.4 fixed time base to measure the frequency of the capacitive sensing oscillator, a fixed time base is required. any timer resource or software loop can be used to establish the fixed time base. it is up to the end user to determine the method in which the fixed time base is generated. 18.4.1 timer0 to select timer0 as the timer resource for the capacitive sensing module: ? set the t0xcs bit of the cpscon0 register ? clear the tmr0cs bit of the option register when timer0 is chosen as the timer resource, the capacitive sensing oscillator will be the clock source for timer0. refer to section 15.0 ?timer0 module? for additional information. 18.4.2 timer1 to select timer1 as the timer resource for the capacitive sensing module, set the tmr1cs<1:0> of the t1con register to ? 11 ?. when timer1 is chosen as the timer resource, the capacitive sensing oscillator will be the clock source for timer1. because the timer1 module has a gate control, developing a time base for the frequency measurement can be simplified by using the timer0 overflow flag. it is recommend that the timer0 overflow flag, in con- junction with the toggle mode of the timer1 gate, be used to develop the fixed time base required by the software portion of the capacitive sensing module. refer to section 16.12 ?timer1 gate control regis- ter? for additional information. table 18-1: timer1 enable function note: the fixed time base can not be generated by the timer resource that the capacitive sensing oscillator is clocking. tmr1on tmr1ge timer1 operation 00 off 01 off 10 on 11 count enabled by input
? 2009 microchip technology inc. preliminary ds41364c-page 181 pic16f193x/lf193x 18.5 software control the software portion of the capacitive sensing module is required to determine the change in frequency of the capacitive sensing oscillator. this is accomplished by the following: ? setting a fixed time base to acquire counts on timer0 or timer1 ? establishing the nominal frequency for the capacitive sensing oscillator ? establishing the reduced frequency for the capacitive sensing oscillator due to an additional capacitive load ? set the frequency threshold 18.5.1 nominal frequency (no capacitive load) to determine the nominal frequency of the capacitive sensing oscillator: ? remove any extra capacitive load on the selected cpsx pin ? at the start of the fixed time base, clear the timer resource ? at the end of the fixed time base save the value in the timer resource the value of the timer resource is the number of oscillations of the capacitive sensing oscillator for the given time base. the frequency of the capacitive sensing oscillator is equal to the number of counts on in the timer divided by the period of the fixed time base. 18.5.2 reduced frequency (additional capacitive load) the extra capacitive load will cause the frequency of the capacitive sensing oscillator to decrease. to determine the reduced frequency of the capacitive sensing oscillator: ? add a typical capacitive load on the selected cpsx pin ? use the same fixed time base as the nominal frequency measurement ? at the start of the fixed time base, clear the timer resource ? at the end of the fixed time base save the value in the timer resource the value of the timer resource is the number of oscil- lations of the capacitive sensing oscillator with an addi- tional capacitive load. the frequency of the capacitive sensing oscillator is equal to the number of counts on in the timer divided by the period of the fixed time base. this frequency should be less than the value obtained during the nominal frequency measurement. 18.5.3 frequency threshold the frequency threshold should be placed midway between the value of nominal frequency and the reduced frequency of the capacitive sensing oscillator. refer to application note an1103, ? software handling for capacitive sensing ? (ds01103) for more detailed information on the software required for capacitive sensing module. 18.6 operation during sleep the capacitive sensing oscillator will continue to run as long as the module is enabled, independent of the part being in sleep. in order for the software to determine if a frequency change has occurred, the part must be awake. however, the part does not have to be awake when the timer resource is acquiring counts. note: for more information on general capacitive sensing refer to application notes: ? an1101, ? introduction to capacitive sensing ? (ds01101) ? an1102, ? layout and physical design guidelines for capacitive sensing ? (ds01102) note: timer0 does not operate when in sleep, and therefore cannot be used for capacitive sense measurements in sleep.
pic16f193x/lf193x ds41364c-page 182 preliminary ? 2009 microchip technology inc. register 18-1: cpscon0: capaciti ve sensing control register 0 r/w-0/0 u-0 u-0 u-0 r/w-0/0 r/w-0/0 r-0/0 r/w-0/0 cpson ? ? ? cpsrng1 cpsrng0 cpsout t0xcs bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 cpson: capacitive sensing module enable bit 1 = capacitive sensing module is operating 0 = capacitive sensing module is shut off and consumes no operating current bit 6-4 unimplemented: read as ? 0 ? bit 3-2 cpsrng<1:0>: capacitive sensing oscillator range bits 00 = oscillator is off 01 = oscillator is in low range. charge/discharge current is nominally 0.1 a. 10 = oscillator is in medium range. charge/discharge current is nominally 1.2 a. 11 = oscillator is in high range. charge/discharge current is nominally 18 a. bit 1 cpsout: capacitive sensing oscillator status bit 1 = oscillator is sourcing current (current flowing out the pin) 0 = oscillator is sinking current (current flowing into the pin) bit 0 t0xcs: timer0 external clock source select bit if tmr0c s = 1 the t0xcs bit controls which clock external to the core/timer0 module supplies timer0: 1 = timer0 clock source is the capacitive sensing oscillator 0 = timer0 clock source is the t0cki pin if tmr0c s = 0 timer0 clock source is controlled by the core/timer0 module and is f osc /4
? 2009 microchip technology inc. preliminary ds41364c-page 183 pic16f193x/lf193x table 18-2: summary of registers as sociated with capacitive sensing register 18-2: cpscon1: capaciti ve sensing control register 1 u-0 u-0 u-0 r/w-0/0 (1, 2) r/w-0/0 (1) r/w-0/0 r/w-0/0 r/w-0/0 ? ? ? cpsch4 cpsch3 cpsch2 cpsch1 cpsch0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-4 unimplemented: read as ? 0 ? bit 3-0 cpsch<3:0>: capacitive sensing channel select bits if cpson = 0 : these bits are ignored. no channel is selected. if cpson = 1 : 0000 = channel 0, (cps0) 0001 = channel 1, (cps1) 0010 = channel 2, (cps2) 0011 = channel 3, (cps3) 0100 = channel 4, (cps4) 0101 = channel 5, (cps5) 0110 = channel 6, (cps6) 0111 = channel 7, (cps7) 1000 = channel 8, (cps8 (1) ) 1001 = channel 9, (cps9 (1) ) 1010 = channel 10, (cps10 (1) ) 1011 = channel 11, (cps11 (1) ) 1100 = channel 12, (cps12 (1) ) 1101 = channel 13, (cps13 (1) ) 1110 = channel 14, (cps14 (1) ) 1111 = channel 15, (cps15 (1) ) note 1: these channels are not implemented on the pic16f1933/1936/1938/pic16lf1933/1936/1938. 2: this bit is not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938, read as ? 0 ? name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page ansela ? ? ansa5 ansa4 ansa3 ansa2 ansa1 ansa0 88 anselb ? ? ansb5 ansb4 ansb3 ansb2 ansb1 ansb0 93 anseld ansd7 ansd6 ansd5 ansd4 ansd3 ansd2 ansd1 ansd0 99 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 option_reg wpuen intedg tmr0cs tmr0se psa ps2 ps1 ps0 53 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on 171 txcon ? toutps3 toutps2 toutps1 toutps0 tmrxon txckps1 txckps0 177 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 88 trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 93 trisd trisd7 trisd6 trisd5 trisd4 trisd3 trisd2 trisd1 trisd0 99 legend: - = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are no t used by the capacitive sensing module.
pic16f193x/lf193x ds41364c-page 184 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 185 pic16f193x/lf193x 19.0 capture/compare/pwm modules (eccp1, eccp2, eccp3, ccp4, ccp5) this device contains three enhanced capture/compare/pwm (eccp1, eccp2, eccp3) and two standard capture/compare/pwm module (ccp4 and ccp5). the ccp4 and ccp5 modules are identical in operation. the eccp1, eccp2 and eccp3 modules may also be referred to as ccp1, ccp2, ccp3, as required.
pic16f193x/lf193x ds41364c-page 186 preliminary ? 2009 microchip technology inc. 19.1 capture/compare/pwm the capture/compare/pwm module is a peripheral which allows the user to time and control different events. in capture mode, the peripheral allows the timing of the duration of an event. the compare mode allows the user to trigger an external event when a predetermined amount of time has expired. the pwm mode can generate a pulse-width modulated signal of varying frequency and duty cycle. table 19-1 shows the timer resources required by the ccp module. table 19-1: required timer resources ccp mode timer resource capture timer1 compare timer1 pwm timer2 or 4 or 6 register 19-1: ccpxcon: ccpx control register r/w-00 r/w-0/0 r/w-0/0 r/w-0/0 r/ w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 pxm1 (1) pxm0 (1) dcxb1 dcxb0 ccpxm3 ccpxm2 ccpxm1 ccpxm0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other reset ?1? = bit is set ?0? = bit is cleared bit 7-6 pxm<1:0>: enhanced pwm output configuration bits (1) i f ccpxm<3:2> = 00 , 01 , 10 : xx = pxa assigned as capture/compare input ; pxb, pxc, pxd assigned as port pins if ccpxm<3:2> = 11 : 00 = single output; pxa modulated; pxb, pxc, pxd assigned as port pins 01 = full-bridge output forward; p1d modulated; p1a active; p1b, p1c inactive 10 = half-bridge output; p1a, p1b modulated with dead-band control; p1c, p1d assigned as port pins 11 = full-bridge output reverse; p1b modulated; p1c active; p1a, p1d inactive bit 5-4 dcxb<1:0>: pwm duty cycle least significant bits capture mode: unused compare mode: unused pwm mode: these bits are the two lsbs of the pwm duty cycle. the eight msbs are found in ccprxl. bit 3-0 ccpxm<3:0>: eccpx mode select bits 0000 = capture/compare/pwm off (resets eccpx module) 0001 = reserved 0010 = compare mode: toggle output on match 0011 = capture mode 0100 = capture mode: every falling edge 0101 = capture mode: every rising edge 0110 = capture mode: every 4th rising edge 0111 = capture mode: every 16th rising edge 1000 = compare mode: initialize eccpx pin low; set output on compare match (set ccpxif) 1001 = compare mode: initialize eccpx pin high; clear output on compare match (set ccpxif) 1010 = compare mode: generate software interrupt only; eccpx pin reverts to i/o state 1011 = compare mode: trigger special event (eccpx resets tmr1, sets ccpxif bit, ccp5 trigger also starts a/d conversion if a/d module is enabled) (1) ccp 4 and ccp5 o nly: 11xx =pwm mode eccp1, eccp2, eccp3 o nly: 1100 = pwm mode: pxa, pxc active-high; pxb, pxd active-high 1101 = pwm mode: pxa, pxc active-high; pxb, pxd active-low 1110 = pwm mode: pxa, pxc active-low; pxb, pxd active-high 1111 = pwm mode: pxa, pxc active-low; pxb, pxd active-low note 1: these bits are not implemented on ccp4 and ccp5.
? 2009 microchip technology inc. preliminary ds41364c-page 187 pic16f193x/lf193x 19.2 ccp clock selection the pic16f193x/lf193x allows each individual ccp module to select the timer source that controls the ccp module. each module has an independent selection. as the pic16f193x/lf193x has only one 16-bit timer (timer1), the capture and compare modes of the ccp modules always uses timer1. as there are three 8-bit timers with auto-reload (timer2, timer4 and timer6), pwm mode on the ccp modules can use any of these timers. the following registers are used to select which timer is used: ? ccp timers control register 0 (ccptmrs0) ? ccp timers control register 1 (ccptmrs1) register 19-2: ccptmrs0: ccp timers control register 0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 c4tsel1 c4tsel0 c3tsel1 c3tsel0 c2tsel1 c2tsel0 c1tsel1 c1tsel0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-6 c4tsel<1:0>: ccp4 timer selection 00 = ccp4 is based off timer 2 in pwm mode 01 = ccp4 is based off timer 4 in pwm mode 10 = ccp4 is based off timer 6 in pwm mode 11 =reserved bit 5-4 c3tsel<1:0>: ccp3 timer selection 00 = ccp3 is based off timer 2 in pwm mode 01 = ccp3 is based off timer 4 in pwm mode 10 = ccp3 is based off timer 6 in pwm mode 11 =reserved bit 3-2 c2tsel<1:0>: ccp2 timer selection 00 = ccp2 is based off timer 2 in pwm mode 01 = ccp2 is based off timer 4 in pwm mode 10 = ccp2 is based off timer 6 in pwm mode 11 =reserved bit 1-0 c1tsel<1:0>: ccp1 timer selection 00 = ccp1 is based off timer 2 in pwm mode 01 = ccp1 is based off timer 4 in pwm mode 10 = ccp1 is based off timer 6 in pwm mode 11 =reserved
pic16f193x/lf193x ds41364c-page 188 preliminary ? 2009 microchip technology inc. register 19-3: ccptmrs1: ccp timers control register 1 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0/0 r/w-0/0 ? ? ? ? ? ? c5tsel1 c5tsel0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-2 unimplemented: read as ? 0 ? bit 1-0 c5tsel<1:0>: ccp5 timer selection 00 = ccp5 is based off timer 2 in pwm mode 01 = ccp5 is based off timer 4 in pwm mode 10 = ccp5 is based off timer 6 in pwm mode 11 =reserved
? 2009 microchip technology inc. preliminary ds41364c-page 189 pic16f193x/lf193x 19.3 capture mode in capture mode, the ccprxh, ccprxl register pair captures the 16-bit value of the tmr1 register when an event occurs on pin ccpx. an event is defined as one of the following and is configured by the ccpxm<3:0> bits of the ccpxcon register: ? every falling edge ? every rising edge ? every 4th rising edge ? every 16th rising edge when a capture is made, the interrupt request flag bit ccpxif of the pirx register is set. the interrupt flag must be cleared in software. if another capture occurs before the value in the ccprxh, ccprxl register pair is read, the old captured value is overwritten by the new captured value (see figure 19-1). 19.3.1 ccpx pin configuration in capture mode, the ccpx pin should be configured as an input by setting the associated tris control bit. also, the ccpx pin function can be moved to alternative pins using the apfcon register. refer to section 6.1 ?alternate pin function? for more details. figure 19-1: capture mode operation block diagram 19.3.2 timer1 mode selection timer1 must be running in timer mode or synchronized counter mode for the ccp module to use the capture feature. in asynchronous counter mode, the capture operation may not work. 19.3.3 software interrupt mode when the capture mode is changed, a false capture interrupt may be generated. the user should keep the ccpxie interrupt enable bit of the piex register clear to avoid false interrupts. additionally, the user should clear the ccpxif interrupt flag bit of the pirx register following any change in operating mode. 19.3.4 ccp prescaler there are four prescaler settings specified by the ccpxm<3:0> bits of the ccpxcon register. whenever the ccp module is turned off, or the ccp module is not in capture mode, the prescaler counter is cleared. any reset will clear the prescaler counter. switching from one capture prescaler to another does not clear the prescaler and may generate a false interrupt. to avoid this unexpected operation, turn the module off by clearing the ccpxcon register before changing the prescaler (see example 19-1). example 19-1: changing between capture prescalers 19.3.5 capture during sleep capture mode depends upon the timer1 module for proper operation. there are two options for driving the timer1 module in capture mode. it can be driven by the instruction clock (f osc /4), or by an external clock source. if timer1 is clocked by f osc /4, then timer1 will not increment during sleep. when the device wakes from sleep, timer1 will continue from its previous state. if timer1 is clocked by an external clock source, then capture mode will operate as defined in section 19.1 ?capture/compare/pwm? . note: if the ccpx pin is configured as an output, a write to the port can cause a capture condition. ccprxh ccprxl tmr1h tmr1l set flag bit ccpxif (pirx register) capture enable ccpxcon<3:0> prescaler 1, 4, 16 and edge detect pin ccpx system clock (f osc ) note: clocking timer1 from the system clock (f osc ) should not be used in capture mode. in order for capture mode to recognize the trigger event on the ccpx pin, timer1 must be clocked from the instruction clock (f osc /4) or from an external clock source. banksel ccp1con ;set bank bits to point ;to ccp1con clrf ccp1con ;turn ccp module off movlw new_capt_ps ;load the w reg with ;the new prescaler ;move value and ccp on movwf ccp1con ;load ccp1con with this ;value
pic16f193x/lf193x ds41364c-page 190 preliminary ? 2009 microchip technology inc. table 19-2: registers associated with capture name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page ccpxcon pxm1 (1) pxm0 (1) dcxb1 dcxb0 ccpxm3 ccpxm2 ccpxm1 ccpxm0 186 ccprxl capture/compare/pwm register x low byte (lsb) 189 ccprxh capture/compare/pwm register x high byte (msb) 189 cm1con0 c1on c1out c1oe c1pol ? c1sp c1hys c1sync 150 cm1con1 c1intp c1intn c1pch1 c1pch0 ? ? c1nch1 c1nch0 151 cm2con0 c2on c2out c2oe c2pol ? c2sp c2hys c2sync 150 cm2con1 c2intp c2intn c2pch1 c2pch0 ? ? c2nch1 c2nch0 151 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pie2 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie 77 pie3 ? ccp5ie ccp4ie ccp3ie tmr6ie ?tmr4ie ? 78 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 pir2 osfif c2if c1if eeif bclif lcdif ?ccp2if 80 pir3 ? ccp5if ccp4if ccp3if tmr6if ? tmr4if ? 81 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on 171 t1gcon tmr1ge t1gpol t1gtm t1gspm t1ggo/done t1gval t1gss1 t1gss0 172 tmr1l holding register for the least significant byte of the 16-bit tmr1 register 167 tmr1h holding register for the most significant byte of the 16-bit tmr1 register 167 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 88 trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 93 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 trisd trisd7 trisd6 trisd5 trisd4 trisd3 trisd2 trisd1 trisd0 99 trise ? ? ? ? trise3 trise2 (2) trise1 (2) trise0 (2) 103 legend: ? = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the capture and compare. note 1: applies to eccp modules only.
? 2009 microchip technology inc. preliminary ds41364c-page 191 pic16f193x/lf193x 19.4 compare mode in compare mode, the 16-bit ccprx register value is constantly compared against the tmr1 register pair value. when a match occurs, the ccpx module may: ? toggle the ccpx output ? set the ccpx output ? clear the ccpx output ? generate a special event trigger ? generate a software interrupt the action on the pin is based on the value of the ccpxm<3:0> control bits of the ccpxcon register. at the same time, the interrupt flag ccpxif bit is set. all compare modes can generate an interrupt. figure 19-2: compare mode operation block diagram 19.4.1 ccpx pin configuration the user must configure the ccpx pin as an output by clearing the associated tris bit. also, the ccpx pin function can be moved to alternative pins using the apfcon register. refer to section 6.1 ?alternate pin function? for more details. 19.4.2 timer1 mode selection in compare mode, timer1 must be running in either timer mode or synchronized counter mode. the compare operation may not work in asynchronous counter mode. 19.4.3 software interrupt mode when generate software interrupt mode is chosen (ccpxm<3:0> = 1010 ), the ccpx module does not assert control of the ccpx pin (see the ccp1con register). 19.4.4 special event trigger when special event trigger mode is chosen (ccpxm<3:0> = 1011 ), the ccpx module does the following: ? resets timer1 ? starts an adc conversion if adc is enabled (ccp5 only) the ccpx module does not assert control of the ccpx pin in this mode (see the ccpxcon register). the special event trigger output of the ccp occurs immediately upon a match between the tmr1h, tmr1l register pair and the ccprxh, ccprxl register pair. the tmr1h, tmr1l register pair is not reset until the next rising edge of the timer1 clock. the special event trigger output starts an a/d conversion (if the a/d module is enabled). this feature is only available on ccp5). this allows the ccprxh, ccprxl register pair to effectively provide a 16-bit programmable period register for timer1. 19.4.5 compare during sleep the compare mode is dependent upon the system clock (f osc ) for proper operation. since f osc is shut down during sleep mode, the compare mode will not function properly during sleep. note: clearing the ccpxcon register will force the ccpx compare output latch to the default low level. this is not the port i/o data latch. ccprxh ccprxl tmr1h tmr1l comparator qs r output logic special event trigger set ccpxif interrupt flag (pirx) match tris ccpxcon<3:0> mode select output enable pin special event trigger will: ? ccp<4:1>: reset timer1, but not set interrupt flag bit tmr1if. ? ccp5: reset timer1, but not set interrupt flag bit and set bit go/done (adcon0<1>). ccpx 4 note: clocking timer1 from the system clock (f osc ) should not be used in capture mode. in order for capture mode to recognize the trigger event on the ccpx pin, timer1 must be clocked from the instruction clock (f osc /4) or from an external clock source. note 1: the special event trigger from the ccp module does not set interrupt flag bit tmr1if of the pir1 register. 2: removing the match condition by changing the contents of the ccprxh and ccprxl register pair, between the clock edge that generates the special event trigger and the clock edge that generates the timer1 reset, will preclude the reset from occurring.
pic16f193x/lf193x ds41364c-page 192 preliminary ? 2009 microchip technology inc. table 19-3: registers associated with compare name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page ccpxcon pxm1 (1) pxm0 (1) dcxb1 dcxb0 ccpxm3 ccpxm2 ccpxm1 ccpxm0 186 ccprxl capture/compare/pwm register x low byte (lsb) 189 ccprxh capture/compare/pwm register x high byte (msb) 189 cm1con0 c1on c1out c1oe c1pol ? c1sp c1hys c1sync 150 cm1con1 c1intp c1intn c1pch1 c1pch0 ? ? c1nch1 c1nch0 151 cm2con0 c2on c2out c2oe c2pol ? c2sp c2hys c2sync 150 cm2con1 c2intp c2intn c2pch1 c2pch0 ? ? c2nch1 c2nch0 151 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pie2 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie 77 pie3 ? ccp5ie ccp4ie ccp3ie tmr6ie ?tmr4ie ? 78 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 pir2 osfif c2if c1if eeif bclif lcdif ?ccp2if 80 pir3 ? ccp5if ccp4if ccp3if tmr6if ? tmr4if ? 81 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ?tmr1on 171 t1gcon tmr1ge t1gpol t1gtm t1gspm t1ggo/done t1gval t1gss1 t1gss0 172 tmr1l holding register for the least significant byte of the 16-bit tmr1 register 167 tmr1h holding register for the most significant byte of the 16-bit tmr1 register 167 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 88 trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 93 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 trisd trisd7 trisd6 trisd5 trisd4 trisd3 trisd2 trisd1 trisd0 99 trise ? ? ? ? trise3 trise2 (2) trise1 (2) trise0 (2) 103 legend: ? = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the capture and compare. note 1: applies to eccp modules only. 2: these bits are not implemented on pic16f1933/1936/1938/pic16lf1933/1936/1938 devices, read as ? 0 ?.
? 2009 microchip technology inc. preliminary ds41364c-page 193 pic16f193x/lf193x 19.5 pwm mode the pwm mode generates a pulse-width modulated signal on the ccpx pin. the duty cycle, period and resolution are determined by the following registers: ?prx ?txcon ? ccprxl ? ccpxcon the eccp modules have the following additional registers: ? eccpxas ? pstrxcon ?pwmxcon in pulse-width modulation (pwm) mode, the ccpx module produces up to a 10-bit resolution pwm output on the ccpx pin. since the ccpx pin is multiplexed with the port data latch, the tris for that pin must be cleared to enable the ccpx pin output driver. the ccpx module in pwm mode can have the pwm based off of either timer2, timer4 or timer6. this is controlled by the ccptmrs0 and ccptmrs1 registers. reference section 19.2 ?ccp clock selection? for more information. figure 19-3 shows a simplified block diagram of pwm operation. figure 19-4 shows a typical waveform of the pwm signal. for a step-by-step procedure on how to set up the ccp module for pwm operation, see section 19.5.7 ?setup for pwm operation? . figure 19-3: simplified pwm block diagram the pwm output (figure 19-4) has a time base (period) and a time that the output stays high (duty cycle). figure 19-4: ccp pwm output note: clearing the ccpxcon register will relinquish ccpx control of the ccpx pin. ccprxl ccprxh (2) (slave) comparator tmrx prx (1) rq s duty cycle registers ccpxcon<5:4> clear timerx, toggle ccpx pin and latch duty cycle note 1: the 8-bit timer tmr2 register is concatenated with the 2-bit internal system clock (f osc ), or 2 bits of the prescaler, to create the 10-bit time base. 2: in pwm mode, ccprxh is a read-only register. tris ccpx comparator period pulse width tmrx = 0 tmrx\2 = ccprxh:ccpxcon<5:4> tmrx = prx
pic16f193x/lf193x ds41364c-page 194 preliminary ? 2009 microchip technology inc. 19.5.1 pwm period the pwm period is specified by the prx register of timerx. the pwm period can be calculated using the formula of equation 19-1. equation 19-1: pwm period when tmrx is equal to prx, the following three events occur on the next increment cycle: ? tmrx is cleared ? the ccpx pin is set. (exception: if the pwm duty cycle = 0%, the pin will not be set.) ? the pwm duty cycle is latched from ccprxl into ccprxh. 19.5.2 pwm duty cycle the pwm duty cycle is specified by writing a 10-bit value to multiple registers: ccprxl register and dcxb<1:0> bits of the ccpxcon register. the ccprxl contains the eight msbs and the dcxb<1:0> bits of the ccpxcon register contain the two lsbs. ccprxl and dcxb<1:0> bits of the ccpxcon register can be written to at any time. the duty cycle value is not latched into ccprxh until after the period completes (i.e., a match between prx and tmrx registers occurs). while using the pwm, the ccprxh register is read-only. equation 19-2 is used to calculate the pwm pulse width. equation 19-3 is used to calculate the pwm duty cycle ratio. equation 19-2: pulse width equation 19-3: duty cycle ratio the ccprxh register and a 2-bit internal latch are used to double buffer the pwm duty cycle. this double buffering is essential for glitchless pwm operation. the 8-bit timer tmrx register is concatenated with either the 2-bit internal system clock (f osc ), or 2 bits of the prescaler, to create the 10-bit time base. the system clock is used if the timerx prescaler is set to 1:1. when the 10-bit time base matches the ccprxh and 2-bit latch, then the ccpx pin is cleared (see figure 19-3). note: the timerx postscaler (see section 17.1 ?timer2/4/6 operation? ) is not used in the determination of the pwm frequency. pwm period pr2x () 1 + [] 4t osc ? ? ? = (tmrx prescale value) note 1: t osc = 1/f osc pulse width ccprxl:ccpxcon<5:4> () ? = t osc ? (tmrx prescale value) duty cycle ratio ccprxl:ccpxcon<5:4> () 4 prx 1 + () ---------------------------------------------------------------------- - =
? 2009 microchip technology inc. preliminary ds41364c-page 195 pic16f193x/lf193x 19.5.3 pwm resolution the resolution determines the number of available duty cycles for a given period. for example, a 10-bit resolution will result in 1024 discrete duty cycles, whereas an 8-bit resolution will result in 256 discrete duty cycles. the maximum pwm resolution is 10 bits when prx is 255. the resolution is a function of the prx register value as shown by equation 19-4. equation 19-4: pwm resolution table 19-4: example pwm frequencies and resolutions (f osc = 32 mhz) table 19-5: example pwm frequencies and resolutions (f osc = 20 mhz) table 19-6: example pwm frequencies and resolutions (f osc = 8 mhz) note: if the pulse width value is greater than the period the assigned pwm pin(s) will remain unchanged. resolution 4prx 1 + () [] log 2 () log ----------------------------------------- - bits = pwm frequency 1.95 khz 7.81 khz 31.25 khz 125 khz 250 khz 333.3 khz timer prescale (1, 4, 16) 16 4 1 1 1 1 prx value 0xff 0xff 0xff 0x3f 0x1f 0x17 maximum resolution (bits) 10 10 10 8 7 6.6 pwm frequency 1.22 khz 4.88 khz 19.53 khz 78.12 khz 156.3 khz 208.3 khz timer prescale (1, 4, 16) 16 4 1 1 1 1 prx value 0xff 0xff 0xff 0x3f 0x1f 0x17 maximum resolution (bits) 10 10 10 8 7 6.6 pwm frequency 1.22 khz 4.90 khz 19.61 khz 76.92 khz 153.85 khz 200.0 khz timer prescale (1, 4, 16) 16 4 1 1 1 1 prx value 0x65 0x65 0x65 0x19 0x0c 0x09 maximum resolution (bits) 8 8 8 6 5 5
pic16f193x/lf193x ds41364c-page 196 preliminary ? 2009 microchip technology inc. 19.5.4 operation in sleep mode in sleep mode, the tmrx register will not increment and the state of the module will not change. if the ccpx pin is driving a value, it will continue to drive that value. when the device wakes up, tmrx will continue from its previous state. 19.5.5 changes in system clock frequency the pwm frequency is derived from the system clock frequency. any changes in the system clock frequency will result in changes to the pwm frequency. see section 8.0 ?oscillator module (with fail-safe clock monitor)? for additional details. 19.5.6 effects of reset any reset will force all ports to input mode and the ccp registers to their reset states. 19.5.7 setup for pwm operation the following steps should be taken when configuring the ccp module for pwm operation: 1. disable the pwm pin (ccpx) output driver(s) by setting the associated tris bit(s). 2. load the prx register with the pwm period value. 3. configure the ccp module for the pwm mode by loading the ccpxcon register with the appropriate values. 4. load the ccprxl register and the dcxbx bits of the ccpxcon register, with the pwm duty cycle value. 5. configure and start timerx: ? clear the tmrxif interrupt flag bit of the pirx register. see note below. ? configure the txckps bits of the txcon register with the timerx prescale value. ? enable timerx by setting the tmrxon bit of the t2con register. 6. enable pwm output pin: ? wait until timerx overflows, tmrxif bit of the pir1 register is set. see note below. ? enable the pwm pin (ccpx) output driver(s) by clearing the associated tris bit(s). note: in order to send a complete duty cycle and period on the first pwm output, the above steps must be included in the setup sequence. if it is not critical to start with a complete pwm signal on the first output, then step 6 may be ignored.
? 2009 microchip technology inc. preliminary ds41364c-page 197 pic16f193x/lf193x 19.6 pwm (enhanced mode) the enhanced pwm mode can generate a pwm signal on up to four different output pins with up to 10-bits of resolution. it can do this through four different pwm output modes: ? single pwm ? half-bridge pwm ? full-bridge pwm, forward mode ? full-bridge pwm, reverse mode to select an enhanced pwm mode, the p1m bits of the ccp1con register must be set appropriately. the pwm outputs are multiplexed with i/o pins and are designated p1a, p1b, p1c and p1d. the polarity of the pwm pins is configurable and is selected by setting the ccp1m bits in the ccp1con register appropriately. table 19-7 shows the pin assignments for each enhanced pwm mode. figure 19-5 shows an example of a simplified block diagram of the enhanced pwm module. figure 19-5: example simplified block diagram of the enhanced pwm mode table 19-7: example pin assignments for various pwm enhanced modes note: the pwm enhanced mode is available on the enhanced capture/compare/pwm module (ccp1) only. note: to prevent the generation of an incomplete waveform when the pwm is first enabled, the eccp module waits until the start of a new pwm period before generating a pwm signal. ccprxl ccprxh (slave) comparator tmrx comparator prx (1) rq s duty cycle registers dcxb<1:0> clear timerx, toggle pwm pin and latch duty cycle note 1: the 8-bit timer tmrx register is concatenated with the 2-bit internal q clock, or 2 bits of the prescaler to create the 10-bit time base. trisx ccpx/p1a trisx p1b trisx p1c trisx p1d output controller pxm<1:0> 2 ccpxm<3:0> 4 pwmxcon ccpx/p1a p1b p1c p1d note 1: the tris register value for each pwm output must be configured appropriately. 2: clearing the ccpxcon register will relinquish eccp control of all pwm output pins. 3: any pin not used by an enhanced pwm mode is available for alternate pin functions. eccp mode pxm<1:0> ccpx/p1a p1b p1c p1d single 00 yes (1) yes (1) yes (1) yes (1) half-bridge 10 yes yes no no full-bridge, forward 01 yes yes yes yes full-bridge, reverse 11 yes yes yes yes note 1: pulse steering enables outputs in single mode.
pic16f193x/lf193x ds41364c-page 198 preliminary ? 2009 microchip technology inc. figure 19-6: example pwm (enhanced mode) output relationships (active-high state) 0 period 00 10 01 11 signal prx+1 pxm<1:0> p1a modulated p1a modulated p1b modulated p1a active p1b inactive p1c inactive p1d modulated p1a inactive p1b modulated p1c active p1d inactive pulse width (single output) (half-bridge) (full-bridge, forward) (full-bridge, reverse) delay (1) delay (1) relationships: ? period = 4 * t osc * (prx + 1) * (tmrx prescale value) ? pulse width = t osc * (ccprxl<7:0>:ccpxcon<5:4>) * (tmrx prescale value) ? delay = 4 * t osc * (pwmxcon<6:0>) note 1: dead-band delay is programmed using the pwmxcon register ( section 19.6.6 ?programmable dead-band delay mode? ).
? 2009 microchip technology inc. preliminary ds41364c-page 199 pic16f193x/lf193x figure 19-7: example enhanced pwm outp ut relationships (active-low state) 0 period 00 10 01 11 signal prx+1 pxm<1:0> p1a modulated p1a modulated p1b modulated p1a active p1b inactive p1c inactive p1d modulated p1a inactive p1b modulated p1c active p1d inactive pulse width (single output) (half-bridge) (full-bridge, forward) (full-bridge, reverse) delay (1) delay (1) relationships: ? period = 4 * t osc * (prx + 1) * (tmrx prescale value) ? pulse width = t osc * (ccprxl<7:0>:ccpxcon<5:4>) * (tmrx prescale value) ? delay = 4 * t osc * (pwmxcon<6:0>) note 1: dead-band delay is programmed using the pwmxcon register ( section 19.6.6 ?programmable dead-band delay mode? ).
pic16f193x/lf193x ds41364c-page 200 preliminary ? 2009 microchip technology inc. 19.6.1 half-bridge mode in half-bridge mode, two pins are used as outputs to drive push-pull loads. the pwm output signal is output on the ccpx/p1a pin, while the complementary pwm output signal is output on the p1b pin (see figure 19-9). this mode can be used for half-bridge applications, as shown in figure 19-9, or for full-bridge applications, where four power switches are being modulated with two pwm signals. in half-bridge mode, the programmable dead-band delay can be used to prevent shoot-through current in half-bridge power devices. the value of the pdc<6:0> bits of the pwmxcon register sets the number of instruction cycles before the output is driven active. if the value is greater than the duty cycle, the corresponding output remains inactive during the entire cycle. see section 19.6.6 ?programmable dead-band delay mode? for more details of the dead-band delay operations. since the p1a and p1b outputs are multiplexed with the port data latches, the associated tris bits must be cleared to configure p1a and p1b as outputs. figure 19-8: example of half-bridge pwm output figure 19-9: example of half-bridge applications period pulse width td td (1) p1a (2) p1b (2) td = dead-band delay period (1) (1) note 1: at this time, the tmrx register is equal to the prx register. 2: output signals are shown as active-high. p1a p1b fet driver fet driver load + - + - fet driver fet driver v+ load fet driver fet driver p1a p1b standard half-bridge circuit (?push-pull?) half-bridge output driving a full-bridge circuit
? 2009 microchip technology inc. preliminary ds41364c-page 201 pic16f193x/lf193x 19.6.2 full-bridge mode in full-bridge mode, all four pins are used as outputs. an example of full-bridge application is shown in figure 19-10. in the forward mode, pin ccpx/p1a is driven to its active state, pin p1d is modulated, while p1b and p1c will be driven to their inactive state as shown in figure 19-11. in the reverse mode, p1c is driven to its active state, pin p1b is modulated, while p1a and p1d will be driven to their inactive state as shown figure 19-11. p1a, p1b, p1c and p1d outputs are multiplexed with the port data latches. the associated tris bits must be cleared to configure the p1a, p1b, p1c and p1d pins as outputs. figure 19-10: example of full-bridge application p1a p1c fet driver fet driver v+ v- load fet driver fet driver p1b p1d qa qb qd qc
pic16f193x/lf193x ds41364c-page 202 preliminary ? 2009 microchip technology inc. figure 19-11: example of full-bridge pwm output period pulse width p1a (2) p1b (2) p1c (2) p1d (2) forward mode (1) period pulse width p1a (2) p1c (2) p1d (2) p1b (2) reverse mode (1) (1) (1) note 1: at this time, the tmrx register is equal to the prx register. 2: output signal is shown as active-high.
? 2009 microchip technology inc. preliminary ds41364c-page 203 pic16f193x/lf193x 19.6.2.1 direction change in full-bridge mode in the full-bridge mode, the pxm1 bit in the ccpxcon register allows users to control the forward/reverse direction. when the application firmware changes this direction control bit, the module will change to the new direction on the next pwm cycle. a direction change is initiated in software by changing the pxm1 bit of the ccpxcon register. the following sequence occurs four timerx cycles prior to the end of the current pwm period: ? the modulated outputs (p1b and p1d) are placed in their inactive state. ? the associated unmodulated outputs (p1a and p1c) are switched to drive in the opposite direction. ? pwm modulation resumes at the beginning of the next period. see figure 19-12 for an illustration of this sequence. the full-bridge mode does not provide dead-band delay. as one output is modulated at a time, dead-band delay is generally not required. there is a situation where dead-band delay is required. this situation occurs when both of the following conditions are true: 1. the direction of the pwm output changes when the duty cycle of the output is at or near 100%. 2. the turn off time of the power switch, including the power device and driver circuit, is greater than the turn on time. figure 19-13 shows an example of the pwm direction changing from forward to reverse, at a near 100% duty cycle. in this example, at time t1, the output p1a and p1d become inactive, while output p1c becomes active. since the turn off time of the power devices is longer than the turn on time, a shoot-through current will flow through power devices qc and qd (see figure 19-10) for the duration of ?t?. the same phenomenon will occur to power devices qa and qb for pwm direction change from reverse to forward. if changing pwm direction at high duty cycle is required for an application, two possible solutions for eliminating the shoot-through current are: 1. reduce pwm duty cycle for one pwm period before changing directions. 2. use switch drivers that can drive the switches off faster than they can drive them on. other options to prevent shoot-through current may exist. figure 19-12: example of pwm direction change pulse width period (1) signal note 1: the direction bit pxm1 of the ccpxcon register is written any time during the pwm cycle. 2: when changing directions, the p1a and p1c signals switch before the end of the current pwm cycle. the modulated p1b and p1d signals are inactive at this time. the length of this time is four timerx counts. period (2) p1a (active-high) p1b (active-high) p1c (active-high) p1d (active-high) pulse width
pic16f193x/lf193x ds41364c-page 204 preliminary ? 2009 microchip technology inc. figure 19-13: example of pwm direct ion change at near 100% duty cycle forward period reverse period p1a t on t off t = t off ? t on p1b p1c p1d external switch d potential shoot-through current note 1: all signals are shown as active-high. 2: t on is the turn on delay of power switch qc and its driver. 3: t off is the turn off delay of pow er switch qd and its driver. external switch c t1 pw pw
? 2009 microchip technology inc. preliminary ds41364c-page 205 pic16f193x/lf193x 19.6.3 start-up considerations when any pwm mode is used, the application hardware must use the proper external pull-up and/or pull-down resistors on the pwm output pins. the ccpxm<1:0> bits of the ccpxcon register allow the user to choose whether the pwm output signals are active-high or active-low for each pair of pwm output pins (p1a/p1c and p1b/p1d). the pwm output polarities must be selected before the pwm pin output drivers are enabled. changing the polarity configuration while the pwm pin output drivers are enable is not recommended since it may result in damage to the application circuits. the p1a, p1b, p1c and p1d output latches may not be in the proper states when the pwm module is initialized. enabling the pwm pin output drivers at the same time as the enhanced pwm modes may cause damage to the application circuit. the enhanced pwm modes must be enabled in the proper output mode and complete a full pwm cycle before enabling the pwm pin output drivers. the completion of a full pwm cycle is indicated by the tmrxif bit of the pirx register being set as the second pwm period begins. 19.6.4 enhanced pwm auto-shutdown mode the pwm mode supports an auto-shutdown mode that will disable the pwm outputs when an external shutdown event occurs. auto-shutdown mode places the pwm output pins into a predetermined state. this mode is used to help prevent the pwm from damaging the application. the auto-shutdown sources are selected using the ccpxas<2:0> bits of the ccpxas register. a shutdown event may be generated by: ?a logic ? 0 ? on the int pin ? comparator cx ? setting the ccpxase bit in firmware a shutdown condition is indicated by the ccpxase (auto-shutdown event status) bit of the ccpxas register. if the bit is a ? 0 ?, the pwm pins are operating normally. if the bit is a ? 1 ?, the pwm outputs are in the shutdown state. when a shutdown event occurs, two things happen: the ccpxase bit is set to ? 1 ?. the ccpxase will remain set until cleared in firmware or an auto-restart occurs (see section 19.6.5 ?auto-restart mode? ). the enabled pwm pins are asynchronously placed in their shutdown states. the pwm output pins are grouped into pairs [p1a/p1c] and [p1b/p1d]. the state of each pin pair is determined by the pssxac and pssxbd bits of the ccpxas register. each pin pair may be placed into one of three states: ? drive logic ? 1 ? ? drive logic ? 0 ? ? tri-state (high-impedance) note: when the microcontroller is released from reset, all of the i/o pins are in the high-impedance state. the external cir- cuits must keep the power switch devices in the off state until the microcontroller drives the i/o pins with the proper signal levels or activates the pwm output(s).
pic16f193x/lf193x ds41364c-page 206 preliminary ? 2009 microchip technology inc. register 19-4: ccpxas: ccpx au to-shutdown control register r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 ccpxase ccpxas2 ccpxas1 ccpxas0 pssxac1 pssxac0 pssxbd1 pssxbd0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 ccpxase: ccpx auto-shutdown event status bit 1 = a shutdown event has occurred; ccpx outputs are in shutdown state 0 = ccpx outputs are operating bit 6-4 ccxpas<2:0>: ccpx auto-shutdown source select bits 000 = auto-shutdown is disabled 001 = comparator c1 output low (1) 010 = comparator c2 output low (1) 011 = either comparator c1 or c2 low (1) 100 =v il on int pin 101 =v il on int pin or comparator c1 low (1) 110 =v il on int pin or comparator c2 low (1) 111 =v il on int pin or comparator c1 or comparator c2 low (1) bit 3-2 pssxacx: pins p1a and p1c shutdown state control bits 00 = drive pins p1a and p1c to ? 0 ? 01 = drive pins p1a and p1c to ? 1 ? 1x = pins p1a and p1c tri-state bit 1-0 pssxbdx: pins p1b and p1d shutdown state control bits 00 = drive pins p1b and p1d to ? 0 ? 01 = drive pins p1b and p1d to ? 1 ? 1x = pins p1b and p1d tri-state note 1: if cxsync is enabled, the shutdown will be delayed by timer1. note 1: the auto-shutdown condition is a level-based signal, not an edge-based signal. as long as the level is present, the auto-shutdown will persist. 2: writing to the ccpxase bit is disabled while an auto-shutdown condition persists. 3: once the auto-shutdown condition has been removed and the pwm restarted (either through firmware or auto-restart) the pwm signal will always restart at the beginning of the next pwm period.
? 2009 microchip technology inc. preliminary ds41364c-page 207 pic16f193x/lf193x figure 19-14: pwm auto-shutdown wi th firmware restart (pxrsen = 0 ) 19.6.5 auto-restart mode the enhanced pwm can be configured to automati- cally restart the pwm signal once the auto-shutdown condition has been removed. auto-restart is enabled by setting the pxrsen bit in the pwmxcon register. if auto-restart is enabled, the ccpxase bit will remain set as long as the auto-shutdown condition is active. when the auto-shutdown condition is removed, the ccpxase bit will be cleared via hardware and normal operation will resume. figure 19-15: pwm auto-shutdown with auto-restart (pxrsen = 1 ) shutdown pwm ccpxase bit activity event shutdown event occurs shutdown event clears pwm resumes pwm period start of pwm period ccpxase cleared by firmware timer overflow timer overflow timer overflow timer overflow missing pulse (auto-shutdown) missing pulse (ccpxase not clear) timer overflow shutdown pwm ccpxase bit activity event shutdown event occurs shutdown event clears pwm period start of pwm period ccpxase cleared by hardware timer overflow timer overflow timer overflow timer overflow missing pulse (auto-shutdown) missing pulse (ccpxase not clear) timer overflow pwm resumes
pic16f193x/lf193x ds41364c-page 208 preliminary ? 2009 microchip technology inc. 19.6.6 programmable dead-band delay mode in half-bridge applications where all power switches are modulated at the pwm frequency, the power switches normally require more time to turn off than to turn on. if both the upper and lower power switches are switched at the same time (one turned on, and the other turned off), both switches may be on for a short period of time until one switch completely turns off. during this brief interval, a very high current ( shoot-through current ) will flow through both power switches, shorting the bridge supply. to avoid this potentially destructive shoot-through current from flowing during switching, turning on either of the power switches is normally delayed to allow the other switch to completely turn off. in half-bridge mode, a digitally programmable dead-band delay is available to avoid shoot-through current from destroying the bridge power switches. the delay occurs at the signal transition from the non-active state to the active state. see figure 19-16 for illustration. the lower seven bits of the associated pwmxcon register (register 19-5) sets the delay period in terms of microcontroller instruction cycles (t cy or 4 t osc ). figure 19-16: example of half-bridge pwm output figure 19-17: example of half-bridge applications period pulse width td td (1) p1a (2) p1b (2) td = dead-band delay period (1) (1) note 1: at this time, the tmrx register is equal to the prx register. 2: output signals are shown as active-high. p1a p1b fet driver fet driver v+ v- load + v - + v - standard half-bridge circuit (?push-pull?)
? 2009 microchip technology inc. preliminary ds41364c-page 209 pic16f193x/lf193x register 19-5: pwmxcon: enhanced pwm control register r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 pxrsen pxdc6 pxdc5 pxdc4 pxdc3 pxdc2 pxdc1 pxdc0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 pxrsen: pwm restart enable bit 1 = upon auto-shutdown, the ccpxase bit clears automatically once the shutdown event goes away; the pwm restarts automatically 0 = upon auto-shutdown, ccpxase must be cleared in software to restart the pwm bit 6-0 pxdc<6:0>: pwm delay count bits pxdcx = number of f osc /4 (4 * t osc ) cycles between the scheduled time when a pwm signal should transition active and the actual time it transitions active note 1: bit resets to ? 0 ? with two-speed start-up and lp, xt or hs selected as the oscillator mode or fail-safe mode is enabled.
pic16f193x/lf193x ds41364c-page 210 preliminary ? 2009 microchip technology inc. 19.6.7 pulse steering mode in single output mode, pulse steering allows any of the pwm pins to be the modulated signal. additionally, the same pwm signal can be simultaneously available on multiple pins. once the single output mode is selected (ccpxm<3:2> = 11 and pxm<1:0> = 00 of the ccpxcon register), the user firmware can bring out the same pwm signal to one, two, three or four output pins by setting the appropriate strx bits of the pstrxcon register, as shown in table 19-7. while the pwm steering mode is active, ccpxm<1:0> bits of the ccpxcon register select the pwm output polarity for the p1 pins. the pwm auto-shutdown operation also applies to pwm steering mode as described in section 19.6.4 ?enhanced pwm auto-shutdown mode? . an auto-shutdown event will only affect pins that have pwm outputs enabled. note: the associated tris bits must be set to output (? 0 ?) to enable the pin output driver in order to see the pwm signal on the pin. register 19-6: pstrxcon: puls e steering control register (1) u-0 u-0 u-0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-1/1 ? ? ? strxsync strxd strxc strxb strxa bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-5 unimplemented: read as ? 0 ? bit 4 strxsync: steering sync bit 1 = output steering update occurs on next pwm period 0 = output steering update occurs at the beginning of the instruction cycle boundary bit 3 strxd: steering enable bit d 1 = p1d pin has the pwm waveform with polarity control from ccpxm<1:0> 0 = p1d pin is assigned to port pin bit 2 strxc: steering enable bit c 1 = p1c pin has the pwm waveform with polarity control from ccpxm<1:0> 0 = p1c pin is assigned to port pin bit 1 strxb: steering enable bit b 1 = p1b pin has the pwm waveform with polarity control from ccpxm<1:0> 0 = p1b pin is assigned to port pin bit 0 strxa: steering enable bit a 1 = p1a pin has the pwm waveform with polarity control from ccpxm<1:0> 0 = p1a pin is assigned to port pin note 1: the pwm steering mode is available only when the ccpxcon register bits ccpxm<3:2> = 11 and pxm<1:0> = 00 .
? 2009 microchip technology inc. preliminary ds41364c-page 211 pic16f193x/lf193x figure 19-18: simplified steering block diagram 1 0 tris p1a pin port data p1a signal strxa 1 0 tris p1b pin port data strxb 1 0 tris p1c pin port data strxc 1 0 tris p1d pin port data strxd note 1: port outputs are configured as shown when the ccpxcon register bits pxm<1:0> = 00 and ccpxm<3:2> = 11. 2: single pwm output requires setting at least one of the strx bits. ccpxm1 ccpxm0 ccpxm1 ccpxm0
pic16f193x/lf193x ds41364c-page 212 preliminary ? 2009 microchip technology inc. 19.6.7.1 steering synchronization the strxsync bit of the pstrxcon register gives the user two selections of when the steering event will happen. when the strxsync bit is ? 0 ?, the steering event will happen at the end of the instruction that writes to the pstrxcon register. in this case, the output signal at the p1 pins may be an incomplete pwm waveform. this operation is useful when the user firmware needs to immediately remove a pwm signal from the pin. when the strxsync bit is ? 1 ?, the effective steering update will happen at the beginning of the next pwm period. in this case, steering on/off the pwm output will always produce a complete pwm waveform. figures 19-19 and 19-20 illustrate the timing diagrams of the pwm steering depending on the strxsync setting. figure 19-19: example of steering ev ent at end of instruction (strxsync = 0) figure 19-20: example of steering event at beginning of instruction (strxsync = 1) pwm p1n = pwm strx p1 port data pwm period port data pwm port data p1n = pwm strx p1 port data
? 2009 microchip technology inc. preliminary ds41364c-page 213 pic16f193x/lf193x table 19-8: registers associated with pwm name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page ccpxcon pxm1 (1) pxm0 (1) dcxb1 dcxb0 ccpxm3 ccpxm2 ccpxm1 ccpxm0 186 ccpxas ccpxase ccpxas2 ccpxas1 ccpxas0 pssxac1 pssxac0 pssxbd1 pssxbd0 206 ccptmrs0 c4tsel1 c4tsel0 c3tsel1 c3tsel0 c2tsel1 c2tsel0 c1tsel1 c1tsel0 187 ccptmrs1 ? ? ? ? ? ? c5tsel1 c5tsel0 188 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 prx timerx period register 175* pstrxcon ? ? ? strxsync strxd strxc strxb strxa 210 pwmxcon pxrsen pxdc6 pxdc5 pxdc4 pxdc3 pxdc2 pxdc1 pxdc0 209 txcon ? txoutps3 txoutps2 txoutps1 txoutps0 tmrxon txckps1 txckps0 177 tmrx timerx module register 175 trisb trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 93 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 trisd trisd7 trisd6 trisd5 trisd4 trisd3 trisd2 trisd1 trisd0 99 legend: ? = unimplemented locations, read as ? 0 ?, u = unchanged, x = unknown. shaded cells are not used by the pwm. note 1: applies to eccp modules only. * page provides register information.
pic16f193x/lf193x ds41364c-page 214 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 215 pic16f193x/lf193x 20.0 enhanced universal synchronous asynchronous receiver transmitter (eusart) the enhanced universal synchronous asynchronous receiver transmitter (eusart) module is a serial i/o communications peripheral. it contains all the clock generators, shift registers and data buffers necessary to perform an input or output serial data transfer independent of device program execution. the eusart, also known as a serial communications interface (sci), can be configured as a full-duplex asynchronous system or half-duplex synchronous system. full-duplex mode is useful for communications with peripheral systems, such as crt terminals and personal computers. half-duplex synchronous mode is intended for communications with peripheral devices, such as a/d or d/a integrated circuits, serial eeproms or other microcontrollers. these devices typically do not have internal clocks for baud rate generation and require the external clock signal provided by a master synchronous device. the eusart module includes the following capabilities: ? full-duplex asynchronous transmit and receive ? two-character input buffer ? one-character output buffer ? programmable 8-bit or 9-bit character length ? address detection in 9-bit mode ? input buffer overrun error detection ? received character framing error detection ? half-duplex synchronous master ? half-duplex synchronous slave ? programmable clock polarity in synchronous modes ? sleep operation the eusart module implements the following additional features, making it ideally suited for use in local interconnect network (lin) bus systems: ? automatic detection and calibration of the baud rate ? wake-up on break reception ? 13-bit break character transmit block diagrams of the eusart transmitter and receiver are shown in figure 20-1 and figure 20-2. figure 20-1: eusart transmi t block diagram txif txie interrupt txen tx9d msb lsb data bus txreg register transmit shift register (tsr) (8) 0 tx9 trmt spen tx/ck pin pin buffer and control 8 spbrg spbrgh brg16 f osc n n + 1 multiplier x4 x16 x64 sync 1x00 0 brgh x110 0 brg16 x101 0 baud rate generator ???
pic16f193x/lf193x ds41364c-page 216 preliminary ? 2009 microchip technology inc. figure 20-2: eusart receiv e block diagram the operation of the eusart module is controlled through three registers: ? transmit status and control (txsta) ? receive status and control (rcsta) ? baud rate control (baudcon) these registers are detailed in register 20-1, register 20-2 and register 20-3, respectively. when the receiver or transmitter section is not enabled then the corresponding rx or tx pin may be used for general purpose input and output. rx/dt pin pin buffer and control spen data recovery cren oerr ferr rsr register msb lsb rx9d rcreg register fifo interrupt rcif rcie data bus 8 stop start (8) 7 1 0 rx9 ? ? ? spbrg spbrgh brg16 rcidl f osc n n + 1 multiplier x4 x16 x64 sync 1x00 0 brgh x110 0 brg16 x101 0 baud rate generator
? 2009 microchip technology inc. preliminary ds41364c-page 217 pic16f193x/lf193x 20.1 eusart asynchronous mode the eusart transmits and receives data using the standard non-return-to-zero (nrz) format. nrz is implemented with two levels: a v oh mark state which represents a ? 1 ? data bit, and a v ol space state which represents a ? 0 ? data bit. nrz refers to the fact that consecutively transmitted data bits of the same value stay at the output level of that bit without returning to a neutral level between each bit transmission. an nrz transmission port idles in the mark state. each character transmission consists of one start bit followed by eight or nine data bits and is always terminated by one or more stop bits. the start bit is always a space and the stop bits are always marks. the most common data format is 8 bits. each transmitted bit persists for a period of 1/(baud rate). an on-chip dedicated 8-bit/16-bit baud rate generator is used to derive standard baud rate frequencies from the system oscillator. see table 20-5 for examples of baud rate configurations. the eusart transmits and receives the lsb first. the eusart?s transmitter and receiver are functionally independent, but share the same data format and baud rate. parity is not supported by the hardware, but can be implemented in software and stored as the ninth data bit. 20.1.1 eusart asynchronous transmitter the eusart transmitter block diagram is shown in figure 20-1. the heart of the transmitter is the serial transmit shift register (tsr), which is not directly accessible by software. the tsr obtains its data from the transmit buffer, which is the txreg register. 20.1.1.1 enabling the transmitter the eusart transmitter is enabled for asynchronous operations by configuring the following three control bits: ?txen = 1 ? sync = 0 ? spen = 1 all other eusart control bits are assumed to be in their default state. setting the txen bit of the txsta register enables the transmitter circuitry of the eusart. clearing the sync bit of the txsta register configures the eusart for asynchronous operation. setting the spen bit of the rcsta register enables the eusart and automatically configures the tx/ck i/o pin as an output. 20.1.1.2 transmitting data a transmission is initiated by writing a character to the txreg register. if this is the first character, or the previous character has been completely flushed from the tsr, the data in the txreg is immediately transferred to the tsr register. if the tsr still contains all or part of a previous character, the new character data is held in the txreg until the stop bit of the previous character has been transmitted. the pending character in the txreg is then transferred to the tsr in one t cy immediately following the stop bit transmission. the transmission of the start bit, data bits and stop bit sequence commences immediately following the transfer of the data to the tsr from the txreg. 20.1.1.3 transmit interrupt flag the txif interrupt flag bit of the pir1 register is set whenever the eusart transmitter is enabled and no character is being held for transmission in the txreg. in other words, the txif bit is only clear when the tsr is busy with a character and a new character has been queued for transmission in the txreg. the txif flag bit is not cleared immediately upon writing txreg. txif becomes valid in the second instruction cycle following the write execution. polling txif immediately following the txreg write will return invalid results. the txif bit is read-only, it cannot be set or cleared by software. the txif interrupt can be enabled by setting the txie interrupt enable bit of the pie1 register. however, the txif flag bit will be set whenever the txreg is empty, regardless of the state of txie enable bit. to use interrupts when transmitting data, set the txie bit only when there is more data to send. clear the txie interrupt enable bit upon writing the last character of the transmission to the txreg. note 1: the txif transmitter interrupt flag is set when the txen enable bit is set.
pic16f193x/lf193x ds41364c-page 218 preliminary ? 2009 microchip technology inc. 20.1.1.4 tsr status the trmt bit of the txsta register indicates the status of the tsr register. this is a read-only bit. the trmt bit is set when the tsr register is empty and is cleared when a character is transferred to the tsr register from the txreg. the trmt bit remains clear until all bits have been shifted out of the tsr register. no interrupt logic is tied to this bit, so the user has to poll this bit to determine the tsr status. 20.1.1.5 transmitting 9-bit characters the eusart supports 9-bit character transmissions. when the tx9 bit of the txsta register is set the eusart will shift 9 bits out for each character transmit- ted. the tx9d bit of the txsta register is the ninth, and most significant, data bit. when transmitting 9-bit data, the tx9d data bit must be written before writing the 8 least significant bits into the txreg. all nine bits of data will be transferred to the tsr shift register immediately after the txreg is written. a special 9-bit address mode is available for use with multiple receivers. see section 20.1.2.7 ?address detection? for more information on the address mode. 20.1.1.6 asynchronous transmission set-up: 1. initialize the spbrgh, spbrg register pair and the brgh and brg16 bits to achieve the desired baud rate (see section 20.3 ?eusart baud rate generator (brg)? ). 2. enable the asynchronous serial port by clearing the sync bit and setting the spen bit. 3. if 9-bit transmission is desired, set the tx9 con- trol bit. a set ninth data bit will indicate that the 8 least significant data bits are an address when the receiver is set for address detection. 4. enable the transmission by setting the txen control bit. this will cause the txif interrupt bit to be set. 5. if interrupts are desired, set the txie interrupt enable bit of the pie1 register. an interrupt will occur immediately provided that the gie and peie bits of the intcon register are also set. 6. if 9-bit transmission is selected, the ninth bit should be loaded into the tx9d data bit. 7. load 8-bit data into the txreg register. this will start the transmission. figure 20-3: asynchronous transmission figure 20-4: asynchronous transmiss ion (back-to-back) note: the tsr register is not mapped in data memory, so it is not available to the user. word 1 stop bit word 1 transmit shift reg. start bit bit 0 bit 1 bit 7/8 write to txreg word 1 brg output (shift clock) tx/ck txif bit (transmit buffer reg. empty flag) trmt bit (transmit shift reg. empty flag) 1 t cy pin transmit shift reg. write to txreg brg output (shift clock) tx/ck trmt bit (transmit shift reg. empty flag) word 1 word 2 word 1 word 2 start bit stop bit start bit transmit shift reg. word 1 word 2 bit 0 bit 1 bit 7/8 bit 0 note: this timing diagram shows two consecutive transmissions. 1 t cy 1 t cy pin txif bit (transmit buffer reg. empty flag)
? 2009 microchip technology inc. preliminary ds41364c-page 219 pic16f193x/lf193x table 20-1: registers associated with asynchronous transmission name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page baudcon abdovf rcidl ? sckp brg16 ? wue abden 226 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 rcsta spen rx9 sren cren adden ferr oerr rx9d 225 spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 227* spbrgh brg15 brg14 brg13 brg12 brg11 brg10 brg9 brg8 227* trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 txreg eusart transmit data register 217* txsta csrc tx9 txen sync sendb brgh trmt tx9d 224 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for asynchronous transmission. * page provides register information.
pic16f193x/lf193x ds41364c-page 220 preliminary ? 2009 microchip technology inc. 20.1.2 eusart asynchronous receiver the asynchronous mode is typically used in rs-232 systems. the receiver block diagram is shown in figure 20-2. the data is received on the rx/dt pin and drives the data recovery block. the data recovery block is actually a high-speed shifter operating at 16 times the baud rate, whereas the serial receive shift register (rsr) operates at the bit rate. when all 8 or 9 bits of the character have been shifted in, they are immediately transferred to a two character first-in-first-out (fifo) memory. the fifo buffering allows reception of two complete characters and the start of a third character before software must start servicing the eusart receiver. the fifo and rsr registers are not directly accessible by software. access to the received data is via the rcreg register. 20.1.2.1 enabling the receiver the eusart receiver is enabled for asynchronous operation by configuring the following three control bits: ? cren = 1 ? sync = 0 ? spen = 1 all other eusart control bits are assumed to be in their default state. setting the cren bit of the rcsta register enables the receiver circuitry of the eusart. clearing the sync bit of the txsta register configures the eusart for asynchronous operation. setting the spen bit of the rcsta register enables the eusart and automatically configures the rx/dt i/o pin as an input. 20.1.2.2 receiving data the receiver data recovery circuit initiates character reception on the falling edge of the first bit. the first bit, also known as the start bit, is always a zero. the data recovery circuit counts one-half bit time to the center of the start bit and verifies that the bit is still a zero. if it is not a zero then the data recovery circuit aborts character reception, without generating an error, and resumes looking for the falling edge of the start bit. if the start bit zero verification succeeds then the data recovery circuit counts a full bit time to the center of the next bit. the bit is then sampled by a majority detect circuit and the resulting ? 0 ? or ? 1 ? is shifted into the rsr. this repeats until all data bits have been sampled and shifted into the rsr. one final bit time is measured and the level sampled. this is the stop bit, which is always a ? 1 ?. if the data recovery circuit samples a ? 0 ? in the stop bit position then a framing error is set for this character, otherwise the framing error is cleared for this character. see section 20.1.2.4 ?receive framing error? for more information on framing errors. immediately after all data bits and the stop bit have been received, the character in the rsr is transferred to the eusart receive fifo and the rcif interrupt flag bit of the pir1 register is set. the top character in the fifo is transferred out of the fifo by reading the rcreg register. 20.1.2.3 receive interrupts the rcif interrupt flag bit of the pir1 register is set whenever the eusart receiver is enabled and there is an unread character in the receive fifo. the rcif interrupt flag bit is read-only, it cannot be set or cleared by software. rcif interrupts are enabled by setting all of the following bits: ? rcie interrupt enable bit of the pie1 register ? peie peripheral interrupt enable bit of the intcon register ? gie global interrupt enable bit of the intcon register the rcif interrupt flag bit will be set when there is an unread character in the fifo, regardless of the state of interrupt enable bits. note: when the spen bit is set the tx/ck i/o pin is automatically configured as an output, regardless of the state of the corresponding tris bit and whether or not the eusart transmitter is enabled. the port latch is disconnected from the output driver so it is not possible to use the tx/ck pin as a general purpose output. note: if the receive fifo is overrun, no additional characters will be received until the overrun condition is cleared. see section 20.1.2.5 ?receive overrun error? for more information on overrun errors.
? 2009 microchip technology inc. preliminary ds41364c-page 221 pic16f193x/lf193x 20.1.2.4 receive framing error each character in the receive fifo buffer has a corresponding framing error status bit. a framing error indicates that a stop bit was not seen at the expected time. the framing error status is accessed via the ferr bit of the rcsta register. the ferr bit represents the status of the top unread character in the receive fifo. therefore, the ferr bit must be read before reading the rcreg. the ferr bit is read-only and only applies to the top unread character in the receive fifo. a framing error (ferr = 1 ) does not preclude reception of additional characters. it is not necessary to clear the ferr bit. reading the next character from the fifo buffer will advance the fifo to the next character and the next corresponding framing error. the ferr bit can be forced clear by clearing the spen bit of the rcsta register which resets the eusart. clearing the cren bit of the rcsta register does not affect the ferr bit. a framing error by itself does not generate an interrupt. 20.1.2.5 receive overrun error the receive fifo buffer can hold two characters. an overrun error will be generated if a third character, in its entirety, is received before the fifo is accessed. when this happens the oerr bit of the rcsta register is set. the characters already in the fifo buffer can be read but no additional characters will be received until the error is cleared. the error must be cleared by either clearing the cren bit of the rcsta register or by resetting the eusart by clearing the spen bit of the rcsta register. 20.1.2.6 receiving 9-bit characters the eusart supports 9-bit character reception. when the rx9 bit of the rcsta register is set the eusart will shift 9 bits into the rsr for each character received. the rx9d bit of the rcsta register is the ninth and most significant data bit of the top unread character in the receive fifo. when reading 9-bit data from the receive fifo buffer, the rx9d data bit must be read before reading the 8 least significant bits from the rcreg. 20.1.2.7 address detection a special address detection mode is available for use when multiple receivers share the same transmission line, such as in rs-485 systems. address detection is enabled by setting the adden bit of the rcsta register. address detection requires 9-bit character reception. when address detection is enabled, only characters with the ninth data bit set will be transferred to the receive fifo buffer, thereby setting the rcif interrupt bit. all other characters will be ignored. upon receiving an address character, user software determines if the address matches its own. upon address match, user software must disable address detection by clearing the adden bit before the next stop bit occurs. when user software detects the end of the message, determined by the message protocol used, software places the receiver back into the address detection mode by setting the adden bit. note: if all receive characters in the receive fifo have framing errors, repeated reads of the rcreg will not clear the ferr bit.
pic16f193x/lf193x ds41364c-page 222 preliminary ? 2009 microchip technology inc. 20.1.2.8 asynchronous reception set-up: 1. initialize the spbrgh, spbrg register pair and the brgh and brg16 bits to achieve the desired baud rate (see section 20.3 ?eusart baud rate generator (brg)? ). 2. enable the serial port by setting the spen bit. the sync bit must be clear for asynchronous operation. 3. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 4. if 9-bit reception is desired, set the rx9 bit. 5. enable reception by setting the cren bit. 6. the rcif interrupt flag bit will be set when a character is transferred from the rsr to the receive buffer. an interrupt will be generated if the rcie interrupt enable bit was also set. 7. read the rcsta register to get the error flags and, if 9-bit data reception is enabled, the ninth data bit. 8. get the received 8 least significant data bits from the receive buffer by reading the rcreg register. 9. if an overrun occurred, clear the oerr flag by clearing the cren receiver enable bit. 20.1.2.9 9-bit address detection mode set-up this mode would typically be used in rs-485 systems. to set up an asynchronous reception with address detect enable: 1. initialize the spbrgh, spbrg register pair and the brgh and brg16 bits to achieve the desired baud rate (see section 20.3 ?eusart baud rate generator (brg)? ). 2. enable the serial port by setting the spen bit. the sync bit must be clear for asynchronous operation. 3. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 4. enable 9-bit reception by setting the rx9 bit. 5. enable address detection by setting the adden bit. 6. enable reception by setting the cren bit. 7. the rcif interrupt flag bit will be set when a character with the ninth bit set is transferred from the rsr to the receive buffer. an interrupt will be generated if the rcie interrupt enable bit was also set. 8. read the rcsta register to get the error flags. the ninth data bit will always be set. 9. get the received 8 least significant data bits from the receive buffer by reading the rcreg register. software determines if this is the device?s address. 10. if an overrun occurred, clear the oerr flag by clearing the cren receiver enable bit. 11. if the device has been addressed, clear the adden bit to allow all received data into the receive buffer and generate interrupts. figure 20-5: asynchronous reception start bit bit 7/8 bit 1 bit 0 bit 7/8 bit 0 stop bit start bit start bit bit 7/8 stop bit rx/dt pin reg rcv buffer reg. rcv shift read rcv buffer reg. rcreg rcif (interrupt flag) oerr bit cren word 1 rcreg word 2 rcreg stop bit note: this timing diagram shows three words appearing on the rx input. the rcreg (receive buffer) is read after the third word, causing the oerr (overrun) bit to be set. rcidl
? 2009 microchip technology inc. preliminary ds41364c-page 223 pic16f193x/lf193x table 20-2: registers associated with asynchronous reception name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page baudcon abdovf rcidl ? sckp brg16 ?wue abden 226 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 rcreg eusart receive data register 220* rcsta spen rx9 sren cren adden ferr oerr rx9d 225 spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 227* spbrgh brg15 brg14 brg13 brg12 brg11 brg10 brg9 brg8 227* trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 txsta csrc tx9 txen sync sendb brgh trmt tx9d 224 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for asynchronous reception. * page provides register information.
pic16f193x/lf193x ds41364c-page 224 preliminary ? 2009 microchip technology inc. 20.2 clock accuracy with asynchronous operation the factory calibrates the internal oscillator block out- put (intosc). however, the intosc frequency may drift as v dd or temperature changes, and this directly affects the asynchronous baud rate. two methods may be used to adjust the baud rate clock, but both require a reference clock source of some kind. the first (preferred) method uses the osctune register to adjust the intosc output. adjusting the value in the osctune register allows for fine resolution changes to the system clock source. see section 8.5 ?internal clock modes? for more information. the other method adjusts the value in the baud rate generator. this can be done automatically with the auto-baud detect feature (see section 20.3.1 ?auto-baud detect? ). there may not be fine enough resolution when adjusting the baud rate generator to compensate for a gradual change in the peripheral clock frequency. register 20-1: txsta: transmit status and control register r/w-/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r-1/1 r/w-0/0 csrc tx9 txen (1) sync sendb brgh trmt tx9d bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 csrc: clock source select bit asynchronous mode : don?t care synchronous mode : 1 = master mode (clock generated internally from brg) 0 = slave mode (clock from external source) bit 6 tx9: 9-bit transmit enable bit 1 = selects 9-bit transmission 0 = selects 8-bit transmission bit 5 txen: transmit enable bit (1) 1 = transmit enabled 0 = transmit disabled bit 4 sync: eusart mode select bit 1 = synchronous mode 0 = asynchronous mode bit 3 sendb: send break character bit asynchronous mode : 1 = send sync break on next transmission (cleared by hardware upon completion) 0 = sync break transmission completed synchronous mode : don?t care bit 2 brgh: high baud rate select bit asynchronous mode : 1 = high speed 0 = low speed synchronous mode: unused in this mode bit 1 trmt: transmit shift register status bit 1 = tsr empty 0 = tsr full bit 0 tx9d: ninth bit of transmit data can be address/data bit or a parity bit. note 1: sren/cren overrides txen in sync mode.
? 2009 microchip technology inc. preliminary ds41364c-page 225 pic16f193x/lf193x register 20-2: rcsta: receive status and control register (1) r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r-0/0 r-0/0 r-x/x spen rx9 sren cren adden ferr oerr rx9d bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 spen: serial port enable bit 1 = serial port enabled (configures rx/dt and tx/ck pins as serial port pins) 0 = serial port disabled (held in reset) bit 6 rx9: 9-bit receive enable bit 1 = selects 9-bit reception 0 = selects 8-bit reception bit 5 sren: single receive enable bit asynchronous mode : don?t care synchronous mode ? master : 1 = enables single receive 0 = disables single receive this bit is cleared after reception is complete. synchronous mode ? slave don?t care bit 4 cren: continuous receive enable bit asynchronous mode : 1 = enables receiver 0 = disables receiver synchronous mode : 1 = enables continuous receive until enable bit cren is cleared (cren overrides sren) 0 = disables continuous receive bit 3 adden: address detect enable bit asynchronous mode 9-bit (rx9 = 1 ) : 1 = enables address detection, enable interrupt and load the receive buffer when rsr<8> is set 0 = disables address detection, all bytes are received and ninth bit can be used as parity bit asynchronous mode 8-bit (rx9 = 0 ) : don?t care bit 2 ferr: framing error bit 1 = framing error (can be updated by reading rcreg register and receive next valid byte) 0 = no framing error bit 1 oerr: overrun error bit 1 = overrun error (can be cleared by clearing bit cren) 0 = no overrun error bit 0 rx9d: ninth bit of received data this can be address/data bit or a parity bit and must be calculated by user firmware.
pic16f193x/lf193x ds41364c-page 226 preliminary ? 2009 microchip technology inc. register 20-3: baudcon: baud rate control register r-0/0 r-1/1 u-0 r/w-0/0 r/w-0/0 u-0 r/w-0/0 r/w-0/0 abdovf rcidl ? sckp brg16 ? wue abden bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 abdovf: auto-baud detect overflow bit asynchronous mode : 1 = auto-baud timer overflowed 0 = auto-baud timer did not overflow synchronous mode : don?t care bit 6 rcidl : receive idle flag bit asynchronous mode : 1 = receiver is idle 0 = start bit has been received and the receiver is receiving synchronous mode : don?t care bit 5 unimplemented: read as ? 0 ? bit 4 sckp : synchronous clock polarity select bit asynchronous mode : 1 = transmit inverted data to the rb7/tx/ck pin 0 = transmit non-inverted data to the rb7/tx/ck pin synchronous mode : 1 = data is clocked on rising edge of the clock 0 = data is clocked on falling edge of the clock bit 3 brg16: 16-bit baud rate generator bit 1 = 16-bit baud rate generator is used 0 = 8-bit baud rate generator is used bit 2 unimplemented: read as ? 0 ? bit 1 wue: wake-up enable bit asynchronous mode : 1 = receiver is waiting for a falling edge. no character will be received, byte rcif will be set. wue will automatically clear after rcif is set. 0 = receiver is operating normally synchronous mode : don?t care bit 0 abden : auto-baud detect enable bit asynchronous mode : 1 = auto-baud detect mode is enabled (clears when auto-baud is complete) 0 = auto-baud detect mode is disabled synchronous mode : don?t care
? 2009 microchip technology inc. preliminary ds41364c-page 227 pic16f193x/lf193x 20.3 eusart baud rate generator (brg) the baud rate generator (brg) is an 8-bit or 16-bit timer that is dedicated to the support of both the asynchronous and synchronous eusart operation. by default, the brg operates in 8-bit mode. setting the brg16 bit of the baudcon register selects 16-bit mode. the spbrgh, spbrg register pair determines the period of the free running baud rate timer. in asynchronous mode the multiplier of the baud rate period is determined by both the brgh bit of the txsta register and the brg16 bit of the baudcon register. in synchronous mode, the brgh bit is ignored. table 20-3 contains the formulas for determining the baud rate. example 20-1 provides a sample calculation for determining the baud rate and baud rate error. typical baud rates and error values for various asynchronous modes have been computed for your convenience and are shown in table 20-3. it may be advantageous to use the high baud rate (brgh = 1 ), or the 16-bit brg (brg16 = 1 ) to reduce the baud rate error. the 16-bit brg mode is used to achieve slow baud rates for fast oscillator frequencies. writing a new value to the spbrgh, spbrg register pair causes the brg timer to be reset (or cleared). this ensures that the brg does not wait for a timer overflow before outputting the new baud rate. if the system clock is changed during an active receive operation, a receive error or data loss may result. to avoid this problem, check the status of the rcidl bit to make sure that the receive operation is idle before changing the system clock. example 20-1: calculating baud rate error for a device with f osc of 16 mhz, desired baud rate of 9600, asynchronous mode, 8-bit brg: solving for spbrgh:spbrg: x f osc desired baud rate --------------------------------------------- 64 --------------------------------------------- 1 ? = desired baud rate f osc 64 [spbrgh:spbrg] 1 + () -------------------------------------------------------------------- - = 16000000 9600 ----------------------- - 64 ----------------------- -1 ? = 25.042 [] 25 == calculated baud rate 16000000 64 25 1 + () -------------------------- - = 9615 = error calc. baud rate desired baud rate ? desired baud rate -------------------------------------------------------------------------------------------- = 9615 9600 ? () 9600 ---------------------------------- 0 . 1 6 % ==
pic16f193x/lf193x ds41364c-page 228 preliminary ? 2009 microchip technology inc. table 20-3: baud rate formulas table 20-4: registers associated with the baud rate generator configuration bits brg/eusart mode baud rate formula sync brg16 brgh 000 8-bit/asynchronous f osc /[64 (n+1)] 001 8-bit/asynchronous f osc /[16 (n+1)] 010 16-bit/asynchronous 011 16-bit/asynchronous f osc /[4 (n+1)] 10x 8-bit/synchronous 11x 16-bit/synchronous legend: x = don?t care, n = value of spbrgh, spbrg register pair name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page baudcon abdovf rcidl ? sckp brg16 ? wue abden 226 rcsta spen rx9 sren cren adden ferr oerr rx9d 225 spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 227* spbrgh brg15 brg14 brg13 brg12 brg11 brg10 brg9 brg8 227* txsta csrc tx9 txen sync sendb brgh trmt tx9d 224 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for the baud rate generator. * page provides register information.
? 2009 microchip technology inc. preliminary ds41364c-page 229 pic16f193x/lf193x table 20-5: baud rates for asynchronous modes baud rate sync = 0 , brgh = 0 , brg16 = 0 f osc = 32.000 mhz f osc = 20.000 mhz f osc = 18.432 mhz f osc = 11.0592 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300?? ? ?? ? ?? ? ?? ? 1200 ? ? ? 1221 1.73 255 1200 0.00 239 1200 0.00 143 2400 2404 0.16 207 2404 0.16 129 2400 0.00 119 2400 0.00 71 9600 9615 0.16 51 9470 -1.36 32 9600 0.00 29 9600 0.00 17 10417 10417 0.00 47 10417 0.00 29 10286 -1.26 27 10165 -2.42 16 19.2k 19.23k 0.16 25 19.53k 1.73 15 19.20k 0.00 14 19.20k 0.00 8 57.6k 55.55k -3.55 3 ? ? ? 57.60k 0.00 7 57.60k 0.00 2 115.2k ? ? ? ? ? ? ? ? ? ? ? ? baud rate sync = 0 , brgh = 0 , brg16 = 0 f osc = 8.000 mhz f osc = 4.000 mhz f osc = 3.6864 mhz f osc = 1.000 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 ? ? ? 300 0.16 207 300 0.00 191 300 0.16 51 1200 1202 0.16 103 1202 0.16 51 1200 0.00 47 1202 0.16 12 2400 2404 0.16 51 2404 0.16 25 2400 0.00 23 ? ? ? 9600 9615 0.16 12 ? ? ? 9600 0.00 5 ? ? ? 10417 10417 0.00 11 10417 0.00 5 ? ? ? ? ? ? 19.2k ? ? ? ? ? ? 19.20k 0.00 2 ? ? ? 57.6k ? ? ? ? ? ? 57.60k 0.00 0 ? ? ? 115.2k ? ? ? ? ? ? ? ? ? ? ? ? baud rate sync = 0 , brgh = 1 , brg16 = 0 f osc = 32.000 mhz f osc = 20.000 mhz f osc = 18.432 mhz f osc = 11.0592 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 ?? ? ?? ? ?? ? ?? ? 1200 ? ? ? ? ? ? ? ? ? ? ? ? 2400 ? ? ? ? ? ? ? ? ? ?? ? 9600 9615 0.16 207 9615 0.16 129 9600 0.00 119 9600 0.00 71 10417 10417 0.00 191 10417 0.00 119 10378 -0.37 110 10473 0.53 65 19.2k 19.23k 0.16 103 19.23k 0.16 64 19.20k 0.00 59 19.20k 0.00 35 57.6k 57.14k -0.79 34 56.82k -1.36 21 57.60k 0.00 19 57.60k 0.00 11 115.2k 117.64k 2.12 16 113.64k -1.36 10 115.2k 0.00 9 115.2k 0.00 5
pic16f193x/lf193x ds41364c-page 230 preliminary ? 2009 microchip technology inc. baud rate sync = 0 , brgh = 1 , brg16 = 0 f osc = 8.000 mhz f osc = 4.000 mhz f osc = 3.6864 mhz f osc = 1.000 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 ?? ? ? ? ? ? ? ? 300 0.16 207 1200 ? ? ? 1202 0.16 207 1200 0.00 191 1202 0.16 51 2400 2404 0.16 207 2404 0.16 103 2400 0.00 95 2404 0.16 25 9600 9615 0.16 51 9615 0.16 25 9600 0.00 23 ? ? ? 10417 10417 0.00 47 10417 0.00 23 10473 0.53 21 10417 0.00 5 19.2k 19231 0.16 25 19.23k 0.16 12 19.2k 0.00 11 ? ? ? 57.6k 55556 -3.55 8 ? ? ? 57.60k 0.00 3 ? ? ? 115.2k ? ? ? ? ? ? 115.2k 0.00 1 ? ? ? baud rate sync = 0 , brgh = 0 , brg16 = 1 f osc = 32.000 mhz f osc = 20.000 mhz f osc = 18.432 mhz f osc = 11.0592 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 300.0 0.00 6666 300.0 -0.01 4166 300.0 0.00 3839 300.0 0.00 2303 1200 1200 -0.02 3332 1200 -0.03 1041 1200 0.00 959 1200 0.00 575 2400 2401 -0.04 832 2399 -0.03 520 2400 0.00 479 2400 0.00 287 9600 9615 0.16 207 9615 0.16 129 9600 0.00 119 9600 0.00 71 10417 10417 0.00 191 10417 0.00 119 10378 -0.37 110 10473 0.53 65 19.2k 19.23k 0.16 103 19.23k 0.16 64 19.20k 0.00 59 19.20k 0.00 35 57.6k 57.14k -0.79 34 56.818 -1.36 21 57.60k 0.00 19 57.60k 0.00 11 115.2k 117.6k 2.12 16 113.636 -1.36 10 115.2k 0.00 9 115.2k 0.00 5 baud rate sync = 0 , brgh = 0 , brg16 = 1 f osc = 8.000 mhz f osc = 4.000 mhz f osc = 3.6864 mhz f osc = 1.000 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 299.9 -0.02 1666 300.1 0.04 832 300.0 0.00 767 300.5 0.16 207 1200 1199 -0.08 416 1202 0.16 207 1200 0.00 191 1202 0.16 51 2400 2404 0.16 207 2404 0.16 103 2400 0.00 95 2404 0.16 25 9600 9615 0.16 51 9615 0.16 25 9600 0.00 23 ? ? ? 10417 10417 0.00 47 10417 0.00 23 10473 0.53 21 10417 0.00 5 19.2k 19.23k 0.16 25 19.23k 0.16 12 19.20k 0.00 11 ? ? ? 57.6k 55556 -3.55 8 ? ? ? 57.60k 0.00 3 ? ? ? 115.2k ? ? ? ? ? ? 115.2k 0.00 1 ? ? ? table 20-5: baud rates for asynchronous modes (continued)
? 2009 microchip technology inc. preliminary ds41364c-page 231 pic16f193x/lf193x baud rate sync = 0 , brgh = 1 , brg16 = 1 or sync = 1 , brg16 = 1 f osc = 32.000 mhz f osc = 20.000 mhz f osc = 18.432 mhz f osc = 11.0592 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 300.0 0.00 26666 300.0 0.00 16665 300.0 0.00 15359 300.0 0.00 9215 1200 1200 0.00 6666 1200 -0.01 4166 1200 0.00 3839 1200 0.00 2303 2400 2400 0.01 3332 2400 0.02 2082 2400 0.00 1919 2400 0.00 1151 9600 9604 0.04 832 9597 -0.03 520 9600 0.00 479 9600 0.00 287 10417 10417 0.00 767 10417 0.00 479 10425 0.08 441 10433 0.16 264 19.2k 19.18k -0.08 416 19.23k 0.16 259 19.20k 0.00 239 19.20k 0.00 143 57.6k 57.55k -0.08 138 57.47k -0.22 86 57.60k 0.00 79 57.60k 0.00 47 115.2k 115.9k 0.64 68 116.3k 0.94 42 115.2k 0.00 39 115.2k 0.00 23 baud rate sync = 0 , brgh = 1 , brg16 = 1 or sync = 1 , brg16 = 1 f osc = 8.000 mhz f osc = 4.000 mhz f osc = 3.6864 mhz f osc = 1.000 mhz actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) actual rate % error spbrg value (decimal) 300 300.0 0.00 6666 300.0 0.01 3332 300.0 0.00 3071 300.1 0.04 832 1200 1200 -0.02 1666 1200 0.04 832 1200 0.00 767 1202 0.16 207 2400 2401 0.04 832 2398 0.08 416 2400 0.00 383 2404 0.16 103 9600 9615 0.16 207 9615 0.16 103 9600 0.00 95 9615 0.16 25 10417 10417 0 191 10417 0.00 95 10473 0.53 87 10417 0.00 23 19.2k 19.23k 0.16 103 19.23k 0.16 51 19.20k 0.00 47 19.23k 0.16 12 57.6k 57.14k -0.79 34 58.82k 2.12 16 57.60k 0.00 15 ? ? ? 115.2k 117.6k 2.12 16 111.1k -3.55 8 115.2k 0.00 7 ? ? ? table 20-5: baud rates for asynchronous modes (continued)
pic16f193x/lf193x ds41364c-page 232 preliminary ? 2009 microchip technology inc. 20.3.1 a uto-baud detect the eusart module supports automatic detection and calibration of the baud rate. in the auto-baud detect (abd) mode, the clock to the brg is reversed. rather than the brg clocking the incoming rx signal, the rx signal is timing the brg. the baud rate generator is used to time the period of a received 55h (ascii ?u?) which is the sync character for the lin bus. the unique feature of this character is that it has five rising edges including the stop bit edge. setting the abden bit of the baudcon register starts the auto-baud calibration sequence (figure 20-6). while the abd sequence takes place, the eusart state machine is held in idle. on the first rising edge of the receive line, after the start bit, the spbrg begins counting up using the brg counter clock as shown in table 20-6. the fifth rising edge will occur on the rx pin at the end of the eighth bit period. at that time, an accumulated value totaling the proper brg period is left in the spbrgh, spbrg register pair, the abden bit is automatically cleared and the rcif interrupt flag is set. the value in the rcreg needs to be read to clear the rcif interrupt. rcreg content should be discarded. when calibrating for modes that do not use the spbrgh register the user can verify that the spbrg register did not overflow by checking for 00h in the spbrgh register. the brg auto-baud clock is determined by the brg16 and brgh bits as shown in table 20-6. during abd, both the spbrgh and spbrg registers are used as a 16-bit counter, independent of the brg16 bit setting. while calibrating the baud rate period, the spbrgh and spbrg registers are clocked at 1/8th the brg base clock rate. the resulting byte measurement is the average bit time when clocked at full speed. table 20-6: brg counter clock rates figure 20-6: automatic baud rate calibration note 1: if the wue bit is set with the abden bit, auto-baud detection will occur on the byte following the break character (see section 20.3.3 ?auto-wake-up on break? ). 2: it is up to the user to determine that the incoming character baud rate is within the range of the selected brg clock source. some combinations of oscillator frequency and eusart baud rates are not possible. 3: during the auto-baud process, the auto-baud counter starts counting at 1. upon completion of the auto-baud sequence, to achieve maximum accuracy, subtract 1 from the spbrgh:spbrg register pair. brg16 brgh brg base clock brg abd clock 00 f osc /64 f osc /512 01 f osc /16 f osc /128 10 f osc /16 f osc /128 11 f osc /4 f osc /32 note: during the abd sequence, spbrg and spbrgh registers are both used as a 16-bit counter, independent of brg16 setting. brg value rx pin abden bit rcif bit bit 0 bit 1 (interrupt) read rcreg brg clock start auto cleared set by user xxxxh 0000h edge #1 bit 2 bit 3 edge #2 bit 4 bit 5 edge #3 bit 6 bit 7 edge #4 stop bit edge #5 001ch note 1: the abd sequence requires the eusart module to be configured in asynchronous mode. spbrg xxh 1ch spbrgh xxh 00h rcidl
? 2009 microchip technology inc. preliminary ds41364c-page 233 pic16f193x/lf193x 20.3.2 auto-baud overflow during the course of automatic baud detection, the abdovf bit of the baudcon register will be set if the baud rate counter overflows before the fifth rising edge is detected on the rx pin. the abdovf bit indicates that the counter has exceeded the maximum count that can fit in the 16 bits of the spbrgh:spbrg register pair. after the abdovf has been set, the counter con- tinues to count until the fifth rising edge is detected on the rx pin. upon detecting the fifth rx edge, the hard- ware will set the rcif interrupt flag and clear the abden bit of the baudcon register. the rcif flag can be subsequently cleared by reading the rcreg register. the abdovf flag of the baudcon register can be cleared by software directly. to terminate the auto-baud process before the rcif flag is set, clear the abden bit then clear the abdovf bit of the baudcon register. the abdovf bit will remain set if the abden bit is not cleared first. 20.3.3 auto-wake-up on break during sleep mode, all clocks to the eusart are suspended. because of this, the baud rate generator is inactive and a proper character reception cannot be performed. the auto-wake-up feature allows the controller to wake-up due to activity on the rx/dt line. this feature is available only in asynchronous mode. the auto-wake-up feature is enabled by setting the wue bit of the baudcon register. once set, the normal receive sequence on rx/dt is disabled, and the eusart remains in an idle state, monitoring for a wake-up event independent of the cpu mode. a wake-up event consists of a high-to-low transition on the rx/dt line. (this coincides with the start of a sync break or a wake-up signal character for the lin protocol.) the eusart module generates an rcif interrupt coincident with the wake-up event. the interrupt is generated synchronously to the q clocks in normal cpu operating modes (figure 20-7), and asynchronously if the device is in sleep mode (figure 20-8). the interrupt condition is cleared by reading the rcreg register. the wue bit is automatically cleared by the low-to-high transition on the rx line at the end of the break. this signals to the user that the break event is over. at this point, the eusart module is in idle mode waiting to receive the next character. 20.3.3.1 special considerations break character to avoid character errors or character fragments during a wake-up event, the wake-up character must be all zeros. when the wake-up is enabled the function works independent of the low time on the data stream. if the wue bit is set and a valid non-zero character is received, the low time from the start bit to the first rising edge will be interpreted as the wake-up event. the remaining bits in the character will be received as a fragmented character and subsequent characters can result in framing or overrun errors. therefore, the initial character in the transmission must be all ? 0 ?s. this must be 10 or more bit times, 13-bit times recommended for lin bus, or any number of bit times for standard rs-232 devices. oscillator startup time oscillator start-up time must be considered, especially in applications using oscillators with longer start-up intervals (i.e., lp, xt or hs/pll mode). the sync break (or wake-up signal) character must be of sufficient length, and be followed by a sufficient interval, to allow enough time for the selected oscillator to start and provide proper initialization of the eusart. wue bit the wake-up event causes a receive interrupt by setting the rcif bit. the wue bit is cleared in hardware by a rising edge on rx/dt. the interrupt condition is then cleared in software by reading the rcreg register and discarding its contents. to ensure that no actual data is lost, check the rcidl bit to verify that a receive operation is not in process before setting the wue bit. if a receive operation is not occurring, the wue bit may then be set just prior to entering the sleep mode.
pic16f193x/lf193x ds41364c-page 234 preliminary ? 2009 microchip technology inc. figure 20-7: auto-wake-up bit (wue) timing during no rmal operation figure 20-8: auto-wake-up bit (wue) timings during sleep q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 osc1 wue bit rx/dt line rcif bit set by user auto cleared cleared due to user read of rcreg note 1: the eusart remains in idle while the wue bit is set. q1 q2 q3 q4 q1q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 osc1 wue bit rx/dt line rcif bit set by user auto cleared cleared due to user read of rcreg sleep command executed note 1 note 1: if the wake-up event requires long oscillator warm-up time, the automatic clearing of the wue bit can occur while the stposc signal is still active. this sequence should not depend on the presence of q clocks. 2: the eusart remains in idle while the wue bit is set. sleep ends
? 2009 microchip technology inc. preliminary ds41364c-page 235 pic16f193x/lf193x 20.3.4 break character sequence the eusart module has the capability of sending the special break character sequences that are required by the lin bus standard. a break character consists of a start bit, followed by 12 ? 0 ? bits and a stop bit. to send a break character, set the sendb and txen bits of the txsta register. the break character trans- mission is then initiated by a write to the txreg. the value of data written to txreg will be ignored and all ? 0 ?s will be transmitted. the sendb bit is automatically reset by hardware after the corresponding stop bit is sent. this allows the user to preload the transmit fifo with the next transmit byte following the break character (typically, the sync character in the lin specification). the trmt bit of the txsta register indicates when the transmit operation is active or idle, just as it does during normal transmission. see figure 20-9 for the timing of the break character sequence. 20.3.4.1 break and sync transmit sequence the following sequence will start a message frame header made up of a break, followed by an auto-baud sync byte. this sequence is typical of a lin bus master. 1. configure the eusart for the desired mode. 2. set the txen and sendb bits to enable the break sequence. 3. load the txreg with a dummy character to initiate transmission (the value is ignored). 4. write ?55h? to txreg to load the sync character into the transmit fifo buffer. 5. after the break has been sent, the sendb bit is reset by hardware and the sync character is then transmitted. when the txreg becomes empty, as indicated by the txif, the next data byte can be written to txreg. 20.3.5 receiving a break character the enhanced eusart module can receive a break character in two ways. the first method to detect a break character uses the ferr bit of the rcsta register and the received data as indicated by rcreg. the baud rate generator is assumed to have been initialized to the expected baud rate. a break character has been received when; ? rcif bit is set ? ferr bit is set ? rcreg = 00h the second method uses the auto-wake-up feature described in section 20.3.3 ?auto-wake-up on break? . by enabling this feature, the eusart will sample the next two transitions on rx/dt, cause an rcif interrupt, and receive the next data byte followed by another interrupt. note that following a break character, the user will typically want to enable the auto-baud detect feature. for both methods, the user can set the abden bit of the baudcon register before placing the eusart in sleep mode. figure 20-9: send break character sequence write to txreg dummy write brg output (shift clock) start bit bit 0 bit 1 bit 11 stop bit break txif bit (transmit interrupt flag) tx (pin) trmt bit (transmit shift empty flag) sendb (send break control bit) sendb sampled here auto cleared
pic16f193x/lf193x ds41364c-page 236 preliminary ? 2009 microchip technology inc. 20.4 eusart synchronous mode synchronous serial communications are typically used in systems with a single master and one or more slaves. the master device contains the necessary cir- cuitry for baud rate generation and supplies the clock for all devices in the system. slave devices can take advantage of the master clock by eliminating the inter- nal clock generation circuitry. there are two signal lines in synchronous mode: a bidi- rectional data line and a clock line. slaves use the external clock supplied by the master to shift the serial data into and out of their respective receive and trans- mit shift registers. since the data line is bidirectional, synchronous operation is half-duplex only. half-duplex refers to the fact that master and slave devices can receive and transmit data but not both simultaneously. the eusart can operate as either a master or slave device. start and stop bits are not used in synchronous trans- missions. 20.4.1 synchronous master mode the following bits are used to configure the eusart for synchronous master operation: ? sync = 1 ? csrc = 1 ? sren = 0 (for transmit); sren = 1 (for receive) ? cren = 0 (for transmit); cren = 1 (for receive) ? spen = 1 setting the sync bit of the txsta register configures the device for synchronous operation. setting the csrc bit of the txsta register configures the device as a master. clearing the sren and cren bits of the rcsta register ensures that the device is in the transmit mode, otherwise the device will be configured to receive. setting the spen bit of the rcsta register enables the eusart. 20.4.1.1 master clock synchronous data transfers use a separate clock line, which is synchronous with the data. a device config- ured as a master transmits the clock on the tx/ck line. the tx/ck pin output driver is automatically enabled when the eusart is configured for synchronous transmit or receive operation. serial data bits change on the leading edge to ensure they are valid at the trail- ing edge of each clock. one clock cycle is generated for each data bit. only as many clock cycles are gener- ated as there are data bits. 20.4.1.2 clock polarity a clock polarity option is provided for microwire compatibility. clock polarity is selected with the sckp bit of the baudcon register. setting the sckp bit sets the clock idle state as high. when the sckp bit is set, the data changes on the falling edge of each clock. clearing the sckp bit sets the idle state as low. when the sckp bit is cleared, the data changes on the rising edge of each clock. 20.4.1.3 synchronous master transmission data is transferred out of the device on the rx/dt pin. the rx/dt and tx/ck pin output drivers are automat- ically enabled when the eusart is configured for syn- chronous master transmit operation. a transmission is initiated by writing a character to the txreg register. if the tsr still contains all or part of a previous character the new character data is held in the txreg until the last bit of the previous character has been transmitted. if this is the first character, or the pre- vious character has been completely flushed from the tsr, the data in the txreg is immediately transferred to the tsr. the transmission of the character com- mences immediately following the transfer of the data to the tsr from the txreg. each data bit changes on the leading edge of the mas- ter clock and remains valid until the subsequent leading clock edge. 20.4.1.4 synchronous master transmission set-up: 1. initialize the spbrgh, spbrg register pair and the brgh and brg16 bits to achieve the desired baud rate (see section 20.3 ?eusart baud rate generator (brg)? ). 2. enable the synchronous master serial port by setting bits sync, spen and csrc. 3. disable receive mode by clearing bits sren and cren. 4. enable transmit mode by setting the txen bit. 5. if 9-bit transmission is desired, set the tx9 bit. 6. if interrupts are desired, set the txie bit of the pie1 register and the gie and peie bits of the intcon register. 7. if 9-bit transmission is selected, the ninth bit should be loaded in the tx9d bit. 8. start transmission by loading data to the txreg register. note: the tsr register is not mapped in data memory, so it is not available to the user.
? 2009 microchip technology inc. preliminary ds41364c-page 237 pic16f193x/lf193x figure 20-10: synchronous transmission figure 20-11: synchronous transmis sion (through txen) table 20-7: registers associated wi th synchronous master transmission name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page baudcon abdovf rcidl ? sckp brg16 ? wue abden 226 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 rcsta spen rx9 sren cren adden ferr oerr rx9d 225 spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 227* spbrgh brg15 brg14 brg13 brg12 brg11 brg10 brg9 brg8 227* trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 txreg eusart transmit data register 217* txsta csrc tx9 txen sync sendb brgh trmt tx9d 224 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for synchronous master transmission. * page provides register information. bit 0 bit 1 bit 7 word 1 bit 2 bit 0 bit 1 bit 7 rx/dt write to txreg reg txif bit (interrupt flag) txen bit ? 1 ? ? 1 ? word 2 trmt bit write word 1 write word 2 note: sync master mode, spbrg = 0 , continuous transmission of two 8-bit words. pin tx/ck pin tx/ck pin (sckp = 0 ) (sckp = 1 ) rx/dt pin tx/ck pin write to txreg reg txif bit trmt bit bit 0 bit 1 bit 2 bit 6 bit 7 txen bit
pic16f193x/lf193x ds41364c-page 238 preliminary ? 2009 microchip technology inc. 20.4.1.5 synchronous master reception data is received at the rx/dt pin. the rx/dt pin output driver is automatically disabled when the eusart is configured for synchronous master receive operation. in synchronous mode, reception is enabled by setting either the single receive enable bit (sren of the rcsta register) or the continuous receive enable bit (cren of the rcsta register). when sren is set and cren is clear, only as many clock cycles are generated as there are data bits in a single character. the sren bit is automatically cleared at the completion of one character. when cren is set, clocks are continuously generated until cren is cleared. if cren is cleared in the middle of a character the ck clock stops immediately and the partial charac- ter is discarded. if sren and cren are both set, then sren is cleared at the completion of the first character and cren takes precedence. to initiate reception, set either sren or cren. data is sampled at the rx/dt pin on the trailing edge of the tx/ck clock pin and is shifted into the receive shift register (rsr). when a complete character is received into the rsr, the rcif bit is set and the char- acter is automatically transferred to the two character receive fifo. the least significant eight bits of the top character in the receive fifo are available in rcreg. the rcif bit remains set as long as there are unread characters in the receive fifo. 20.4.1.6 slave clock synchronous data transfers use a separate clock line, which is synchronous with the data. a device configured as a slave receives the clock on the tx/ck line. the tx/ck pin output driver is automatically disabled when the device is configured for synchronous slave transmit or receive operation. serial data bits change on the leading edge to ensure they are valid at the trailing edge of each clock. one data bit is transferred for each clock cycle. only as many clock cycles should be received as there are data bits. 20.4.1.7 receive overrun error the receive fifo buffer can hold two characters. an overrun error will be generated if a third character, in its entirety, is received before rcreg is read to access the fifo. when this happens the oerr bit of the rcsta register is set. previous data in the fifo will not be overwritten. the two characters in the fifo buffer can be read, however, no additional characters will be received until the error is cleared. the oerr bit can only be cleared by clearing the overrun condition. if the overrun error occurred when the sren bit is set and cren is clear then the error is cleared by reading rcreg. if the overrun occurred when the cren bit is set then the error condition is cleared by either clearing the cren bit of the rcsta register or by clearing the spen bit which resets the eusart. 20.4.1.8 receiving 9-bit characters the eusart supports 9-bit character reception. when the rx9 bit of the rcsta register is set the eusart will shift 9-bits into the rsr for each character received. the rx9d bit of the rcsta register is the ninth, and most significant, data bit of the top unread character in the receive fifo. when reading 9-bit data from the receive fifo buffer, the rx9d data bit must be read before reading the 8 least significant bits from the rcreg. 20.4.1.9 synchronous master reception set-up: 1. initialize the spbrgh, spbrg register pair for the appropriate baud rate. set or clear the brgh and brg16 bits, as required, to achieve the desired baud rate. 2. enable the synchronous master serial port by setting bits sync, spen and csrc. 3. ensure bits cren and sren are clear. 4. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 5. if 9-bit reception is desired, set bit rx9. 6. start reception by setting the sren bit or for continuous reception, set the cren bit. 7. interrupt flag bit rcif will be set when reception of a character is complete. an interrupt will be generated if the enable bit rcie was set. 8. read the rcsta register to get the ninth bit (if enabled) and determine if any error occurred during reception. 9. read the 8-bit received data by reading the rcreg register. 10. if an overrun error occurs, clear the error by either clearing the cren bit of the rcsta register or by clearing the spen bit which resets the eusart.
? 2009 microchip technology inc. preliminary ds41364c-page 239 pic16f193x/lf193x figure 20-12: synchronous reception (master mode, sren) table 20-8: registers associated with synchronous master reception name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page baudcon abdovf rcidl ? sckp brg16 ? wue abden 226 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 rcreg eusart receive data register 220* rcsta spen rx9 sren cren adden ferr oerr rx9d 225 spbrg brg7 brg6 brg5 brg4 brg3 brg2 brg1 brg0 227* spbrgh brg15 brg14 brg13 brg12 brg11 brg10 brg9 brg8 227* trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 txsta csrc tx9 txen sync sendb brgh trmt tx9d 224 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for synchronous master reception. * page provides register information. cren bit rx/dt write to bit sren sren bit rcif bit (interrupt) read rxreg ? 0 ? bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 ? 0 ? note: timing diagram demonstrates sync master mode with bit sren = 1 and bit brgh = 0 . tx/ck pin tx/ck pin pin (sckp = 0 ) (sckp = 1 )
pic16f193x/lf193x ds41364c-page 240 preliminary ? 2009 microchip technology inc. 20.4.2 synchronous slave mode the following bits are used to configure the eusart for synchronous slave operation: ? sync = 1 ? csrc = 0 ? sren = 0 (for transmit); sren = 1 (for receive) ? cren = 0 (for transmit); cren = 1 (for receive) ? spen = 1 setting the sync bit of the txsta register configures the device for synchronous operation. clearing the csrc bit of the txsta register configures the device as a slave. clearing the sren and cren bits of the rcsta register ensures that the device is in the transmit mode, otherwise the device will be configured to receive. setting the spen bit of the rcsta register enables the eusart. 20.4.2.1 eusart synchronous slave transmit the operation of the synchronous master and slave modes are identical (see section 20.4.1.3 ?synchronous master transmission?) , except in the case of the sleep mode. if two words are written to the txreg and then the sleep instruction is executed, the following will occur: 1. the first character will immediately transfer to the tsr register and transmit. 2. the second word will remain in txreg register. 3. the txif bit will not be set. 4. after the first character has been shifted out of tsr, the txreg register will transfer the second character to the tsr and the txif bit will now be set. 5. if the peie and txie bits are set, the interrupt will wake the device from sleep and execute the next instruction. if the gie bit is also set, the program will call the interrupt service routine. 20.4.2.2 synchronous slave transmission set-up: 1. set the sync and spen bits and clear the csrc bit. 2. clear the cren and sren bits. 3. if interrupts are desired, set the txie bit of the pie1 register and the gie and peie bits of the intcon register. 4. if 9-bit transmission is desired, set the tx9 bit. 5. enable transmission by setting the txen bit. 6. if 9-bit transmission is selected, insert the most significant bit into the tx9d bit. 7. start transmission by writing the least significant 8 bits to the txreg register. table 20-9: registers associated with synchronous slave transmission name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page baudcon abdovf rcidl ?sckp brg16 ? wue abden 226 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 rcsta spen rx9 sren cren adden ferr oerr rx9d 225 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 txreg eusart transmit data register 217* txsta csrc tx9 txen sync sendb brgh trmt tx9d 224 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for synchronous slave transmission. * page provides register information.
? 2009 microchip technology inc. preliminary ds41364c-page 241 pic16f193x/lf193x 20.4.2.3 eusart synchronous slave reception the operation of the synchronous master and slave modes is identical ( section 20.4.1.5 ?synchronous master reception? ), with the following exceptions: ? sleep ? cren bit is always set, therefore the receiver is never idle ? sren bit, which is a ?don?t care? in slave mode a character may be received while in sleep mode by setting the cren bit prior to entering sleep. once the word is received, the rsr register will transfer the data to the rcreg register. if the rcie enable bit is set, the interrupt generated will wake the device from sleep and execute the next instruction. if the gie bit is also set, the program will branch to the interrupt vector. 20.4.2.4 synchronous slave reception set-up: 1. set the sync and spen bits and clear the csrc bit. 2. if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. 3. if 9-bit reception is desired, set the rx9 bit. 4. set the cren bit to enable reception. 5. the rcif bit will be set when reception is complete. an interrupt will be generated if the rcie bit was set. 6. if 9-bit mode is enabled, retrieve the most significant bit from the rx9d bit of the rcsta register. 7. retrieve the 8 least significant bits from the receive fifo by reading the rcreg register. 8. if an overrun error occurs, clear the error by either clearing the cren bit of the rcsta register or by clearing the spen bit which resets the eusart. table 20-10: registers associated with synchronous slave reception name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page baudcon abdovf rcidl ?sckp brg16 ? wue abden 226 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 rcreg eusart receive data register 220* rcsta spen rx9 sren cren adden ferr oerr rx9d 225 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 txsta csrc tx9 txen sync sendb brgh trmt tx9d 224 legend: x = unknown, - = unimplemented read as ? 0 ?. shaded cells are not used for synchronous slave reception. * page provides register information.
pic16f193x/lf193x ds41364c-page 242 preliminary ? 2009 microchip technology inc. 20.5 eusart operation during sleep the eusart will remain active during sleep only in the synchronous slave mode. all other modes require the system clock and therefore cannot generate the neces- sary signals to run the transmit or receive shift regis- ters during sleep. synchronous slave mode uses an externally generated clock to run the transmit and receive shift registers. 20.5.1 synchronous receive during sleep to receive during sleep, all the following conditions must be met before entering sleep mode: ? rcsta and txsta control registers must be configured for synchronous slave reception (see section 20.4.2.4 ?synchronous slave reception set-up:? ). ? if interrupts are desired, set the rcie bit of the pie1 register and the gie and peie bits of the intcon register. ? the rcif interrupt flag must be cleared by read- ing rcreg to unload any pending characters in the receive buffer. upon entering sleep mode, the device will be ready to accept data and clocks on the rx/dt and tx/ck pins, respectively. when the data word has been completely clocked in by the external device, the rcif interrupt flag bit of the pir1 register will be set. thereby, waking the processor from sleep. upon waking from sleep, the instruction following the sleep instruction will be executed. if the gie global interrupt enable bit of the intcon register is also set, then the interrupt service routine at address 004h will be called. 20.5.2 synchronous transmit during sleep to transmit during sleep, all the following conditions must be met before entering sleep mode: ? rcsta and txsta control registers must be configured for synchronous slave transmission (see section 20.4.2.2 ?synchronous slave transmission set-up:? ). ? the txif interrupt flag must be cleared by writing the output data to the txreg, thereby filling the tsr and transmit buffer. ? if interrupts are desired, set the txie bit of the pie1 register and the peie bit of the intcon reg- ister. ? interrupt enable bits txie of the pie1 register and peie of the intcon register must set. upon entering sleep mode, the device will be ready to accept clocks on tx/ck pin and transmit data on the rx/dt pin. when the data word in the tsr has been completely clocked out by the external device, the pending byte in the txreg will transfer to the tsr and the txif flag will be set. thereby, waking the processor from sleep. at this point, the txreg is available to accept another character for transmission, which will clear the txif flag. upon waking from sleep, the instruction following the sleep instruction will be executed. if the gie global interrupt enable bit is also set then the interrupt service routine at address 0004h will be called.
? 2009 microchip technology inc. preliminary ds41364c-page 243 pic16f193x/lf193x 21.0 liquid crystal display (lcd) driver module the liquid crystal display (lcd) driver module generates the timing control to drive a static or multiplexed lcd panel. in the pic16f193x/lf193x device, the module drives the panels of up to four commons and up to 24 segments. the lcd module also provides control of the lcd pixel data. the lcd driver module supports: ? direct driving of lcd panel ? three lcd clock sources with selectable prescaler ? up to four common pins: - static (1 common) - 1/2 multiplex (2 commons) - 1/3 multiplex (3 commons) - 1/4 multiplex (4 commons) ? segment pins up to: - 16 (pic16f1933/1936/1938/ pic16lf1933/1936/1938) - 24 (pic16f1934/1937/1939/ pic16lf1934/1937/1939) ? static, 1/2 or 1/3 lcd bias 21.1 lcd registers the module contains the following registers: ? lcd control register (lcdcon) ? lcd phase register (lcdps) ? lcd reference ladder register (lcdrl) ? lcd contrast control register (lcdcst) ? lcd reference voltage control register (lcdref) ? up to 3 lcd segment enable registers (lcdsen) ? up to 12 lcd data registers (lcddatan) figure 21-1: lcd driver module block diagram note: com3 and seg15 share the same physical pin on the pic16f1933/1936/1938/ pic16lf1933/1936/1938, therefore seg15 is not available when using 1/4 multiplex displays. data bus seg<23:0> (1, 3) to i/o pads (1) lcddatax registers note 1: these are not directly connected to the i/o pads, but may be tri-stated, depending on the configuration of the lcd module. 2: seg<23:0> on pic16f1934/1937/1939, seg<15:0> on pic16f1933/1936/1938/ pic16lf1933/1936/1938. 3: com3 and seg15 share the same physical pin on the pic16f1933/1936/1938/pic16lf1933/1936/1938, therefore seg15 is not available when using 1/4 multiplex displays. com<3:0> (3) clock source timing control select and prescaler lfintosc f osc /256 t1osc to i/o pads (1) lcdcon lcdps lcdsen mux
pic16f193x/lf193x ds41364c-page 244 preliminary ? 2009 microchip technology inc. table 21-1: lcd segment and data registers the lcdcon register (register 21-1) controls the operation of the lcd driver module. the lcdps regis- ter (register 21-2) configures the lcd clock source prescaler and the type of waveform; type-a or type-b. the lcdse registers (register 21-5) configure the functions of the port pins. the following lcdse registers are available: ? lcdse0 se<7:0> ? lcdse1 se<15:8> ? lcdse2 se<23:16> (1) once the module is initialized for the lcd panel, the individual bits of the lcddata<11:0> registers are cleared/set to represent a clear/dark pixel, respectively: ? lcddata0 seg<7:0>com0 ? lcddata1 seg<15:8>com0 ? lcddata2 seg<23:16>com0 (1) ? lcddata3 seg<7:0>com1 ? lcddata4 seg<15:8>com1 ? lcddata5 seg<23:16>com1 (1) ? lcddata6 seg<7:0>com2 ? lcddata7 seg<15:8>com2 ? lcddata8 seg<23:16>com2 (1) ? lcddata9 seg<7:0>com3 ? lcddata10 seg<15:8>com3 ? lcddata11 seg<23:16>com3 (1) as an example, lcddatax is detailed in register 21-6. once the module is configured, the lcden bit of the lcdcon register is used to enable or disable the lcd module. the lcd panel can also operate during sleep by clearing the slpen bit of the lcdcon register. device # of lcd registers segment enable data pic16f1933/1936/1938/ pic16lf1933/1936/1938 28 pic16f1934/1937/1939/ pic16lf1934/1937/1939 312 note 1: pic16f1934/1937/1939/ pic16lf1934/1937/1939 only. note 1: pic16f1934/1937/1939/ pic16lf1934/1937/1939 only.
? 2009 microchip technology inc. preliminary ds41364c-page 245 pic16f193x/lf193x register 21-1: lcdcon: liquid crystal display (lcd) control register r/w-0/0 r/w-0/0 r/c-0/0 u-0 r/w-0/0 r/w-0/0 r/w-1/1 r/w-1/1 lcden slpen werr ? cs1 cs0 lmux1 lmux0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared c = only clearable bit bit 7 lcden: lcd driver enable bit 1 = lcd driver module is enabled 0 = lcd driver module is disabled bit 6 slpen: lcd driver enable in sleep mode bit 1 = lcd driver module is disabled in sleep mode 0 = lcd driver module is enabled in sleep mode bit 5 werr: lcd write failed error bit 1 = lcddatax register written while the wa bit of the lcdps register = 0 (must be cleared in software) 0 = no lcd write error bit 4 unimplemented: read as ? 0 ? bit 3-2 cs<1:0>: clock source select bits 00 = f osc /256 01 = t1osc (timer1) 1x = lfintosc (31 khz) bit 1-0 lmux<1:0>: commons select bits note 1: on these devices, com3 and seg15 are shared on one pin, limiting the device from driving 64 pixels. lmux<1:0> multiplex maximum number of pixels bias pic16f1933/1936/1938/ pic16lf1933/1936/1938 pic16f1934/1937/1939/ pic16lf1934/1937/1939 00 static (com0) 16 24 static 01 1/2 (com<1:0>) 32 48 1/2 or 1/3 10 1/3 (com<2:0>) 48 72 1/2 or 1/3 11 1/4 (com<3:0>) 60 (1) 96 1/3
pic16f193x/lf193x ds41364c-page 246 preliminary ? 2009 microchip technology inc. register 21-2: lcdps: lcd phase register r/w-0/0 r/w-0/0 r-0/0 r-0/0 r/w-0/0 r/w-0/0 r/w-1/1 r/w-1/1 wft biasmd lcda wa lp3 lp2 lp1 lp0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared c = only clearable bit bit 7 wft: waveform type bit 1 = type-b phase changes on each frame boundary 0 = type-a phase changes within each common type bit 6 biasmd: bias mode select bit when lmux<1:0> = 00 : 0 = static bias mode (do not set this bit to ? 1 ?) when lmux<1:0> = 01 : 1 = 1/2 bias mode 0 = 1/3 bias mode when lmux<1:0> = 10 : 1 = 1/2 bias mode 0 = 1/3 bias mode when lmux<1:0> = 11 : 0 = 1/3 bias mode (do not set this bit to ? 1 ?) bit 5 lcda: lcd active status bit 1 = lcd driver module is active 0 = lcd driver module is inactive bit 4 wa: lcd write allow status bit 1 = write into the lcddatax registers is allowed 0 = write into the lcddatax registers is not allowed bit 3-0 lp<3:0>: lcd prescaler selection bits 1111 = 1:16 1110 = 1:15 1101 = 1:14 1100 = 1:13 1011 = 1:12 1010 = 1:11 1001 = 1:10 1000 = 1:9 0111 = 1:8 0110 = 1:7 0101 = 1:6 0100 = 1:5 0011 = 1:4 0010 = 1:3 0001 = 1:2 0000 = 1:1
? 2009 microchip technology inc. preliminary ds41364c-page 247 pic16f193x/lf193x register 21-3: lcdref: lcd refe rence voltage control register r/w-0/0 r/w-0/0 r/w-0/0 u-0 r/w-0/0 r/w-0/0 r/w-0/0 u-0 lcdire lcdirs lcdiri ? vlcd3pe vlcd2pe vlcd1pe ? bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared c = only clearable bit bit 7 lcdire: lcd internal reference enable bit 1 = internal lcd reference is enabled and connected to the internal contrast control circuit 0 = internal lcd reference is disabled bit 6 lcdirs: lcd internal reference source bit if lcdire = 1: 0 = internal lcd contrast control is powered by v dd 1 = internal lcd contrast control is powered by a 3.072v output of the fvr. if lcdire = 0 : internal lcd contrast control is unconnected. lcd bandgap buffer is disabled. bit 5 lcdiri: lcd internal reference ladder idle enable bit allows the internal fvr buffer to shut down when the lcd reference ladder is in power mode ?b? 1 = when the lcd reference ladder is in power mode ?b?, the lcd internal fvr buffer is disabled. 0 = the lcd internal fvr buffer ignores the lcd reference ladder power mode. bit 4 unimplemented: read as ? 0 ? bit 3 vlcd3pe: vlcd3 pin enable bit 1 = the vlcd3 pin is connected to the internal bias voltage lcdbias3 (1) 0 = the vlcd3 pin is not connected bit 2 vlcd2pe: vlcd2 pin enable bit 1 = the vlcd2 pin is connected to the internal bias voltage lcdbias2 (1) 0 = the vlcd2 pin is not connected bit 1 vlcd1pe: vlcd1 pin enable bit 1 = the vlcd1 pin is connected to the internal bias voltage lcdbias1 (1) 0 = the vlcd1 pin is not connected bit 0 unimplemented: read as ? 0 ? note 1: normal pin controls of trisx and anselx are unaffected.
pic16f193x/lf193x ds41364c-page 248 preliminary ? 2009 microchip technology inc. register 21-4: lcdcst: lcd contrast control register u-0 u-0 u-0 u-0 u-0 r/w-0/0 r/w-0/0 r/w-0/0 ? ? ? ? ? lcdcst2 lcdcst1 lcdcst0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared c = only clearable bit bit 7-3 unimplemented: read as ? 0 ? bit 2-0 lcdcst<2:0>: lcd contrast control bits selects the resistance of the lcd contrast control resistor ladder bit value = resistor ladder 000 = minimum resistance (maximum contrast). resistor ladder is shorted. 001 = resistor ladder is at 1/7th of maximum resistance 010 = resistor ladder is at 2/7th of maximum resistance 011 = resistor ladder is at 3/7th of maximum resistance 100 = resistor ladder is at 4/7th of maximum resistance 101 = resistor ladder is at 5/7th of maximum resistance 110 = resistor ladder is at 6/7th of maximum resistance 111 = resistor ladder is at maximum resistance (minimum contrast).
? 2009 microchip technology inc. preliminary ds41364c-page 249 pic16f193x/lf193x register 21-5: lcdsen: lcd segment enable registers r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 sen sen sen sen sen sen sen sen bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 sen: segment enable bits 1 = segment function of the pin is enabled 0 = i/o function of the pin is enabled register 21-6: lcddatax: lcd data registers r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u segx-comy segx-comy segx-comy segx-comy segx-comy segx-comy segx-comy segx-comy bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 segx-comy: pixel on bits 1 = pixel on (dark) 0 = pixel off (clear)
pic16f193x/lf193x ds41364c-page 250 preliminary ? 2009 microchip technology inc. 21.2 lcd clock source selection the lcd module has 3 possible clock sources: ?f osc /256 ?t1osc ?lfintosc the first clock source is the system clock divided by 256 (f osc /256). this divider ratio is chosen to provide about 1 khz output when the system clock is 8 mhz. the divider is not programmable. instead, the lcd prescaler bits lp<3:0> of the lcdps register are used to set the lcd frame clock rate. the second clock source is the t1osc. this also gives about 1 khz when a 32.768 khz crystal is used with the timer1 oscillator. to use the timer1 oscillator as a clock source, the t1oscen bit of the t1con register should be set. the third clock source is the 31 khz lfintosc, which provides approximately 1 khz output. the second and third clock sources may be used to continue running the lcd while the processor is in sleep. using bits cs<1:0> of the lcdcon register can select any of these clock sources. 21.2.1 lcd prescaler a 4-bit counter is available as a prescaler for the lcd clock. the prescaler is not directly readable or writable; its value is set by the lp<3:0> bits of the lcdps register, which determine the prescaler assignment and prescale ratio. the prescale values are selectable from 1:1 through 1:16. figure 21-2: lcd cl ock generation cs<1:0> t1osc 32 khz crystal osc. lfintosc nominal = 31 khz static 1/2 1/3, 1/4 4 lmux<1:0> 4-bit prog 1, 2, 3, 4 ring counter lmux<1:0> com0 com1 com2 com3 256 f osc 2 32 lp<3:0> (lcdcon<3:2>) (lcdcon<1:0>) (lcdcon<1:0>) (lcdps<3:0>) prescaler 5 to reference ladder control
? 2009 microchip technology inc. preliminary ds41364c-page 251 pic16f193x/lf193x 21.3 lcd bias voltage generation the lcd module can be configured for one of three bias types: ? static bias (2 voltage levels: v ss and v lcd ) ? 1/2 bias (3 voltage levels: v ss , 1/2 v lcd and v lcd ) ? 1/3 bias (4 voltage levels: v ss , 1/3 v lcd , 2/3 v lcd and v lcd ) table 21-2: lcd bias voltages so that the user is not forced to place external compo- nents and use up to three pins for bias voltage generation, internal contrast control and an internal reference ladder are provided internally to the pic16f193x/lf193x. both of these features may be used in conjunction with the external vlcd<3:1> pins, to provide maximum flexibility. refer to figure 21-3. figure 21-3: lcd bias volt age generation block diagram static bias 1/2 bias 1/3 bias lcd bias 0 v ss v ss v ss lcd bias 1 ?1/2 v dd 1/3 v dd lcd bias 2 ?1/2 v dd 2/3 v dd lcd bias 3 v lcd 3v lcd 3v lcd 3 v dd lcdire x 3 3.072v 1.024v from fvr vlcd3 lcdirs lcdire lcdirs lcdcst<2:0> vlcd3pe vlcd2 vlcd2pe vlcd1 vlcd1pe lcdrlp1 biasmd lcdbias3 lcdbias2 lcdbias1 lcdbias0 lcda lcda lcda lcdrlp0
pic16f193x/lf193x ds41364c-page 252 preliminary ? 2009 microchip technology inc. 21.4 lcd bias internal reference ladder the internal reference ladder can be used to divide the lcd bias voltage two or three equally spaced voltages that will be supplied to the lcd segment pins. to create this, the reference ladder consists of three matched resistors. refer to figure 21-3. 21.4.1 bias mode interaction when in 1/2 bias mode (biasmd = 1 ), then the middle resistor of the ladder is shorted out so that only two voltages are generated. the current consumption of the ladder is higher in this mode, with the one resistor removed. table 21-3: lcd internal ladder power modes (1/3 bias) 21.4.2 power modes the internal reference ladder may be operated in one of three power modes. this allows the user to trade off lcd contrast for power in the specific application. the larger the lcd glass, the more capacitance is present on a physical lcd segment, requiring more current to maintain the same contrast level. three different power modes are available, lp, mp and hp. the internal reference ladder can also be turned off for applications that wish to provide an external ladder or to minimize power consumption. disabling the internal reference ladder results in all of the ladders being disconnected, allowing external voltages to be supplied. whenever the lcd module is inactive (lcda = 0 ), the internal reference ladder will be turned off. power mode nominal resistance of entire ladder nominal i dd low 3 mohm 1 a medium 300 kohm 10 a high 30 kohm 100 a
? 2009 microchip technology inc. preliminary ds41364c-page 253 pic16f193x/lf193x 21.4.3 automatic power mode switching as an lcd segment is electrically only a capacitor, cur- rent is drawn only during the interval where the voltage is switching. to minimize total device current, the lcd internal reference ladder can be operated in a different power mode for the transition portion of the duration. this is controlled by the lcdrl register (register 21-7). the lcdlad register allows switching between two power modes, designated ?a? and ?b?. ?a? power mode is active for a programmable time, beginning at the time win the lcd segments transition. ?b? power mode is the remaining time before the segments or com- mons change again. the lrlat<2:0> bits select how long, if any, that the ?a? power mode is active. refer to figure 21-4. to implement this, the 5-bit prescaler used to divide the 32 khz clock down to the lcd controller?s 1 khz base rate is used to select the power mode. figure 21-4: lcd internal reference l adder power mode switching diagram ? type a figure 21-5: lcd internal reference l adder power mode switching diagram ? type b single segment time ?h00 ?h01 ?h02 ?h03 ?h04 ?h05 ?h06 ?h07 ?h0e ?h0f ?h00 ?h01 ?h3 power mode a power mode b mode a lrlat<2:0> 32khz_clk cnt[4:0] lcd_clk lrlat[2:0] segment data power mode single segment time ?h00 ?h01 ?h02 ?h03 ?h04 ?h05 ?h06 ?h07 ?h1e ?h1f ?h00 ?h01 ?h3 power mode a power mode b mode a lrlat<2:0> 32khz_clk cnt[4:0] lcd_clk lrlat[2:0] segment data power mode
pic16f193x/lf193x ds41364c-page 254 preliminary ? 2009 microchip technology inc. register 21-7: lcdrl: lcd refere nce ladder control registers r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 u-0 r/w-0/0 r/w-0/0 r/w-0/0 lrlap1 lrlap0 lrlbp1 lrlbp0 ? lrlat2 lrlat1 lrlat0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-6 lrlap<1:0>: lcd reference ladder a time power control bits during time interval a (refer to figure 21-4): 00 = internal lcd reference ladder is powered down and unconnected 01 = internal lcd reference ladder is powered in low-power mode 10 = internal lcd reference ladder is powered in medium-power mode 11 = internal lcd reference ladder is powered in high-power mode bit 5-4 lrlbp<1:0>: lcd reference ladder b time power control bits during time interval b (refer to figure 21-4): 00 = internal lcd reference ladder is powered down and unconnected 01 = internal lcd reference ladder is powered in low-power mode 10 = internal lcd reference ladder is powered in medium-power mode 11 = internal lcd reference ladder is powered in high-power mode bit 3 unimplemented: read as ? 0 ? bit 2-0 lrlat<2:0>: lcd reference ladder a time interval control bits sets the number of 32 khz clocks that the a time interval power mode is active for type a waveforms (wft = 0 ): 000 = internal lcd reference ladder is always in ?b? power mode 001 = internal lcd reference ladder is in ?a? power mode for 1 clock and ?b? power mode for 15 clocks 010 = internal lcd reference ladder is in ?a? power mode for 2 clocks and ?b? power mode for 14 clocks 011 = internal lcd reference ladder is in ?a? power mode for 3 clocks and ?b? power mode for 13 clocks 100 = internal lcd reference ladder is in ?a? power mode for 4 clocks and ?b? power mode for 12 clocks 101 = internal lcd reference ladder is in ?a? power mode for 5 clocks and ?b? power mode for 11 clocks 110 = internal lcd reference ladder is in ?a? power mode for 6 clocks and ?b? power mode for 10 clocks 111 = internal lcd reference ladder is in ?a? power mode for 7 clocks and ?b? power mode for 9 clocks for type b waveforms (wft = 1 ): 000 = internal lcd reference ladder is always in ?b? power mode. 001 = internal lcd reference ladder is in ?a? power mode for 1 clock and ?b? power mode for 31 clocks 010 = internal lcd reference ladder is in ?a? power mode for 2 clocks and ?b? power mode for 30 clocks 011 = internal lcd reference ladder is in ?a? power mode for 3 clocks and ?b? power mode for 29 clocks 100 = internal lcd reference ladder is in ?a? power mode for 4 clocks and ?b? power mode for 28 clocks 101 = internal lcd reference ladder is in ?a? power mode for 5 clocks and ?b? power mode for 27 clocks 110 = internal lcd reference ladder is in ?a? power mode for 6 clocks and ?b? power mode for 26 clocks 111 = internal lcd reference ladder is in ?a? power mode for 7 clocks and ?b? power mode for 25 clocks
? 2009 microchip technology inc. preliminary ds41364c-page 255 pic16f193x/lf193x 21.4.4 contrast control the lcd contrast control circuit consists of a seven-tap resistor ladder, controlled by the lcdcst bits. refer to figure 21-6. the contrast control circuit is used to decrease the output voltage of the signal source by a total of approximately 10%, when lcdcst = 111 . whenever the lcd module is inactive (lcda = 0 ), the contrast control ladder will be turned off (open). figure 21-6: internal reference and contrast contro l block diagram 21.4.5 internal reference under firmware control, an internal reference for the lcd bias voltages can be enabled. when enabled, the source of this voltage can be either v ddio or a voltage 3 times the main fixed voltage reference (3.072v). when no internal reference is selected, the lcd con- trast control circuit is disabled and lcd bias must be provided externally. whenever the lcd module is inactive (lcda = 0 ), the internal reference will be turned off. when the internal reference is enabled and the fixed voltage reference is selected, the lcdiri bit can be used to minimize power consumption by tieing into the lcd reference ladder automatic power mode switch- ing. when lcdiri = 1 , the power mode that the inter- nal lcd reference ladder enables the buffer when in power mode ?a? and disables it when in power mode ?b?. . 21.4.6 vlcd<3:1> pins the vlcd<3:1> pins provide the ability for an external lcd bias network to be used instead of the internal lad- der. use of the vlcd<3:1> pins does not prevent use of the internal ladder. each vlcd pin has an indepen- dent control in the lcdref register (register 21-3), allowing access to any or all of the lcd bias signals. this architecture allows for maximum flexibility in differ- ent applications for example, the vlcd<3:1> pins may be used to add capacitors to the internal reference ladder, increasing the drive capacity. for applications where the internal contrast control is insufficient, the firmware can choose to only enable the vlcd3 pin, allowing an external contrast control circuit to use the internal reference divider. lcdcst<2:0> analog rr rr 7 stages mux to top of reference ladder 7 0 3 3.072v v ddio from fvr buffer internal reference contrast control note: the lcd module automatically turns on the fixed voltage reference when needed.
pic16f193x/lf193x ds41364c-page 256 preliminary ? 2009 microchip technology inc. 21.5 lcd multiplex types the lcd driver module can be configured into one of four multiplex types: ? static (only com0 is used) ? 1/2 multiplex (com<1:0> are used) ? 1/3 multiplex (com<2:0> are used) ? 1/4 multiplex (com<3:0> are used) the lmux<1:0> bit setting of the lcdcon register decides which of the lcd common pins are used (see table 21-4 for details). if the pin is a digital i/o, the corresponding tris bit controls the data direction. if the pin is a com drive, then the tris setting of that pin is overridden. table 21-4: common pin usage 21.6 segment enables the lcdsen registers are used to select the pin function for each segment pin. the selection allows each pin to operate as either an lcd segment driver or as one of the pin?s alternate functions. to configure the pin as a segment pin, the corresponding bits in the lcdsen registers must be set to ? 1 ?. if the pin is a digital i/o, the corresponding tris bit controls the data direction. any bit set in the lcdsen registers overrides any bit settings in the corresponding tris register. 21.7 pixel control the lcddatax registers contain bits which define the state of each pixel. each bit defines one unique pixel. register 21-6 shows the correlation of each bit in the lcddatax registers to the respective common and segment signals. any lcd pixel location not being used for display can be used as general purpose ram. 21.8 lcd frame frequency the rate at which the com and seg outputs change is called the lcd frame frequency. table 21-5: frame frequency formulas table 21-6: approximate frame frequency (in hz) using f osc @ 8 mhz, timer1 @ 32.768 khz or lfintosc multiplex lmux <1:0> com3 com2 com1 static 00 unused unused unused 1/2 01 unused unused active 1/3 10 unused active active 1/4 11 active active active note: on a power-on reset, these pins are configured as normal i/o, not lcd pins. multiplex frame frequency = static clock source/(4 x 1 x (lp<3:0> + 1)) 1/2 clock source/(2 x 2 x (lp<3:0> + 1)) 1/3 clock source/(1 x 3 x (lp<3:0> + 1)) 1/4 clock source/(1 x 4 x (lp<3:0> + 1)) note: clock source is f osc /256, t1osc or lfintosc. lp<3:0> static 1/2 1/3 1/4 2858511485 364648564 451516851 543435743 637374937 732324332
? 2009 microchip technology inc. preliminary ds41364c-page 257 pic16f193x/lf193x table 21-7: lcd segment mapping worksheet lcd function com0 com1 com2 com3 lcddatax address lcd segment lcddatax address lcd segment lcddatax address lcd segment lcddatax address lcd segment seg0 lcddata0, 0 lcddata3, 0 lcddata6, 0 lcddata9, 0 seg1 lcddata0, 1 lcddata3, 1 lcddata6, 1 lcddata9, 1 seg2 lcddata0, 2 lcddata3, 2 lcddata6, 2 lcddata9, 2 seg3 lcddata0, 3 lcddata3, 3 lcddata6, 3 lcddata9, 3 seg4 lcddata0, 4 lcddata3, 4 lcddata6, 4 lcddata9, 4 seg5 lcddata0, 5 lcddata3, 5 lcddata6, 5 lcddata9, 5 seg6 lcddata0, 6 lcddata3, 6 lcddata6, 6 lcddata9, 6 seg7 lcddata0, 7 lcddata3, 7 lcddata6, 7 lcddata9, 7 seg8 lcddata1, 0 lcddata4, 0 lcddata7, 0 lcddata10, 0 seg9 lcddata1, 1 lcddata4, 1 lcddata7, 1 lcddata10, 1 seg10 lcddata1, 2 lcddata4, 2 lcddata7, 2 lcddata10, 2 seg11 lcddata1, 3 lcddata4, 3 lcddata7, 3 lcddata10, 3 seg12 lcddata1, 4 lcddata4, 4 lcddata7, 4 lcddata10, 4 seg13 lcddata1, 5 lcddata4, 5 lcddata7, 5 lcddata10, 5 seg14 lcddata1, 6 lcddata4, 6 lcddata7, 6 lcddata10, 6 seg15 lcddata1, 7 lcddata4, 7 lcddata7, 7 lcddata10, 7 seg16 lcddata2, 0 lcddata5, 0 lcddata8, 0 lcddata11, 0 seg17 lcddata2, 1 lcddata5, 1 lcddata8, 1 lcddata11, 1 seg18 lcddata2, 2 lcddata5, 2 lcddata8, 2 lcddata11, 2 seg19 lcddata2, 3 lcddata5, 3 lcddata8, 3 lcddata11, 3 seg20 lcddata2, 4 lcddata5, 4 lcddata8, 4 lcddata11, 4 seg21 lcddata2, 5 lcddata5, 5 lcddata8, 5 lcddata11, 5 seg22 lcddata2, 6 lcddata5, 6 lcddata8, 6 lcddata11, 6 seg23 lcddata2, 7 lcddata5, 7 lcddata8, 7 lcddata11, 7
pic16f193x/lf193x ds41364c-page 258 preliminary ? 2009 microchip technology inc. 21.9 lcd waveform generation lcd waveforms are generated so that the net ac voltage across the dark pixel should be maximized and the net ac voltage across the clear pixel should be minimized. the net dc voltage across any pixel should be zero. the com signal represents the time slice for each common, while the seg contains the pixel data. the pixel signal (com-seg) will have no dc component and it can take only one of the two rms values. the higher rms value will create a dark pixel and a lower rms value will create a clear pixel. as the number of commons increases, the delta between the two rms values decreases. the delta represents the maximum contrast that the display can have. the lcds can be driven by two types of waveform: type-a and type-b. in type-a waveform, the phase changes within each common type, whereas in type-b waveform, the phase changes on each frame boundary. thus, type-a waveform maintains 0 v dc over a single frame, whereas type-b waveform takes two frames. figure 21-7 through figure 21-17 provide waveforms for static, half-multiplex, 1/3-multiplex and 1/4-multiplex drives for type-a and type-b waveforms. figure 21-7: type-a/type-b waveforms in static drive note 1: if sleep has to be executed with lcd sleep disabled (lcdcon is ? 1 ?), then care must be taken to execute sleep only when v dc on all the pixels is ? 0 ?. 2: when the lcd clock source is f osc /256, if sleep is executed, irrespective of the lcdcon setting, the lcd immediately goes into sleep. thus, take care to see that v dc on all pixels is ? 0 ? when sleep is executed. v 1 v 0 com0 seg0 com0-seg0 com0-seg1 seg1 v 1 v 0 v 1 v 0 v 0 v 1 -v 1 v 0 1 frame com0 seg0 seg1 seg2 seg3 seg4 seg5 seg6 seg7
? 2009 microchip technology inc. preliminary ds41364c-page 259 pic16f193x/lf193x figure 21-8: type-a waveforms in 1/2 mux, 1/2 bias drive v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 -v 2 -v 1 v 2 v 1 v 0 -v 2 -v 1 com0 com1 seg0 seg1 com0-seg0 com0-seg1 1 frame com1 com0 seg0 seg1 seg2 seg3
pic16f193x/lf193x ds41364c-page 260 preliminary ? 2009 microchip technology inc. figure 21-9: type-b waveforms in 1/2 mux, 1/2 bias drive v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 -v 2 -v 1 v 2 v 1 v 0 -v 2 -v 1 com0 com1 seg0 seg1 com0-seg0 com0-seg1 com1 com0 seg0 seg1 seg2 seg3 2 frames
? 2009 microchip technology inc. preliminary ds41364c-page 261 pic16f193x/lf193x figure 21-10: type-a waveforms in 1/2 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 seg0 seg1 com0-seg0 com0-seg1 1 frame com1 com0 seg0 seg1 seg2 seg3
pic16f193x/lf193x ds41364c-page 262 preliminary ? 2009 microchip technology inc. figure 21-11: type-b waveforms in 1/2 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 seg0 seg1 com0-seg0 com0-seg1 com1 com0 seg0 seg1 seg2 seg3 2 frames
? 2009 microchip technology inc. preliminary ds41364c-page 263 pic16f193x/lf193x figure 21-12: type-a waveforms in 1/3 mux, 1/2 bias drive v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 -v 2 -v 1 v 2 v 1 v 0 -v 2 -v 1 com0 com1 com2 seg0 seg1 com0-seg0 com0-seg1 1 frame com2 com1 com0 seg0 seg1 seg2 seg2
pic16f193x/lf193x ds41364c-page 264 preliminary ? 2009 microchip technology inc. figure 21-13: type-b waveforms in 1/3 mux, 1/2 bias drive v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 v 2 v 1 v 0 -v 2 -v 1 v 2 v 1 v 0 -v 2 -v 1 com0 com1 com2 seg0 seg1 com0-seg0 com0-seg1 2 frames com2 com1 com0 seg0 seg1 seg2
? 2009 microchip technology inc. preliminary ds41364c-page 265 pic16f193x/lf193x figure 21-14: type-a waveforms in 1/3 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 com2 seg0 seg1 com0-seg0 com0-seg1 1 frame com2 com1 com0 seg0 seg1 seg2 seg2
pic16f193x/lf193x ds41364c-page 266 preliminary ? 2009 microchip technology inc. figure 21-15: type-b waveforms in 1/3 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 com2 seg0 seg1 com0-seg0 com0-seg1 2 frames com2 com1 com0 seg0 seg1 seg2
? 2009 microchip technology inc. preliminary ds41364c-page 267 pic16f193x/lf193x figure 21-16: type-a waveforms in 1/4 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 com2 com3 seg0 seg1 com0-seg0 com0-seg1 com3 com2 com1 com0 1 frame seg0 seg1
pic16f193x/lf193x ds41364c-page 268 preliminary ? 2009 microchip technology inc. figure 21-17: type-b waveforms in 1/4 mux, 1/3 bias drive v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 v 3 v 2 v 1 v 0 -v 3 -v 2 -v 1 com0 com1 com2 com3 seg0 seg1 com0-seg0 com0-seg1 com3 com2 com1 com0 2 frames seg0 seg1
? 2009 microchip technology inc. preliminary ds41364c-page 269 pic16f193x/lf193x 21.10 lcd interrupts the lcd module provides an interrupt in two cases. an interrupt when the lcd controller goes from active to inactive controller. an interrupt also provides unframe boundaries for type b waveform. the lcd timing gen- eration provides an interrupt that defines the lcd frame timing. 21.10.1 lcd interrupt on module shutdown an lcd interrupt is generated when the module com- pletes shutting down (lcda goes from ? 1 ? to ? 0 ?). 21.10.2 lcd frame interrupts a new frame is defined to begin at the leading edge of the com0 common signal. the interrupt will be set immediately after the lcd controller completes access- ing all pixel data required for a frame. this will occur at a fixed interval before the frame boundary (t fint ), as shown in figure 21-18. the lcd controller will begin to access data for the next frame within the interval from the interrupt to when the controller begins to access data after the interrupt (t fwr ). new data must be writ- ten within t fwr , as this is when the lcd controller will begin to access the data for the next frame. when the lcd driver is running with type-b waveforms and the lmux<1:0> bits are not equal to ? 00 ? (static drive), there are some additional issues that must be addressed. since the dc voltage on the pixel takes two frames to maintain zero volts, the pixel data must not change between subsequent frames. if the pixel data were allowed to change, the waveform for the odd frames would not necessarily be the complement of the waveform generated in the even frames and a dc component would be introduced into the panel. therefore, when using type-b waveforms, the user must synchronize the lcd pixel updates to occur within a subframe after the frame interrupt. to correctly sequence writing while in type-b, the interrupt will only occur on complete phase intervals. if the user attempts to write when the write is disabled, the werr bit of the lcdcon register is set and the write does not occur. note: the lcd frame interrupt is not generated when the type-a waveform is selected and when the type-b with no multiplex (static) is selected.
pic16f193x/lf193x ds41364c-page 270 preliminary ? 2009 microchip technology inc. figure 21-18: waveforms and interrupt ti ming in quarter- duty cycle drive (example ? type-b, non-static) frame boundary frame boundary lcd interrupt occurs controller accesses next frame data t fint t fwr t fwr =t frame /2*(lmux<1:0> + 1) + t cy /2 t fint =(t fwr /2 ? (2 t cy + 40 ns)) minimum = 1.5(t frame /4) ? (2 t cy + 40 ns) (t fwr /2 ? (1 t cy + 40 ns)) maximum = 1.5(t frame /4) ? (1 t cy + 40 ns) frame boundary v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 com0 com1 com2 com3 2 frames
? 2009 microchip technology inc. preliminary ds41364c-page 271 pic16f193x/lf193x 21.11 operation during sleep the lcd module can operate during sleep. the selection is controlled by bit slpen of the lcdcon register. setting the slpen bit allows the lcd module to go to sleep. clearing the slpen bit allows the module to continue to operate during sleep. if a sleep instruction is executed and slpen = 1 , the lcd module will cease all functions and go into a very low-current consumption mode. the module will stop operation immediately and drive the minimum lcd voltage on both segment and common lines. figure 21-19 shows this operation. the lcd module can be configured to operate during sleep. the selection is controlled by bit slpen of the lcdcon register. clearing slpen and correctly con- figuring the lcd module clock will allow the lcd mod- ule to operate during sleep. setting slpen and correctly executing the lcd module shutdown will dis- able the lcd module during sleep and save power. if a sleep instruction is executed and slpen = 1 , the lcd module will immediately cease all functions, drive the outputs to vss and go into a very low-current mode. the sleep instruction should only be executed after the lcd module has been disabled and the current cycle completed, thus ensuring that there are no dc voltages on the glass. to disable the lcd module, clear the lcden bit. the lcd module will complete the disabling process after the current frame, clear the lcda bit and optionally cause an interrupt. the steps required to properly enter sleep with the lcd disabled are: ? clear lcden ? wait for lcda = 0 either by polling or by interrupt ? execute sleep if slpen = 0 and sleep is executed while the lcd module clock source is f osc /4, then the lcd module will halt with the pin driving the last lcd voltage pat- tern. prolonged exposure to a fixed lcd voltage pat- tern will cause damage to the lcd glass. to prevent lcd glass damage, either perform the proper lcd module shutdown prior to sleep, or change the lcd module clock to allow the lcd module to continue operation during sleep. if a sleep instruction is executed and slpen = 0 and the lcd module clock is either t1osc or lfintosc, the module will continue to display the current contents of the lcddata registers. while in sleep, the lcd data cannot be changed. if the lcdie bit is set, the device will wake from sleep on the next lcd frame boundary. the lcd module current consumption will not decrease in this mode; however, the overall device power consumption will be lower due to the shutdown of the cpu and other peripherals. table 21-8 shows the status of the lcd module during a sleep while using each of the three available clock sources. if a sleep instruction is executed and slpen = 0 , the module will continue to display the current contents of the lcddata registers. to allow the module to continue operation while in sleep, the clock source must be either the lfintosc or t1osc external oscillator. while in sleep, the lcd data cannot be changed. the lcd module current consumption will not decrease in this mode; however, the overall consumption of the device will be lower due to shut down of the core and other peripheral functions. table 21-8 shows the status of the lcd module during sleep while using each of the three available clock sources: table 21-8: lcd module status during sleep if lcd interrupts are being generated (type-b wave- form with a multiplex mode not static) and lcdie = 1 , the device will awaken from sleep on the next frame boundary. note: when the lcden bit is cleared, the lcd module will be disabled at the completion of frame. at this time, the port pins will revert to digital functionality. to minimize power consumption due to floating digital inputs, the lcd pins should be driven low using the port and tris registers. clock source slpen operational during sleep t1osc 0 yes 1 no lfintosc 0 yes 1 no f osc /4 0 no 1 no note: the lfintosc or external t1osc oscillator must be used to operate the lcd module during sleep.
pic16f193x/lf193x ds41364c-page 272 preliminary ? 2009 microchip technology inc. figure 21-19: sleep entry/exit when slpen = 1 sleep instruction execution wake-up 2 frames v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 v 3 v 2 v 1 v 0 com0 com1 com2 seg0
? 2009 microchip technology inc. preliminary ds41364c-page 273 pic16f193x/lf193x 21.12 configuring the lcd module the following is the sequence of steps to configure the lcd module. 1. select the frame clock prescale using bits lp<3:0> of the lcdps register. 2. configure the appropriate pins to function as segment drivers using the lcdsen registers. 3. configure the lcd module for the following using the lcdcon register: - multiplex and bias mode, bits lmux<1:0> - timing source, bits cs<1:0> - sleep mode, bit slpen 4. write initial values to pixel data registers, lcddata0 through lcddata11 (lcddata23 on pic16f1938). 5. clear lcd interrupt flag, lcdif bit of the pir2 register and if desired, enable the interrupt by setting bit lcdie of the pie2 register. 6. configure bias voltages by setting the lcdrl, lcdref and the associated anselx registers as needed. 7. enable the lcd module by setting bit lcden of the lcdcon register. 21.13 disabling the lcd module to disable the lcd module, write all ? 0 ?s to the lcdcon register. 21.14 lcd current consumption when using the lcd module the current consumption consists of the following three factors: ? oscillator selection ? lcd bias source ? capacitance of the lcd segments the current consumption of just the lcd module can be considered negligible compared to these other factors. 21.14.1 oscillator selection the current consumed by the clock source selected must be considered when using the lcd module. see section 28.0 ?electrical specifications? for oscillator current consumption information. 21.14.2 lcd bias source the lcd bias source, internal or external, can contrib- ute significantly to the current consumption. use the highest possible resistor values while maintaining contrast to minimize current. 21.14.3 capacitance of the lcd segments the lcd segments which can be modeled as capaci- tors which must be both charged and discharged every frame. the size of the lcd segment and its technology determines the segment?s capacitance.
pic16f193x/lf193x ds41364c-page 274 preliminary ? 2009 microchip technology inc. table 21-9: registers associated with lcd operation name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 lcdcon lcden slpen werr ? cs1 cs0 lmux1 lmux0 245 lcdcst ? ? ? ? ? lcdcst2 lcdcst1 lcdcst0 248 lcddata0 seg7 com0 seg6 com0 seg5 com0 seg4 com0 seg3 com0 seg2 com0 seg1 com0 seg0 com0 249 lcddata1 seg15 com0 seg14 com0 seg13 com0 seg12 com0 seg11 com0 seg10 com0 seg9 com0 seg8 com0 249 lcddata2 seg23 com0 seg22 com0 seg21 com0 seg20 com0 seg19 com0 seg18 com0 seg17 com0 seg16 com0 249 lcddata3 seg7 com1 seg6 com1 seg5 com1 seg4 com1 seg3 com1 seg2 com1 seg1 com1 seg0 com1 249 lcddata4 seg15 com1 seg14 com1 seg13 com1 seg12 com1 seg11 com1 seg10 com1 seg9 com1 seg8 com1 249 lcddata5 seg23 com1 seg22 com1 seg21 com1 seg20 com1 seg19 com1 seg18 com1 seg17 com1 seg16 com1 249 lcddata6 seg7 com2 seg6 com2 seg5 com2 seg4 com2 seg3 com2 seg2 com2 seg1 com2 seg0 com2 249 lcddata7 seg15 com2 seg14 com2 seg13 com2 seg12 com2 seg11 com2 seg10 com2 seg9 com2 seg8 com2 249 lcddata8 seg23 com2 seg22 com2 seg21 com2 seg20 com2 seg19 com2 seg18 com2 seg17 com2 seg16 com2 249 lcddata9 seg7 com3 seg6 com3 seg5 com3 seg4 com3 seg3 com3 seg2 com3 seg1 com3 seg0 com3 249 lcddata10 seg15 com3 seg14 com3 seg13 com3 seg12 com3 seg11 com3 seg10 com3 seg9 com3 seg8 com3 249 lcddata11 seg23 com3 seg22 com3 seg21 com3 seg20 com3 seg19 com3 seg18 com3 seg17 com3 seg16 com3 249 lcdps wft biasmd lcda wa lp3 lp2 lp1 lp0 246 lcdref lcdire lcdirs lcdiri ? vlcd3pe vlcd2pe vlcd1pe ? 247 lcdrl lrlap1 lrlap0 lrlbp1 lrlbp0 ? lrlat2 lrlat1 lrlat0 254 lcdse0 se7 se6 se5 se4 se3 se2 se1 se0 249 lcdse1 se15 se14 se13 se12 se11 se10 se9 se8 249 lcdse2 se23 se22 se21 se20 se19 se18 se17 se16 249 pie2 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie 77 pir2 osfif c2if c1if eeif bclif lcdif ? ccp2if 80 t1con tmr1cs1 tmr1cs0 t1ckps1 t1ckps0 t1oscen t1sync ? tmr1on 171 legend: x = unknown, u = unchanged, - = unimplemented, read as ? 0 ?. shaded cells are not used by the lcd module.
? 2009 microchip technology inc. preliminary ds41364c-page 275 pic16f193x/lf193x 22.0 master synchronous serial port (mssp) module 22.1 master ssp (mssp) module overview the master synchronous serial port (mssp) module is a serial interface useful for communicating with other peripheral or microcontroller devices. these peripheral devices may be serial eeproms, shift registers, dis- play drivers, a/d converters, etc. the mssp module can operate in one of two modes: ? serial peripheral interface (spi) ? inter-integrated circuit (i 2 c?) the spi interface supports the following modes and features: ?master mode ? slave mode ? clock parity ? slave select synchronization (slave mode only) ? daisy chain connection of slave devices figure 22-1 is a block diagram of the spi interface module. figure 22-1: mssp block diagram (spi mode) ( ) read write data bus sspsr reg sspm<3:0> bit 0 shift clock ss control enable edge select clock select tmr2 output t osc prescaler 4, 16, 64 2 edge select 2 (ckp, cke) 4 tris bit sdo sspbuf reg sdi ss sck baud rate generator (sspadd)
pic16f193x/lf193x ds41364c-page 276 preliminary ? 2009 microchip technology inc. the i 2 c interface supports the following modes and features: ?master mode ? slave mode ? byte nacking (slave mode) ? limited multi-master support ? 7-bit and 10-bit addressing ? start and stop interrupts ? interrupt masking ? clock stretching ? bus collision detection ? general call address matching ?address masking ? address hold and data hold modes ? selectable sda hold times figure 22-2 is a block diagram of the i 2 c interface mod- ule in master mode. figure 22-3 is a diagram of the i 2 c interface module in slave mode. figure 22-2: mssp block diagram (i 2 c? master mode) read write sspsr start bit, stop bit, start bit detect, sspbuf internal data bus set/reset: s, p, sspstat, wcol, sspov shift clock msb lsb sda acknowledge generate (sspcon2) stop bit detect write collision detect clock arbitration state counter for end of xmit/rcv scl scl in bus collision sda in receive enable (rcen) clock cntl clock arbitrate/bcol detect (hold off clock source) [sspm 3:0] baud rate reset sen, pen (sspcon2) generator (sspadd) address match detect set sspif, bclif
? 2009 microchip technology inc. preliminary ds41364c-page 277 pic16f193x/lf193x figure 22-3: mssp block diagram (i 2 c? slave mode) 22.2 mssp control registers the mssp module has seven associated registers: ? mssp status register (sspstat) ? mssp control register 1 (sspcon1) ? mssp control register 2 (sspcon2) ? mssp control register 3 (sspcon3) ? mssp address masking register (sspmsk) ? mssp data buffer register (sspbuf) ? mssp address register (sspadd) read write sspsr reg match detect sspadd reg start and stop bit detect sspbuf reg internal data bus addr match set, reset s, p bits (sspstat reg) scl sda shift clock msb lsb sspmsk reg
pic16f193x/lf193x ds41364c-page 278 preliminary ? 2009 microchip technology inc. register 22-1: sspstat: ssp status register r/w-0/0 r/w-0/0 r-0/0 r-0/0 r-0/0 r-0/0 r-0/0 r-0/0 smp cke d/a psr/w ua bf bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 smp: spi data input sample bit spi master mode: 1 = input data sampled at end of data output time 0 = input data sampled at middle of data output time spi slave mode: smp must be cleared when spi is used in slave mode in i 2 c master or slave mode: 1 = slew rate control disabled for standard speed mode (100 khz and 1 mhz) 0 = slew rate control enabled for high speed mode (400 khz) bit 6 cke: spi clock edge select bit in spi master or slave mode: 1 = transmit occurs on transition from active to idle clock state 0 = transmit occurs on transition from idle to active clock state in i 2 c? mode only: 1 = enable input logic so that thresholds are compliant with smbus? specification 0 = disable smbus? specific inputs bit 5 d/a : data/address bit (i 2 c mode only) 1 = indicates that the last byte received or transmitted was data 0 = indicates that the last byte received or transmitted was address bit 4 p: stop bit (i 2 c mode only. this bit is cleared when the ms sp module is disabled, sspen is cleared.) 1 = indicates that a stop bit has been detected last (this bit is ? 0 ? on reset) 0 = stop bit was not detected last bit 3 s: start bit (i 2 c mode only. this bit is cleared when the ms sp module is disabled, sspen is cleared.) 1 = indicates that a start bit has been detected last (this bit is ? 0 ? on reset) 0 = start bit was not detected last bit 2 r/w : read/write bit information (i 2 c mode only) this bit holds the r/w bit information following the last address match. this bit is only valid from the address match to the next start bit, stop bit, or not ack bit. in i 2 c slave mode: 1 = read 0 = write in i 2 c master mode: 1 = transmit is in progress 0 = transmit is not in progress or-ing this bit with sen, rsen, pen, rcen or acken will indicate if the mssp is in idle mode. bit 1 ua: update address bit (10-bit i 2 c mode only) 1 = indicates that the user needs to update the address in the sspadd register 0 = address does not need to be updated bit 0 bf: buffer full status bit receive (spi and i 2 c modes): 1 = receive complete, sspbuf is full 0 = receive not complete, sspbuf is empty transmit (i 2 c mode only): 1 = data transmit in progress (does not include the ack and stop bits), sspbuf is full 0 = data transmit complete (does not include the ack and stop bits), sspbuf is empty
? 2009 microchip technology inc. preliminary ds41364c-page 279 pic16f193x/lf193x register 22-2: sspcon1: ssp control register 1 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 wcol: write collision detect bit master mode: 1 = a write to the sspbuf register was attempted while the i 2 c conditions were not valid for a transmission to be started 0 = no collision slave mode: 1 = the sspbuf register is written while it is still transmitting the previous word (must be cleared in software) 0 = no collision bit 6 sspov: receive overflow indicator bit (1) in spi mode: 1 = a new byte is received while the sspbuf register is still holding the previous data. in case of overflow, the data in sspsr i s lost. overflow can only occur in slave mode. in slave mode, the user must read the sspbuf, even if only transmitting data, to avoid setting overflow. in master mode, the overflow bit is not set since each new reception (and transmission) is initiated by writi ng to the sspbuf register (must be cleared in software). 0 = no overflow in i 2 c mode: 1 = a byte is received while the sspbuf register is still holding the previous byte. sspov is a ?don?t care? in transmit mode (must be cleared in software). 0 = no overflow bit 5 sspen: synchronous serial port enable bit in both modes, when enabled, these pins must be properly configured as input or output in spi mode: 1 = enables serial port and configures sck, sdo, sdi and ss as the source of the serial port pins (2) 0 = disables serial port and configures these pins as i/o port pins in i 2 c mode: 1 = enables the serial port and configures the sda and scl pins as the source of the serial port pins (3) 0 = disables serial port and configures these pins as i/o port pins bit 4 ckp: clock polarity select bit in spi mode: 1 = idle state for clock is a high level 0 = idle state for clock is a low level in i 2 c slave mode: sck release control 1 = enable clock 0 = holds clock low (clock stretch). (used to ensure data setup time.) in i 2 c master mode: unused in this mode bit 3-0 sspm<3:0>: synchronous serial port mode select bits 0000 = spi master mode, clock = f osc /4 0001 = spi master mode, clock = f osc /16 0010 = spi master mode, clock = f osc /64 0011 = spi master mode, clock = tmr2 output/2 0100 = spi slave mode, clock = sck pin, ss pin control enabled 0101 = spi slave mode, clock = sck pin, ss pin control disabled, ss can be used as i/o pin 0110 = i 2 c slave mode, 7-bit address 0111 = i 2 c slave mode, 10-bit address 1000 = i 2 c master mode, clock = f osc / (4 * (sspadd+1)) (4) 1001 = reserved 1010 = spi master mode, clock = f osc /(4 * (sspadd+1)) 1011 = i 2 c firmware controlled master mode (slave idle) 1100 = reserved 1101 = reserved 1110 = i 2 c slave mode, 7-bit address with start and stop bit interrupts enabled 1111 = i 2 c slave mode, 10-bit address with start and stop bit interrupts enabled note 1: in master mode, the overflow bit is not set since each new reception (and transmission) is initiated by writing to the sspbuf r egister. 2: when enabled, these pins must be properly configured as input or output. 3: when enabled, the sda and scl pins must be configured as inputs. 4: sspadd values of 0, 1 or 2 are not supported for i 2 c mode.
pic16f193x/lf193x ds41364c-page 280 preliminary ? 2009 microchip technology inc. register 22-3: sspcon2: ssp control register 2 r/w-0/0 r-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 gcen ackstat ackdt acken rcen pen rsen sen bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 gcen: general call enable bit (in i 2 c slave mode only) 1 = enable interrupt when a general call address (0x00 or 00h) is received in the sspsr 0 = general call address disabled bit 6 ackstat: acknowledge status bit (in i 2 c mode only) 1 = acknowledge was not received 0 = acknowledge was received bit 5 ackdt: acknowledge data bit (in i 2 c mode only) in r eceive mode: value transmitted when the user initiates an acknowledge sequence at the end of a receive 1 = not acknowledge 0 = acknowledge bit 4 acken: acknowledge sequence enable bit (in i 2 c master mode only) in master receive mode: 1 = initiate acknowledge sequence on sda and scl pins, and transmit ackdt data bit. automatically cleared by hardware. 0 = acknowledge sequence idle bit 3 rcen: receive enable bit (in i 2 c master mode only) 1 = enables receive mode for i 2 c 0 = receive idle bit 2 pen: stop condition enable bit (in i 2 c master mode only) sck release control: 1 = initiate stop condition on sda and scl pins. automatically cleared by hardware. 0 = stop condition idle bit 1 rsen: repeated start condition enabled bit (in i 2 c master mode only) 1 = initiate repeated start condition on sda and scl pins. automatically cleared by hardware. 0 = repeated start condition idle bit 0 sen: start condition enabled bit (in i 2 c master mode only) in master mode: 1 = initiate start condition on sda and scl pins. automatically cleared by hardware. 0 = start condition idle in slave mode: 1 = clock stretching is enabled for both slave transmit and slave receive (stretch enabled) 0 = clock stretching is disabled note 1: for bits acken, rcen, pen, rsen, sen: if the i 2 c module is not in the idle mode, this bit may not be set (no spooling) and the sspbuf may not be written (or writes to the sspbuf are disabled).
? 2009 microchip technology inc. preliminary ds41364c-page 281 pic16f193x/lf193x register 22-4: sspcon3: ssp control register 3 r-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 acktim pcie scie boen sdaht sbcde ahen dhen bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 acktim: acknowledge time status bit (i 2 c mode only) 1 = indicates the i 2 c bus is in an acknowledge sequence, set on 8 th falling edge of scl clock 0 = not an acknowledge sequence, cleared on 9 th rising edge of scl clock bit 6 pcie : stop condition interrupt enable bit (i 2 c mode only) 1 = enable interrupt on detection of stop condition 0 = stop detection interrupts are disabled (2) bit 5 scie : start condition interrupt enable bit (i 2 c mode only) 1 = enable interrupt on detection of start or restart conditions 0 = start detection interrupts are disabled (2) bit 4 boen: buffer overwrite enable bit in spi slave mode: (1) 1 = sspbuf updates every time that a new data byte is shifted in ignoring the bf bit 0 = if new byte is received with bf bit of the sspstat register already set, sspov bit of the sspcon1 register is set, and the buffer is not updated in i 2 c master mode: this bit is ignored. in i 2 c slave mode: 1 = sspbuf is updated and ack is generated for a received address/data byte, ignoring the state of the sspov bit only if the bf bit = 0 . 0 = sspbuf is only updated when sspov is clear bit 3 sdaht: sda hold time selection bit (i 2 c mode only) 1 = minimum of 300 ns hold time on sda after the falling edge of scl 0 = minimum of 100 ns hold time on sda after the falling edge of scl bit 2 sbcde: slave mode bus collision detect enable bit (i 2 c slave mode only) if on the rising edge of scl, sda is sampled low when the module is outputting a high state, the bclif bit of the pir2 register is set, and bus goes idle 1 = enable slave bus collision interrupts 0 = slave bus collision interrupts are disabled bit 1 ahen: address hold enable bit (i 2 c slave mode only) 1 = following the 8th falling edge of scl for a matching received address byte; ckp bit of the sspcon1 register will be cleared and the scl will be held low. 0 = address holding is disabled bit 0 dhen: data hold enable bit (i 2 c slave mode only) 1 = following the 8th falling edge of scl for a received data byte; slave hardware clears the ckp bit of the sspcon1 register and scl is held low. 0 = data holding is disabled note 1: for daisy-chained spi operation; allows the user to ignore all but the last received byte. sspov is still set when a new byte is received and bf = 1 , but hardware continues to write the most recent byte to sspbuf. 2: this bit has no effect in slave modes that start and stop condition detection is explicitly listed as enabled.
pic16f193x/lf193x ds41364c-page 282 preliminary ? 2009 microchip technology inc. register 22-5: sspmsk: ssp mask register r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 r/w-1/1 msk7 msk6 msk5 msk4 msk3 msk2 msk1 msk0 (2) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-1 msk<7:1>: mask bits 1 = the received address bit n is compared to sspadd to detect i 2 c address match 0 = the received address bit n is not used to detect i 2 c address match bit 0 msk<0>: mask bit for i 2 c slave mode, 10-bit address i 2 c slave mode, 10-bit address (sspm<3:0> = 0111 or 1111 ): 1 = the received address bit 0 is compared to sspadd<0> to detect i 2 c address match 0 = the received address bit 0 is not used to detect i 2 c address match i 2 c slave mode, 7-bit address, the bit is ignored register 22-6: sspadd: mssp address and baud rate register (i 2 c mode) r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 add7 add6 add5 add4 add3 add2 add1 add0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared master mode : bit 7-0 add<7:0>: baud rate clock divider bits scl pin clock period = ((add<7:0> + 1) *4)/f osc 10-bit slave mode ? most si gnificant ad dress byte: bit 7-3 not used: unused for most significant address byte. bit state of this register is a ?don?t care?. bit pat- tern sent by master is fixed by i 2 c specification and must be equal to ? 11110 ?. however, those bits are compared by hardware and are not affected by the value in this register. bit 2-1 add<2:1>: two most significant bits of 10-bit address bit 0 not used: unused in this mode. bit state is a ?don?t care?. 10-bit slave mode ? least si gnificant ad dress byte: bit 7-0 add<7:0>: eight least significant bits of 10-bit address 7-bit slave mode: bit 7-1 add<7:1>: 7-bit address bit 0 not used: unused in this mode. bit state is a ?don?t care?.
? 2009 microchip technology inc. preliminary ds41364c-page 283 pic16f193x/lf193x 22.3 spi mode the spi mode allows 8 bits of data to be synchronously transmitted and received simultaneously. all four clock modes of spi are supported in both master and slave modes. to accomplish communication, typically three pins are used: ? serial data out (sdo) ? serial data in (sdi) ? serial clock (sck) additionally, a fourth pin may be used when in a slave mode of operation: ? slave select (ss ) figure 22-1 shows the block diagram of the mssp module when operating in spi mode. 22.3.1 registers the mssp module has five registers for spi mode operation. these are: ? mssp status register (sspstat) ? mssp control register 1 (sspcon1) ? mssp control register 3 (sspcon3) ? mssp data buffer register (sspbuf) ? mssp address register (sspadd) ? mssp shift register (sspsr) (not directly accessible) sspcon1 and sspstat are the control and status registers in spi mode operation. the sspcon1 regis- ter is readable and writable. the lower 6 bits of the sspstat are read-only. the upper two bits of the sspstat are read/write. in one spi master mode, sspadd can be loaded with a value used in the baud rate generator. more infor- mation on the baud rate generator is available in section 22.7 ?baud rate generator? . sspsr is the shift register used for shifting data in and out. sspbuf provides indirect access to the sspsr register. sspbuf is the buffer register to which data bytes are written, and from which data bytes are read. in receive operations, sspsr and sspbuf together create a buffered receiver. when sspsr receives a complete byte, it is transferred to sspbuf and the sspif interrupt is set. during transmission, the sspbuf is not buffered. a write to sspbuf will write to both sspbuf and sspsr. 22.3.2 operations when initializing the spi, several options need to be specified. this is done by programming the appropriate control bits (sspcon1<5:0> and sspstat<7:6>). these control bits allow the following to be specified: ? master mode (sck is the clock output) ? slave mode (sck is the clock input) ? clock polarity (idle state of sck) ? data input sample phase (middle or end of data output time) ? clock edge (output data on rising/falling edge of sck) ? clock rate (master mode only) ? slave select mode (slave mode only) the mssp consists of a transmit/receive shift register (sspsr) and a buffer register (sspbuf). the sspsr shifts the data in and out of the device, msb first. the sspbuf holds the data that was written to the sspsr until the received data is ready. once the 8 bits of data have been received, that byte is moved to the sspbuf register. then, the buffer full detect bit, bf of the sspstat register, and the interrupt flag bit, sspif, are set. this double-buffering of the received data (sspbuf) allows the next byte to start reception before reading the data that was just received. any write to the sspbuf register during transmission/reception of data will be ignored and the write collision detect bit wcol of the sspcon1 register, will be set. user software must clear the wcol bit to allow the following write(s) to the sspbuf register to complete successfully. when the application software is expecting to receive valid data, the sspbuf should be read before the next byte of data to transfer is written to the sspbuf. the buffer full bit, bf of the sspstat register, indicates when sspbuf has been loaded with the received data (transmission is complete). when the sspbuf is read, the bf bit is cleared. this data may be irrelevant if the spi is only a transmitter. generally, the mssp interrupt is used to determine when the transmission/reception has completed. if the interrupt method is not going to be used, then software polling can be done to ensure that a write collision does not occur. the sspsr is not directly readable or writable and can only be accessed by addressing the sspbuf register. additionally, the sspstat register indicates the various status conditions.
pic16f193x/lf193x ds41364c-page 284 preliminary ? 2009 microchip technology inc. 22.3.3 enabling spi i/o to enable the serial port, ssp enable bit, sspen of the sspcon1 register, must be set. to reset or reconfig- ure spi mode, clear the sspen bit, re-initialize the sspconx registers and then set the sspen bit. this configures the sdi, sdo, sck and ss pins as serial port pins. for the pins to behave as the serial port func- tion, some must have their data direction bits (in the tris register) appropriately programmed as follows: ? sdi must have corresponding tris bit set ? sdo must have corresponding tris bit cleared ? sck (master mode) must have corresponding tris bit cleared ? sck (slave mode) must have corresponding tris bit set ?ss must have corresponding tris bit set any serial port function that is not desired may be overridden by programming the corresponding data direction (tris) register to the opposite value. 22.3.4 typical connection figure 22-4 shows a typical connection between two microcontrollers. the master controller (processor 1) initiates the data transfer by sending the sck signal. data is shifted out of both shift registers on their pro- grammed clock edge and latched on the opposite edge of the clock. both processors should be programmed to the same clock polarity (ckp), then both controllers would send and receive data at the same time. whether the data is meaningful (or dummy data) depends on the application software. this leads to three scenarios for data transmission: ? master sends data (slave sends dummy data) ? master sends data (slave sends data) ? master sends dummy data (slave sends data) figure 22-4: spi master /slave connection serial input buffer (sspbuf) shift register (sspsr) msb lsb sdo sdi processor 1 sck spi master sspm<3:0> = 00xx serial input buffer (sspbuf) shift register (sspsr) lsb msb sdi sdo processor 2 sck spi slave sspm<3:0> = 010x serial clock ss slave select general i/o (optional) = 1010
? 2009 microchip technology inc. preliminary ds41364c-page 285 pic16f193x/lf193x 22.3.5 master mode the master can initiate the data transfer at any time because it controls the sck. the master determines when the slave (processor 2, figure 22-4) is to broadcast data by the software protocol. in master mode, the data is transmitted/received as soon as the sspbuf register is written to. if the spi is only going to receive, the sdo output could be dis- abled (programmed as an input). the sspsr register will continue to shift in the signal present on the sdi pin at the programmed clock rate. as each byte is received, it will be loaded into the sspbuf register as if a normal received byte (interrupts and status bits appropriately set). the clock polarity is selected by appropriately programming the ckp bit of the sspcon1 register and the cke bit of the sspstat register. this then, would give waveforms for spi communication as shown in figure 22-5, figure 22-6 and figure 22-7, where the msb is transmitted first. in master mode, the spi clock rate (bit rate) is user programmable to be one of the following: ?f osc /4 (or t cy ) ?f osc /16 (or 4 * t cy ) ?f osc /64 (or 16 * t cy ) ? timer2 output/2 ? fosc/(4 * (sspadd + 1)) figure 22-5 shows the waveforms for master mode. when the cke bit is set, the sdo data is valid before there is a clock edge on sck. the change of the input sample is shown based on the state of the smp bit. the time when the sspbuf is loaded with the received data is shown. figure 22-5: spi mode waveform (master mode) sck (ckp = 0 sck (ckp = 1 sck (ckp = 0 sck (ckp = 1 4 clock modes input sample input sample sdi bit 7 bit 0 sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 bit 7 sdi sspif (smp = 1 ) (smp = 0 ) (smp = 1 ) cke = 1 ) cke = 0 ) cke = 1 ) cke = 0 ) (smp = 0 ) write to sspbuf sspsr to sspbuf sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 (cke = 0 ) (cke = 1 ) bit 0
pic16f193x/lf193x ds41364c-page 286 preliminary ? 2009 microchip technology inc. 22.3.6 slave mode in slave mode, the data is transmitted and received as external clock pulses appear on sck. when the last bit is latched, the sspif interrupt flag bit is set. before enabling the module in spi slave mode, the clock line must match the proper idle state. the clock line can be observed by reading the sck pin. the idle state is determined by the ckp bit of the sspcon1 register. while in slave mode, the external clock is supplied by the external clock source on the sck pin. this external clock must meet the minimum high and low times as specified in the electrical specifications. while in sleep mode, the slave can transmit/receive data. the shift register is clocked from the sck pin input and when a byte is received, the device will gen- erate an interrupt. if enabled, the device will wake-up from sleep. 22.3.6.1 buffer overwrite enable in spi daisy-chained configurations only the most recent byte on the bus is required by the slave. setting the boen bit of the sspcon 3 register will enable writes to the sspbuf register, even if the previous byte has not been read. allowing the software to ignore data that may not apply to it. 22.3.7 slave select synchronization the ss pin allows a synchronous slave mode. the spi must be in slave mode with ss pin control enabled (sspcon1<3:0> = 0100 ). when the ss pin is low, transmission and reception are enabled and the sdo pin is driven. when the ss pin goes high, the sdo pin is no longer driven, even if in the middle of a transmitted byte and becomes a floating output. external pull-up/pull-down resistors may be desirable depending on the applica- tion. when the spi module resets, the bit counter is forced to ? 0 ?. this can be done by either forcing the ss pin to a high level or clearing the sspen bit. figure 22-6: slave select syncronization waveform note 1: when the spi is in slave mode with ss pin control enabled (sspcon1<3:0> = 0100 ), the spi module will reset if the ss pin is set to v dd . 2: when the spi is used in slave mode with cke set; the user must enable ss pin control. 3: while operated in spi slave mode the smp bit of the sspstat register must remain clear. sck (ckp = 1 sck (ckp = 0 input sample sdi bit 7 sdo bit 7 bit 6 bit 7 sspif interrupt cke = 0 ) cke = 0 ) write to sspbuf sspsr to sspbuf ss flag bit 0 bit 7 bit 0 bit 6 sspbuf to sspsr shift register sspsr and bit count are reset
? 2009 microchip technology inc. preliminary ds41364c-page 287 pic16f193x/lf193x figure 22-7: spi mode waveform (slave mode with cke = 0 ) figure 22-8: spi mode waveform (slave mode with cke = 1 ) sck (ckp = 1 sck (ckp = 0 input sample sdi bit 7 sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sspif interrupt cke = 0 ) cke = 0 ) write to sspbuf sspsr to sspbuf ss flag optional bit 0 detection active write collision valid sck (ckp = 1 sck (ckp = 0 input sample sdi bit 7 bit 0 sdo bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 sspif interrupt cke = 1 ) cke = 1 ) write to sspbuf sspsr to sspbuf ss flag not optional write collision detection active valid
pic16f193x/lf193x ds41364c-page 288 preliminary ? 2009 microchip technology inc. 22.3.8 operation in power-managed modes in spi master mode, module clocks may be operating at a different speed than when in full power mode; in the case of the sleep mode, all clocks are halted. special care must be taken by the user when the mssp clock is much faster than the system clock. when mssp interrupts are enabled, after the master completes sending data, an mssp interrupt will wake the controller: ? from sleep, in slave mode ? from idle, in slave or master mode if an exit from sleep or idle mode is not desired, mssp interrupts should be disabled. in spi master mode, when the sleep mode is selected, all module clocks are halted and the transmis- sion/reception will remain in that state until the device wakes. after the device returns to run mode, the mod- ule will resume transmitting and receiving data. in spi slave mode, the spi transmit/receive shift register operates asynchronously to the device. this allows the device to be placed in any power-managed mode and data to be shifted into the spi transmit/receive shift register. when all 8 bits have been received, the mssp interrupt flag bit will be set and if enabled, will wake the device. table 22-1: registers associat ed with spi operation name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page apfcon ? ccp3sel t1gsel p2bsel srnqsel c2outsel sssel ccp2sel 86 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 sspbuf synchronous serial port receive buffer/transmit register 283* sspcon1 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 279 sspcon3 acktim pcie scie boen sdaht sbcde ahen dhen 281 sspstat smp cke d/a p s r/w ua bf 278 trisa trisa7 trisa6 trisa5 trisa4 trisa3 trisa2 trisa1 trisa0 88 trisc trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 96 legend: shaded cells are not used by the mssp in spi mode. * page provides register information.
? 2009 microchip technology inc. preliminary ds41364c-page 289 pic16f193x/lf193x 22.4 i 2 c mode all mssp i 2 c communication is byte oriented and shifted out msb first. six sfr registers and 2 interrupt flags interface the module with the pic ? microcon- troller and user software. two pins, sda and scl, are exercised by the module to communicate with other external i 2 c devices. 22.4.1 sda and scl pins selection of any i 2 c mode with the sspen bit set, forces the scl and sda pins to be open-drain. these pins should be set by the user to inputs by setting the appropriate tris bits. 22.4.2 byte format all communication in i 2 c is done in 9-bit segments. a byte is sent from a master to a slave or vice-versa, fol- lowed by an acknowledge bit sent back. after the 8th falling edge of the scl line, the device outputting data on the sda changes that pin to an input and reads in an acknowledge value on the next clock pulse. the clock signal, scl, is provided by the master. data is valid to change while the scl signal is low, and sampled on the rising edge of the clock. changes on the sda line while the scl line is high define special conditions on the bus, explained below. 22.4.3 definition of i 2 c terminology there is language and terminology in the description of i 2 c communication that have definitions specific to i 2 c. that word usage is defined below and may be used in the rest of this document without explana- tion. this table was adapted from the phillips i 2 c specification. table 22-2: i 2 c bus terms note: data is tied to output zero when an i 2 c mode is enabled. term description transmitter the device which shifts data out onto the bus. receiver the device which shifts data in from the bus. master the device that initiates a transfer, generates clock signals and termi- nates a transfer. slave the device addressed by the mas- ter. multi-master a bus with more than one device that can initiate data transfers. arbitration procedure to ensure that only one master at a time controls the bus. winning arbitration ensures that the message is not corrupted. synchronization procedure to synchronize the clocks of two or more devices on the bus. idle no master is controlling the bus, and both sda and scl lines are high. active any time one or more master devices are controlling the bus. addressed slave slave device that has received a matching address and is actively being clocked by a master. matching address address byte that is clocked into a slave that matches the value stored in sspadd. write request slave receives a matching address with r/w bit clear, and is ready to clock in data. read request master sends an address byte with the r/w bit set, indicating that it wishes to clock data out of the slave. this data is the next and all following bytes until a restart or stop. clock stretching when a device on the bus hold scl low to stall communication. bus collision any time the sda line is sampled low by the module while it is out- putting and expected high state.
pic16f193x/lf193x ds41364c-page 290 preliminary ? 2009 microchip technology inc. 22.4.4 start condition the i 2 c specification defines a start condition as a transition of sda from a high to a low state while scl line is high. a start condition is always generated by the master and signifies the transition of the bus from an idle to an active state. figure 22-8 shows wave forms for start and stop conditions. a bus collision can occur on a start condition if the module samples the sda line low before asserting it low. this does not conform to the i 2 c specification that states no bus collision can occur on a start. 22.4.5 stop condition a stop condition is a transition of the sda line from low to high state while the scl line is high. 22.4.6 restart condition a restart is valid any time that a stop would be valid. a master can issue a restart if it wishes to hold the bus after terminating the current transfer. a restart has the same effect on the slave that a start would, resetting all slave logic and preparing it to clock in an address. the master may want to address the same or another slave. in 10-bit addressing slave mode a restart is required for the master to clock data out of the addressed slave. once a slave has been fully address, matching both high and low address bytes, the master can issue a restart and the high address byte with the r/w bit set. the slave logic will then hold the clock and pre- pare to clock out data. after a full match with r/w clear in 10-bit mode, a prior match flag is set and maintained. until a stop condi- tion, a high address with r/w clear, or high address match fails. 22.4.7 start/stop condition interrupt masking the scie and pcie bits of the sspcon3 register can enable the generation of an interrupt in slave mode. slave modes where interrupt on start and stop detect are already enabled, these bits will have no effect. figure 22-9: i 2 c start and stop conditions note: the philips i 2 c specification states that a bus collision cannot occur on a start, and should occur during the address sequence. note: at least one scl low time must appear before a stop is valid, therefore, if the sda line goes low then high again while the scl line stays high, only the start condition is detected. sda scl p stop condition s start condition change of data allowed change of data allowed
? 2009 microchip technology inc. preliminary ds41364c-page 291 pic16f193x/lf193x figure 22-10: i 2 c restart condition restart condition sr change of data allowed change of data allowed
pic16f193x/lf193x ds41364c-page 292 preliminary ? 2009 microchip technology inc. 22.4.8 acknowledge sequence the 9th scl pulse for any transferred byte in i 2 c is dedicated as an acknowledge. it allows receiving devices to respond back to the transmitter by pulling the sda line low. the transmitter must release control of the line during this time to shift in the response. the acknowledge (ack ) is an active-low signal, pulling the sda line low indicated to the transmitter that the device has received the transmitted data and is ready to receive more. the result of an ack is placed in the ackstat bit of the sspcon2 register. slave software, when the ahen and dhen bits are set, allow the user to set the ack value sent back to the transmitter. the ackdt bit of the sspcon2 regis- ter is set/cleared to determine the response. slave hardware will generate an ack response if the ahen and dhen bits of the sspcon3 register are clear. there are certain conditions where an ack will not be sent by the slave. if the bf bit of the sspstat register or the sspov bit of the sspcon1 register are set when a byte is received. 22.5 i 2 c slave mode operation the mssp slave mode operates in one of four modes selected in the sspm bits of sspcon1 register. the modes can be divided into 7-bit and 10-bit addressing mode. 10-bit addressing modes operate the same as 7-bit with some additional overhead for handling the larger addresses. modes with start and stop bit interrupts operated the same as the other modes with sspif additionally get- ting set upon detection of a start, restart, or stop condition. 22.5.1 slave mode addresses the sspadd register (register 22-6) contains the slave mode address. the first byte received after a start or restart condition is compared against the value stored in this register. if the byte matches the value is loaded into the sspbuf register and an inter- rupt is generated. if the value does not match, the module goes idle and no indication is given to the soft- ware that anything happened. the ssp mask register (register 22-5) affects the address matching process. see section 22.5.9 ?ssp mask register? for more information. 22.5.1.1 i 2 c slave 7-bit addressing mode in 7-bit addressing mode, the lsb of the received data byte is ignored when determining if there is an address match. 22.5.1.2 i 2 c slave 10-bit addressing mode in 10-bit addressing mode, the first received byte is compared to the binary value of ?1 1 1 1 0 a9 a8 0?. a9 and a8 are the two msb of the 10-bit address and stored in bits 2 and 1 of the sspadd register. after the acknowledge of the high byte the ua bit is set and scl is held low until the user updates sspadd with the low address. the low address byte is clocked in and all 8 bits are compared to the low address value in sspadd. even if there is not an address match; sspif and ua are set, and scl is held low until sspadd is updated to receive a high byte again. when sspadd is updated the ua bit is cleared. this ensures the module is ready to receive the high address byte on the next communication. a high and low address match as a write request is required at the start of all 10-bit addressing communi- cation. a transmission can be initiated by issuing a restart once the slave is addressed, and clocking in the high address with the r/w bit set. the slave hard- ware will then acknowledge the read request and pre- pare to clock out data. this is only valid for a slave after it has received a complete high and low address byte match.
? 2009 microchip technology inc. preliminary ds41364c-page 293 pic16f193x/lf193x 22.5.2 slave reception when the r/w bit of a matching received address byte is clear, the r/w bit of the sspstat register is cleared. the received address is loaded into the sspbuf reg- ister and acknowledged. when the overflow condition exists for a received address, then not acknowledge is given. an overflow condition is defined as either bit bf bit of the sspstat register is set, or bit sspov bit of the sspcon1 reg- ister is set. the boen bit of the sspcon3 register modifies this operation. for more information see register 22-4. an mssp interrupt is generated for each transferred data byte. flag bit, sspif, must be cleared by software. when the sen bit of the sspcon2 register is set, scl will be held low (clock stretch) following each received byte. the clock must be released by setting the ckp bit of the sspcon1 register, except sometimes in 10-bit mode. see section 22.3.5 ?master mode? for more detail. 22.5.2.1 7-bit addressing reception this section describes a standard sequence of events for the mssp module configured as an i 2 c slave in 7-bit addressing mode. all decisions made by hard- ware or software and their effect on reception. figure 22-10 and figure 22-11 is used as a visual reference for this description. this is a step by step process of what typically must be done to accomplish i 2 c communication. 1. start bit detected. 2. s bit of sspstat is set; sspif is set if interrupt on start detect is enabled. 3. matching address with r/w bit clear is received. 4. the slave pulls sda low sending an ack to the master, and sets sspif bit. 5. software clears the sspif bit. 6. software reads received address from sspbuf clearing the bf flag. 7. if sen = 1 ; slave software sets ckp bit to release the scl line. 8. the master clocks out a data byte. 9. slave drives sda low sending an ack to the master, and sets sspif bit. 10. software clears sspif. 11. software reads the received byte from sspbuf clearing bf. 12. steps 8-12 are repeated for all received bytes from the master. 13. master sends stop condition, setting p bit of sspstat, and the bus goes idle. 22.5.2.2 7-bit reception with ahen and dhen slave device reception with ahen and dhen set operate the same as without these options with extra interrupts and clock stretching added after the 8th fall- ing edge of scl. these additional interrupts allow the slave software to decide whether it wants to ack the receive address or data byte, rather than the hard- ware. this functionality adds support for pmbus? that was not present on previous versions of this module. this list describes the steps that need to be taken by slave software to use these options for i 2 c commun- cation. figure 22-12 displays a module using both address and data holding. figure 22-13 includes the operation with the sen bit of the sspcon2 register set. 1. s bit of sspstat is set; sspif is set if interrupt on start detect is enabled. 2. matching address with r/w bit clear is clocked in. sspif is set and ckp cleared after the 8th falling edge of scl. 3. slave clears the sspif. 4. slave can look at the acktim bit of the sspcon3 register to determine if the sspif was after or before the ack. 5. slave reads the address value from sspbuf, clearing the bf flag. 6. slave sets ack value clocked out to the master by setting ackdt. 7. slave releases the clock by setting ckp. 8. sspif is set after an ack , not after a nack. 9. if sen = 1 the slave hardware will stretch the clock after the ack. 10. slave clears sspif. 11. sspif set and ckp cleared after 8th falling edge of scl for a received data byte. 12. slave looks at acktim bit of sspcon3 to determine the source of the interrupt. 13. slave reads the received data from sspbuf clearing bf. 14. steps 7-14 are the same for each received data byte. 15. communication is ended by either the slave sending an ack = 1 , or the master sending a stop condition. if a stop is sent and interrupt on stop detect is disabled, the slave will only know by polling the p bit of the sststat register. note: sspif is still set after the 9th falling edge of scl even if there is no clock stretching and bf has been cleared. only if nack is sent to master is sspif not set
pic16f193x/lf193x ds41364c-page 294 preliminary ? 2009 microchip technology inc. figure 22-11: i 2 c slave, 7-bit address, reception (sen = 0 , ahen = 0 , dhen = 0 ) receiving address ack receiving data ack receiving data ack = 1 a7 a6 a5 a4 a3 a2 a1 d7 d6 d5 d4 d3 d2 d1 d0 d7 d6 d5 d4 d3 d2 d1 d0 sda scl sspif bf sspov 12345678 12345678 12345678 9 9 9 ack is not sent. sspov set because sspbuf is still full. cleared by software first byte of data is available in sspbuf sspbuf is read sspif set on 9th falling edge of scl cleared by software p bus master sends stop condition s from slave to master
? 2009 microchip technology inc. preliminary ds41364c-page 295 pic16f193x/lf193x figure 22-12: i 2 c slave, 7-bit address, reception (sen = 1 , ahen = 0 , dhen = 0 ) sen sen a7 a6 a5 a4 a3 a2 a1 d7 d6 d5 d4 d3 d2 d1 d0 d7 d6 d5 d4 d3 d2 d1 d0 sda scl 123456789 123456789 123456789 p sspif set on 9th scl is not held ckp is written to 1 in software, ckp is written to ? 1 ? in software, ack low because falling edge of scl releasing scl ack is not sent. bus master sends ckp sspov bf sspif sspov set because sspbuf is still full. cleared by software first byte of data is available in sspbuf ack = 1 cleared by software sspbuf is read clock is held low until ckp is set to ? 1 ? releasing scl stop condition s ack ack receive address receive data receive data r/w= 0
pic16f193x/lf193x ds41364c-page 296 preliminary ? 2009 microchip technology inc. figure 22-13: i 2 c slave, 7-bit address, reception (sen = 0 , ahen = 1 , dhen = 1 ) receiving address receiving data received data p a7 a6 a5 a4 a3 a2 a1 d7 d6 d5 d4 d3 d2 d1 d0 d7 d6 d5 d4 d3 d2 d1 d0 sda scl bf ckp s p 12 3 4 56 7 8 9 12345678 9 12345678 master sends stop condition s data is read from sspbuf cleared by software sspif is set on 9th falling edge of scl, after ack ckp set by software, scl is released slave software 9 acktim cleared by hardware in 9th rising edge of scl sets ackdt to not ack when dhen=1: ckp is cleared by hardware on 8th falling edge of scl slave software clears ackdt to ack the received byte acktim set by hardware on 8th falling edge of scl when ahen=1: ckp is cleared by hardware and scl is stretched address is read from ssbuf acktim set by hardware on 8th falling edge of scl ack master releases sda to slave for ack sequence no interrupt after not ack from slave ack =1 ack ackdt acktim sspif if ahen = 1 : sspif is set
? 2009 microchip technology inc. preliminary ds41364c-page 297 pic16f193x/lf193x figure 22-14: i 2 c slave, 7-bit address, reception (sen = 1 , ahen = 1 , dhen = 1 ) receiving address receive data receive data a7 a6 a5 a4 a3 a2 a1 d7 d6 d5 d4 d3 d2 d1 d0 d7 d6 d5 d4 d3 d2 d1 d0 sda scl sspif bf ackdt ckp s p ack s 12 34 5678 9 12 3 4567 8 9 12 345 67 8 9 ack ack cleared by software acktim is cleared by hardware sspbuf can be set by software, read any time before next byte is loaded release scl on 9th rising edge of scl received address is loaded into sspbuf slave software clears ackdt to ack r/w = 0 master releases sda to slave for ack sequence the received byte when ahen = 1 ; on the 8th falling edge of scl of an address byte, ckp is cleared acktim is set by hardware on 8th falling edge of scl when dhen = 1 ; on the 8th falling edge of scl of a received data byte, ckp is cleared received data is available on sspbuf slave sends not ack ckp is not cleared if not ack p master sends stop condition no interrupt after if not ack from slave acktim
pic16f193x/lf193x ds41364c-page 298 preliminary ? 2009 microchip technology inc. 22.5.3 slave transmission when the r/w bit of the incoming address byte is set and an address match occurs, the r/w bit of the sspstat register is set. the received address is loaded into the sspbuf register, and an ack pulse is sent by the slave on the ninth bit. following the ack , slave hardware clears the ckp bit and the scl pin is held low (see section 22.5.6 ?clock stretching? for more detail). by stretching the clock, the master will be unable to assert another clock pulse until the slave is done preparing the transmit data. the transmit data must be loaded into the sspbuf register which also loads the sspsr register. then the scl pin should be released by setting the ckp bit of the sspcon1 register. the eight data bits are shifted out on the falling edge of the scl input. this ensures that the sda signal is valid during the scl high time. the ack pulse from the master-receiver is latched on the rising edge of the ninth scl input pulse. this ack value is copied to the ackstat bit of the sspcon2 register. if ackstat is set (not ack ), then the data transfer is complete. in this case, when the not ack is latched by the slave, the slave goes idle and waits for another occurrence of the start bit. if the sda line was low (ack ), the next transmit data must be loaded into the sspbuf register. again, the scl pin must be released by setting bit ckp. an mssp interrupt is generated for each data transfer byte. the sspif bit must be cleared by software and the sspstat register is used to determine the status of the byte. the sspif bit is set on the falling edge of the ninth clock pulse. 22.5.3.1 7-bit transmission a master device can transmit a read request to a slave, and then clock data out of the slave. the list below outlines what software for a slave will need to do to accomplish a standard transmission. figure 22-14 can be used as a reference to this list. 1. master sends a start condition on sda and scl. 2. s bit of sspstat is set; sspif is set if interrupt on start detect is enabled. 3. matching address with r/w bit set is received by the slave setting sspif bit. 4. slave hardware generates an ack and sets sspif. 5. sspif bit is cleared by user. 6. software reads the received address from ssp- buf, clearing bf. 7. r/w is set so ckp was automatically cleared after the ack. 8. the slave software loads the transmit data into sspbuf. 9. ckp bit is set releasing scl, allowing the mas- ter to clock the data out of the slave. 10. sspif is set after the ack response from the master is loaded into the ackstat register. 11. sspif bit is cleared. 12. the slave software checks the ackstat bit to see if the master wants to clock out more data. 13. steps 9-13 are repeated for each transmitted byte. 14. if the master sends a not ack ; the clock is not held, but sspif is still set. 15. the master sends a restart condition or a stop. 16. the slave is no longer addressed. note 1: if the master ack s the clock will be stretched. 2: ackstat is the only bit updated on the rising edge of scl (9th) rather than the falling.
? 2009 microchip technology inc. preliminary ds41364c-page 299 pic16f193x/lf193x figure 22-15: i 2 c slave, 7-bit address, transmission (ahen = 0 ) receiving address automatic transmitting data automatic transmitting data a7 a6 a5 a4 a3 a2 a1 d7 d6 d5 d4 d3 d2 d1 d0 d7 d6 d5 d4 d3 d2 d1 d0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 sda scl sspif bf ckp ackstat r/w d/a s p received address when r/w is set r/w is copied from the indicates an address is read from sspbuf scl is always held low after 9th scl falling edge matching address byte has been received masters not ack is copied to ackstat ckp is not held for not ack bf is automatically cleared after 8th falling edge of scl data to transmit is loaded into sspbuf set by software cleared by software ack ack ack r/w = 1 s p master sends stop condition
pic16f193x/lf193x ds41364c-page 300 preliminary ? 2009 microchip technology inc. 22.5.3.2 7-bit transmission with address hold enabled setting the ahen bit of the sspcon3 register enables additional clock stretching and interrupt gen- eration after the 8th falling edge of a received match- ing address. once a matching address has been clocked in, ckp is cleared and the sspif interrupt is set. figure 22-15 displays a standard waveform of a 7-bit address slave transmission with ahen enabled. 1. bus starts idle. 2. master sends start condition; the s bit of sspstat is set; sspif is set if interrupt on start detect is enabled. 3. master sends matching address with r/w bit set. after the 8th falling edge of the scl line the ckp bit is cleared and sspif interrupt is gener- ated. 4. slave software clears sspif. 5. slave software reads acktim bit of sspcon3 register, and r/w and d/a of the sspstat reg- ister to determine the source of the interrupt. 6. slave reads the address value from the sspbuf register clearing the bf bit. 7. slave software decides from this information if it wishes to ack or not ack and sets ackdt bit of the sspcon2 register accordingly. 8. slave sets the ckp bit releasing scl. 9. master clocks in the ack value from the slave. 10. slave hardware automatically clears the ckp bit and sets sspif after the ack if the r/w bit is set. 11. slave software clears sspif. 12. slave loads value to transmit to the master into sspbuf setting the bf bit. 13. slave sets ckp bit releasing the clock. 14. master clocks out the data from the slave and sends an ack value on the 9th scl pulse. 15. slave hardware copies the ack value into the ackstat bit of the sspcon2 register. 16. steps 10-15 are repeated for each byte transmit- ted to the master from the slave. 17. if the master sends a not ack the slave releases the bus allowing the master to send a stop and end the communication. note: sspbuf cannot be loaded until after the ack. note: master must send a not ack on the last byte to ensure that the slave releases the scl line to receive a stop.
? 2009 microchip technology inc. preliminary ds41364c-page 301 pic16f193x/lf193x figure 22-16: i 2 c slave, 7-bit address, transmission (ahen = 1 ) receiving address automatic transmitting data automatic transmitting data a7 a6 a5 a4 a3 a2 a1 d7 d6 d5 d4 d3 d2 d1 d0 d7 d6 d5 d4 d3 d2 d1 d0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 sda scl sspif bf ackdt ackstat ckp r/w d/a received address is read from sspbuf bf is automatically cleared after 8th falling edge of scl data to transmit is loaded into sspbuf cleared by software slave clears ackdt to ack address master?s ack response is copied to sspstat ckp not cleared after not ack set by software, releases scl acktim is cleared on 9th rising edge of scl acktim is set on 8th falling edge of scl when ahen = 1 ; ckp is cleared by hardware after receiving matching address. when r/w = 1 ; ckp is always cleared after ack s p master sends stop condition ack r/w = 1 master releases sda to slave for ack sequence ack ack acktim
pic16f193x/lf193x ds41364c-page 302 preliminary ? 2009 microchip technology inc. 22.5.4 slave mode 10-bit address reception this section describes a standard sequence of events for the mssp module configured as an i 2 c slave in 10-bit addressing mode. figure 22-16 and is used as a visual reference for this description. this is a step by step process of what must be done by slave software to accomplish i 2 c communication. 1. bus starts idle. 2. master sends start condition; s bit of sspstat is set; sspif is set if interrupt on start detect is enabled. 3. master sends matching high address with r/w bit clear; ua bit of the sspstat register is set. 4. slave sends ack and sspif is set. 5. software clears the sspif bit. 6. software reads received address from sspbuf clearing the bf flag. 7. slave loads low address into sspadd, releasing scl. 8. master sends matching low address byte to the slave; ua bit is set. 9. slave sends ack and sspif is set. 10. slave clears sspif. 11. slave reads the received matching address from sspbuf clearing bf. 12. slave loads high address into sspadd. 13. master clocks a data byte to the slave and clocks out the slaves ack on the 9th scl pulse; sspif is set. 14. if sen bit of sspcon2 is set, ckp is cleared by hardware and the clock is stretched. 15. slave clears sspif. 16. slave reads the received byte from sspbuf clearing bf. 17. if sen is set the slave sets ckp to release the scl. 18. steps 13-17 repeat for each received byte. 19. master sends stop to end the transmission. 22.5.5 10-bit addressing with address or data hold reception using 10-bit addressing with ahen or dhen set is the same as with 7-bit modes. the only difference is the need to update the sspadd register using the ua bit. all functionality, specifically when the ckp bit is cleared and scl line is held low are the same. figure 22-17 can be used as a reference of a slave in 10-bit addressing with ahen set. figure 22-18 shows a standard waveform for a slave transmitter in 10-bit addressing mode. note: updates to the sspadd register are not allowed until after the ack sequence. note: if the low address does not match, sspif and ua are still set so that the slave software can set sspadd back to the high address. bf is not set because there is no match. ckp is unaffected.
? 2009 microchip technology inc. preliminary ds41364c-page 303 pic16f193x/lf193x figure 22-17: i 2 c slave, 10-bit address, reception (sen = 1 , ahen = 0 , dhen = 0 ) sspif receive first address byte ack receive second address byte ack receive data ack receive data ack 1 1 1 1 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 d7 d6 d5 d4 d3 d2 d1 d0 d7 d6 d5 d4 d3 d2 d1 d0 sda scl ua ckp 1 2345678 912345678 912345678 9 12345678 9 p master sends stop condition cleared by software receive address is software updates sspadd data is read scl is held low set by software, while ckp = 0 from sspbuf releasing scl when sen = 1 ; ckp is cleared after 9th falling edge of received byte read from sspbuf and releases scl when ua = 1 ; if address matches set by hardware on 9th falling edge sspadd it is loaded into sspbuf scl is held low s bf
pic16f193x/lf193x ds41364c-page 304 preliminary ? 2009 microchip technology inc. figure 22-18: i 2 c slave, 10-bit address, reception (sen = 0 , ahen = 1 , dhen = 0 ) receive first address byte ua receive second address byte ua receive data ack receive data 1 1 1 1 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 d7 d6 d5 d4 d3 d2 d1 d0 d7 d6 d5 sda scl sspif bf ackdt ua ckp acktim 12345678 9 s ack ack 12 345678 9 12345678 91 2 sspbuf is read from received data sspbuf can be read anytime before the next received byte cleared by software falling edge of scl not allowed until 9th update to sspadd is set ckp with software releases scl scl clears ua and releases update of sspadd, set by hardware on 9th falling edge slave software clears ackdt to ack the received byte if when ahen = 1 ; on the 8th falling edge of scl of an address byte, ckp is cleared acktim is set by hardware on 8th falling edge of scl cleared by software r/w = 0
? 2009 microchip technology inc. preliminary ds41364c-page 305 pic16f193x/lf193x figure 22-19: i 2 c slave, 10-bit address, transmission (sen = 0 , ahen = 0 , dhen = 0 ) receiving address ack receiving second address byte sr receive first address byte ack transmitting data byte 1 1 1 1 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 1 1 1 1 0 a9 a8 d7 d6 d5 d4 d3 d2 d1 d0 sda scl sspif bf ua ckp r/w d/a 1 2345 6789 1 2345 6789 1 23 4 5 6789 1 23456 789 ack = 1 p master sends stop condition master sends not ack master sends restart event ack r/w = 0 s cleared by software after sspadd is updated, ua is cleared and scl is released high address is loaded received address is data to transmit is set by software indicates an address when r/w = 1 ; r/w is copied from the set by hardware ua indicates sspadd sspbuf loaded with received address must be updated has been received loaded into sspbuf releases scl masters not ack is copied matching address byte ckp is cleared on 9th falling edge of scl read from sspbuf back into sspadd ackstat set by hardware
pic16f193x/lf193x ds41364c-page 306 preliminary ? 2009 microchip technology inc. 22.5.6 clock stretching clock stretching occurs when a device on the bus holds the scl line low effectively pausing communica- tion. the slave may stretch the clock to allow more time to handle data or prepare a response for the mas- ter device. a master device is not concerned with stretching as anytime it is active on the bus and not transferring data it is stretching. any stretching done by a slave is invisible to the master software and han- dled by the hardware that generates scl. the ckp bit of the sspcon1 register is used to con- trol stretching in software. any time the ckp bit is cleared, the module will wait for the scl line to go low and then hold it. setting ckp will release scl and allow more communication. 22.5.6.1 normal clock stretching following an ack if the r/w bit of sspstat is set, a read request, the slave hardware will clear ckp. this allows the slave time to update sspbuf with data to transfer to the master. if the sen bit of sspcon2 is set, the slave hardware will always stretch the clock after the ack sequence. once the slave is ready; ckp is set by software and communication resumes. 22.5.6.2 10-bit addressing mode in 10-bit addressing mode, when the ua bit is set the clock is always stretched. this is the only time the scl is stretched without ckp being cleared. scl is releases immediately after a write to sspadd. 22.5.6.3 byte nacking when ahen bit of sspcon3 is set; ckp is cleared by hardware after the 8th falling edge of scl for a received matching address byte. when dhen bit of sspcon3 is set; ckp is cleared after the 8th falling edge of scl for received data. stretching after the 8th falling edge of scl allows the slave to look at the received address or data and decide if it wants to ack the received data. 22.5.7 clock synchronization and the ckp bit any time the ckp bit is cleared, the module will wait for the scl line to go low and then hold it. however, clearing the ckp bit will not assert the scl output low until the scl output is already sampled low. there- fore, the ckp bit will not assert the scl line until an external i 2 c master device has already asserted the scl line. the scl output will remain low until the ckp bit is set and all other devices on the i 2 c bus have released scl. this ensures that a write to the ckp bit will not violate the minimum high time requirement for scl (see figure 22-19). figure 22-20: clock synchronization timing note 1: the bf bit has no effect on if the clock will be stretched or not. this is different than previous versions of the module that would not stretch the clock, clear ckp, if sspbuf was read before the 9th falling edge of scl. 2: previous versions of the module did not stretch the clock for a transmission if sspbuf was loaded before the 9th falling edge of scl. it is now always cleared for read requests. note: previous versions of the module did not stretch the clock if the second address byte did not match. sda scl dx ? ? 1 dx wr q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 sspcon1 ckp master device releases clock master device asserts clock
? 2009 microchip technology inc. preliminary ds41364c-page 307 pic16f193x/lf193x 22.5.8 general call address support the addressing procedure for the i 2 c bus is such that the first byte after the start condition usually deter- mines which device will be the slave addressed by the master device. the exception is the general call address which can address all devices. when this address is used, all devices should, in theory, respond with an acknowledge. the general call address is a reserved address in the i 2 c protocol, defined as address 0x00. when the gcen bit of the sspcon2 register is set, the slave module will automatically ack the reception of this address regardless of the value stored in sspadd. after the slave clocks in an address of all zeros with the r/w bit clear, an interrupt is generated and slave software can read sspbuf and respond. figure 22-20 shows a general call reception sequence. in 10-bit address mode, the ua bit will not be set on the reception of the general call address. the slave will prepare to receive the second byte as data, just as it would in 7-bit mode. if the ahen bit of the sspcon3 register is set, just as with any other address reception, the slave hardware will stretch the clock after the 8th falling edge of scl. the slave must then set its ackdt value and release the clock with communication progressing as it would normally. figure 22-21: slave mode general call address sequence 22.5.9 ssp mask register an ssp mask (sspmsk) register (register 22-5) is available in i 2 c slave mode as a mask for the value held in the sspsr register during an address comparison operation. a zero (? 0 ?) bit in the sspmsk register has the effect of making the corresponding bit of the received address a ?don?t care?. this register is reset to all ? 1 ?s upon any reset condition and, therefore, has no effect on standard ssp operation until written with a mask value. the ssp mask register is active during: ? 7-bit address mode: address compare of a<7:1>. ? 10-bit address mode: address compare of a<7:0> only. the ssp mask has no effect during the reception of the first (high) byte of the address. sda scl s sspif bf (sspstat<0>) cleared by software sspbuf is read r/w = 0 ack general call address address is compared to general call address receiving data ack 123456789123456789 d7 d6 d5 d4 d3 d2 d1 d0 after ack , set interrupt gcen (sspcon2<7>) ?1?
pic16f193x/lf193x ds41364c-page 308 preliminary ? 2009 microchip technology inc. 22.6 i 2 c master mode master mode is enabled by setting and clearing the appropriate sspm bits in the sspcon1 register and by setting the sspen bit. in master mode, the scl and sda lines are set as inputs and are manipulated by the mssp hardware. master mode of operation is supported by interrupt generation on the detection of the start and stop con- ditions. the stop (p) and start (s) bits are cleared from a reset or when the mssp module is disabled. control of the i 2 c bus may be taken when the p bit is set, or the bus is idle. in firmware controlled master mode, user code conducts all i 2 c bus operations based on start and stop bit condition detection. start and stop condition detection is the only active circuitry in this mode. all other communication is done by the user software directly manipulating the sda and scl lines. the following events will cause the ssp interrupt flag bit, sspif, to be set (ssp interrupt, if enabled): ? start condition detected ? stop condition detected ? data transfer byte transmitted/received ? acknowledge transmitted/received ? repeated start generated 22.6.1 i 2 c master mode operation the master device generates all of the serial clock pulses and the start and stop conditions. a transfer is ended with a stop condition or with a repeated start condition. since the repeated start condition is also the beginning of the next serial transfer, the i 2 c bus will not be released. in master transmitter mode, serial data is output through sda, while scl outputs the serial clock. the first byte transmitted contains the slave address of the receiving device (7 bits) and the read/write (r/w ) bit. in this case, the r/w bit will be logic ? 0 ?. serial data is transmitted 8 bits at a time. after each byte is transmit- ted, an acknowledge bit is received. start and stop conditions are output to indicate the beginning and the end of a serial transfer. in master receive mode, the first byte transmitted con- tains the slave address of the transmitting device (7 bits) and the r/w bit. in this case, the r/w bit will be logic ? 1 ?. thus, the first byte transmitted is a 7-bit slave address followed by a ? 1 ? to indicate the receive bit. serial data is received via sda, while scl outputs the serial clock. serial data is received 8 bits at a time. after each byte is received, an acknowledge bit is transmit- ted. start and stop conditions indicate the beginning and end of transmission. a baud rate generator is used to set the clock fre- quency output on scl. see section 22.7 ?baud rate generator? for more detail. note 1: the mssp module, when configured in i 2 c master mode, does not allow queue- ing of events. for instance, the user is not allowed to initiate a start condition and immediately write the sspbuf register to initiate transmission before the start con- dition is complete. in this case, the sspbuf will not be written to and the wcol bit will be set, indicating that a write to the sspbuf did not occur 2: when in master mode, start/stop detec- tion is masked and an interrupt is gener- ated when the sen/pen bit is cleared and the generation is complete.
? 2009 microchip technology inc. preliminary ds41364c-page 309 pic16f193x/lf193x 22.6.2 clock arbitration clock arbitration occurs when the master, during any receive, transmit or repeated start/stop condition, releases the scl pin (scl allowed to float high). when the scl pin is allowed to float high, the baud rate gen- erator (brg) is suspended from counting until the scl pin is actually sampled high. when the scl pin is sam- pled high, the baud rate generator is reloaded with the contents of sspadd<7:0> and begins counting. this ensures that the scl high time will always be at least one brg rollover count in the event that the clock is held low by an external device (figure 22-22). figure 22-22: baud rate generator timing with clock arbitration 22.6.3 wcol status flag if the user writes the sspbuf when a start, restart, stop, receive or transmit sequence is in progress, the wcol is set and the contents of the buffer are unchanged (the write doesn?t occur). any time the wcol bit is set it indicates that an action on sspbuf was attempted while the module was not idle. sda scl scl deasserted but slave holds dx ? ? 1 dx brg scl is sampled high, reload takes place and brg starts its count 03h 02h 01h 00h (hold off) 03h 02h reload brg value scl low (clock arbitration) scl allowed to transition high brg decrements on q2 and q4 cycles note: because queueing of events is not allowed, writing to the lower 5 bits of sspcon2 is disabled until the start condition is complete.
pic16f193x/lf193x ds41364c-page 310 preliminary ? 2009 microchip technology inc. 22.6.4 i 2 c master mode start condition timing to initiate a start condition, the user sets the start enable bit, sen bit of the sspcon2 register. if the sda and scl pins are sampled high, the baud rate generator is reloaded with the contents of sspadd<7:0> and starts its count. if scl and sda are both sampled high when the baud rate generator times out (t brg ), the sda pin is driven low. the action of the sda being driven low while scl is high is the start condition and causes the s bit of the sspstat1 register to be set. following this, the baud rate gen- erator is reloaded with the contents of sspadd<7:0> and resumes its count. when the baud rate genera- tor times out (t brg ), the sen bit of the sspcon2 reg- ister will be automatically cleared by hardware; the baud rate generator is suspended, leaving the sda line held low and the start condition is complete. figure 22-23: first start bit timing note 1: if at the beginning of the start condition, the sda and scl pins are already sam- pled low, or if during the start condition, the scl line is sampled low before the sda line is driven low, a bus collision occurs, the bus collision interrupt flag, bclif, is set, the start condition is aborted and the i 2 c module is reset into its idle state. 2: the philips i 2 c specification states that a bus collision cannot occur on a start. sda scl s t brg 1st bit 2nd bit t brg sda = 1 , at completion of start bit, scl = 1 write to sspbuf occurs here t brg hardware clears sen bit t brg write to sen bit occurs here set s bit (sspstat<3>) and sets sspif bit
? 2009 microchip technology inc. preliminary ds41364c-page 311 pic16f193x/lf193x 22.6.5 i 2 c master mode repeated start condition timing a repeated start condition occurs when the rsen bit of the sspcon2 register is programmed high and the master state machine is no longer active. when the rsen bit is set, the scl pin is asserted low. when the scl pin is sampled low, the baud rate generator is loaded and begins counting. the sda pin is released (brought high) for one baud rate generator count (t brg ). when the baud rate generator times out, if sda is sampled high, the scl pin will be deasserted (brought high). when scl is sampled high, the baud rate generator is reloaded and begins counting. sda and scl must be sampled high for one t brg . this action is then followed by assertion of the sda pin (sda = 0 ) for one t brg while scl is high. scl is asserted low. following this, the rsen bit of the sspcon2 register will be automatically cleared and the baud rate generator will not be reloaded, leaving the sda pin held low. as soon as a start condition is detected on the sda and scl pins, the s bit of the sspstat register will be set. the sspif bit will not be set until the baud rate generator has timed out. figure 22-24: repeat start condition waveform note 1: if rsen is programmed while any other event is in progress, it will not take effect. 2: a bus collision during the repeated start condition occurs if: ? sda is sampled low when scl goes from low-to-high. ? scl goes low before sda is asserted low. this may indicate that another master is attempting to transmit a data ? 1 ?. sda scl repeated start write to sspcon2 write to sspbuf occurs here at completion of start bit, hardware clears rsen bit 1st bit s bit set by hardware t brg t brg sda = 1 , sda = 1 , scl (no change) scl = 1 occurs here t brg t brg t brg and sets sspif sr
pic16f193x/lf193x ds41364c-page 312 preliminary ? 2009 microchip technology inc. 22.6.6 i 2 c master mode transmission transmission of a data byte, a 7-bit address or the other half of a 10-bit address is accomplished by simply writing a value to the sspbuf register. this action will set the buffer full flag bit, bf and allow the baud rate generator to begin counting and start the next trans- mission. each bit of address/data will be shifted out onto the sda pin after the falling edge of scl is asserted. scl is held low for one baud rate generator rollover count (t brg ). data should be valid before scl is released high. when the scl pin is released high, it is held that way for t brg . the data on the sda pin must remain stable for that duration and some hold time after the next falling edge of scl. after the eighth bit is shifted out (the falling edge of the eighth clock), the bf flag is cleared and the master releases sda. this allows the slave device being addressed to respond with an ack bit during the ninth bit time if an address match occurred, or if data was received prop- erly. the status of ack is written into the ackstat bit on the rising edge of the ninth clock. if the master receives an acknowledge, the acknowledge status bit, ackstat, is cleared. if not, the bit is set. after the ninth clock, the sspif bit is set and the master clock (baud rate generator) is suspended until the next data byte is loaded into the sspbuf, leaving scl low and sda unchanged (figure 22-24). after the write to the sspbuf, each bit of the address will be shifted out on the falling edge of scl until all seven address bits and the r/w bit are completed. on the falling edge of the eighth clock, the master will release the sda pin, allowing the slave to respond with an acknowledge. on the falling edge of the ninth clock, the master will sample the sda pin to see if the address was recognized by a slave. the status of the ack bit is loaded into the ackstat status bit of the sspcon2 register. following the falling edge of the ninth clock transmission of the address, the sspif is set, the bf flag is cleared and the baud rate generator is turned off until another write to the sspbuf takes place, hold- ing scl low and allowing sda to float. 22.6.6.1 bf status flag in transmit mode, the bf bit of the sspstat register is set when the cpu writes to sspbuf and is cleared when all 8 bits are shifted out. 22.6.6.2 wcol status flag if the user writes the sspbuf when a transmit is already in progress (i.e., sspsr is still shifting out a data byte), the wcol is set and the contents of the buf- fer are unchanged (the write doesn?t occur). wcol must be cleared by software before the next transmission. 22.6.6.3 ackstat status flag in transmit mode, the ackstat bit of the sspcon2 register is cleared when the slave has sent an acknowl- edge (ack = 0 ) and is set when the slave does not acknowledge (ack = 1 ). a slave sends an acknowl- edge when it has recognized its address (including a general call), or when the slave has properly received its data. 22.6.6.4 typical transmit sequence: 1. the user generates a start condition by setting the sen bit of the sspcon2 register. 2. sspif is set by hardware on completion of the start. 3. sspif is cleared by software. 4. the mssp module will wait the required start time before any other operation takes place. 5. the user loads the sspbuf with the slave address to transmit. 6. address is shifted out the sda pin until all 8 bits are transmitted. transmission begins as soon as sspbuf is written to. 7. the mssp module shifts in the ack bit from the slave device and writes its value into the ackstat bit of the sspcon2 register. 8. the mssp module generates an interrupt at the end of the ninth clock cycle by setting the sspif bit. 9. the user loads the sspbuf with eight bits of data. 10. data is shifted out the sda pin until all 8 bits are transmitted. 11. the mssp module shifts in the ack bit from the slave device and writes its value into the ackstat bit of the sspcon2 register. 12. steps 8-11 are repeated for all transmitted data bytes. 13. the user generates a stop or restart condition by setting the pen or rsen bits of the sspcon2 register. interrupt is generated once the stop/restart condition is complete.
? 2009 microchip technology inc. preliminary ds41364c-page 313 pic16f193x/lf193x figure 22-25: i 2 c master mode waveform (transmission, 7 or 10-bit address) sda scl sspif bf (sspstat<0>) sen a7 a6 a5 a4 a3 a2 a1 ack = 0 d7 d6 d5 d4 d3 d2 d1 d0 ack transmitting data or second half r/w = 0 transmit address to slave 123456789 123456789 p cleared by software service routine sspbuf is written by software from ssp interrupt after start condition, sen cleared by hardware s sspbuf written with 7-bit address and r/w start transmit scl held low while cpu responds to sspif sen = 0 of 10-bit address write sspcon2<0> sen = 1 start condition begins from slave, clear ackstat bit sspcon2<6> ackstat in sspcon2 = 1 cleared by software sspbuf written pen r/w cleared by software
pic16f193x/lf193x ds41364c-page 314 preliminary ? 2009 microchip technology inc. 22.6.7 i 2 c master mode reception master mode reception is enabled by programming the receive enable bit, rcen bit of the sspcon2 register. the baud rate generator begins counting and on each rollover, the state of the scl pin changes (high-to-low/low-to-high) and data is shifted into the sspsr. after the falling edge of the eighth clock, the receive enable flag is automatically cleared, the con- tents of the sspsr are loaded into the sspbuf, the bf flag bit is set, the sspif flag bit is set and the baud rate generator is suspended from counting, holding scl low. the mssp is now in idle state awaiting the next command. when the buffer is read by the cpu, the bf flag bit is automatically cleared. the user can then send an acknowledge bit at the end of reception by setting the acknowledge sequence enable, acken bit of the sspcon2 register. 22.6.7.1 bf status flag in receive operation, the bf bit is set when an address or data byte is loaded into sspbuf from sspsr. it is cleared when the sspbuf register is read. 22.6.7.2 sspov status flag in receive operation, the sspov bit is set when 8 bits are received into the sspsr and the bf flag bit is already set from a previous reception. 22.6.7.3 wcol status flag if the user writes the sspbuf when a receive is already in progress (i.e., sspsr is still shifting in a data byte), the wcol bit is set and the contents of the buffer are unchanged (the write doesn?t occur). 22.6.7.4 typical receive sequence: 1. the user generates a start condition by setting the sen bit of the sspcon2 register. 2. sspif is set by hardware on completion of the start. 3. sspif is cleared by software. 4. user writes sspbuf with the slave address to transmit and the r/w bit set. 5. address is shifted out the sda pin until all 8 bits are transmitted. transmission begins as soon as sspbuf is written to. 6. the mssp module shifts in the ack bit from the slave device and writes its value into the ackstat bit of the sspcon2 register. 7. the mssp module generates an interrupt at the end of the ninth clock cycle by setting the sspif bit. 8. user sets the rcen bit of the sspcon2 register and the master clocks in a byte from the slave. 9. after the 8th falling edge of scl, sspif and bf are set. 10. master clears sspif and reads the received byte from sspuf, clears bf. 11. master sets ack value sent to slave in ackdt bit of the sspcon2 register and initiates the ack by setting the acken bit. 12. masters ack is clocked out to the slave and sspif is set. 13. user clears sspif. 14. steps 8-13 are repeated for each received byte from the slave. 15. master sends a not ack or stop to end communication. note: the mssp module must be in an idle state before the rcen bit is set or the rcen bit will be disregarded.
? 2009 microchip technology inc. preliminary ds41364c-page 315 pic16f193x/lf193x figure 22-26: i 2 c master mode waveform (reception, 7-bit address) p 9 8 7 6 5 d0 d1 d2 d3 d4 d5 d6 d7 s a7 a6 a5 a4 a3 a2 a1 sda scl 12 3 4 5 6 7 8 9 12 3 4 5 678 9 1234 bus master terminates transfer ack receiving data from slave receiving data from slave d0 d1 d2 d3 d4 d5 d6 d7 ack r/w = 0 transmit address to slave sspif bf ack is not sent write to sspcon2<0> (sen = 1 ), write to sspbuf occurs here, ack from slave master configured as a receiver by programming sspcon2<3> (rcen = 1 ) pen bit = 1 written here data shifted in on falling edge of clk cleared by software start xmit sen = 0 sspov sda = 0 , scl = 1 while cpu (sspstat<0>) ack cleared by software cleared by software set sspif interrupt at end of receive set p bit (sspstat<4>) and sspif cleared in software ack from master set sspif at end set sspif interrupt at end of acknowledge sequence set sspif interrupt at end of acknow- ledge sequence of receive set acken, start acknowledge sequence sspov is set because sspbuf is still full sda = ackdt = 1 rcen cleared automatically rcen = 1 , start next receive write to sspcon2<4> to start acknowledge sequence sda = ackdt (sspcon2<5>) = 0 rcen cleared automatically responds to sspif acken begin start condition cleared by software sda = ackdt = 0 last bit is shifted into sspsr and contents are unloaded into sspbuf rcen master configured as a receiver by programming sspcon2<3> (rcen = 1 ) rcen cleared automatically ack from master sda = ackdt = 0 rcen cleared automatically
pic16f193x/lf193x ds41364c-page 316 preliminary ? 2009 microchip technology inc. 22.6.8 acknowledge sequence timing an acknowledge sequence is enabled by setting the acknowledge sequence enable bit, acken bit of the sspcon2 register. when this bit is set, the scl pin is pulled low and the contents of the acknowledge data bit are presented on the sda pin. if the user wishes to gen- erate an acknowledge, then the ackdt bit should be cleared. if not, the user should set the ackdt bit before starting an acknowledge sequence. the baud rate generator then counts for one rollover period (t brg ) and the scl pin is deasserted (pulled high). when the scl pin is sampled high (clock arbitration), the baud rate generator counts for t brg . the scl pin is then pulled low. following this, the acken bit is automatically cleared, the baud rate generator is turned off and the mssp module then goes into idle mode (figure 22-26). 22.6.8.1 wcol status flag if the user writes the sspbuf when an acknowledge sequence is in progress, then wcol is set and the contents of the buffer are unchanged (the write doesn?t occur). 22.6.9 stop condition timing a stop bit is asserted on the sda pin at the end of a receive/transmit by setting the stop sequence enable bit, pen bit of the sspcon2 register. at the end of a receive/transmit, the scl line is held low after the falling edge of the ninth clock. when the pen bit is set, the master will assert the sda line low. when the sda line is sampled low, the baud rate generator is reloaded and counts down to ? 0 ?. when the baud rate generator times out, the scl pin will be brought high and one t brg (baud rate generator rollover count) later, the sda pin will be deasserted. when the sda pin is sampled high while scl is high, the p bit of the sspstat register is set. a t brg later, the pen bit is cleared and the sspif bit is set (figure 22-27). 22.6.9.1 wcol status flag if the user writes the sspbuf when a stop sequence is in progress, then the wcol bit is set and the contents of the buffer are unchanged (the write doesn?t occur). figure 22-27: acknowledge sequen ce waveform figure 22-28: stop cond ition receive or transmit mode note: t brg = one baud rate generator period. sda scl sspif set at acknowledge sequence starts here, write to sspcon2 acken automatically cleared cleared in t brg t brg the end of receive 8 acken = 1 , ackdt = 0 d0 9 sspif software sspif set at the end of acknowledge sequence cleared in software ack scl sda sda asserted low before rising edge of clock write to sspcon2, set pen falling edge of scl = 1 for t brg , followed by sda = 1 for t brg 9th clock scl brought high after t brg note: t brg = one baud rate generator period. t brg t brg after sda sampled high. p bit (sspstat<4>) is set. t brg to setup stop condition ack p t brg pen bit (sspcon2<2>) is cleared by hardware and the sspif bit is set
? 2009 microchip technology inc. preliminary ds41364c-page 317 pic16f193x/lf193x 22.6.10 sleep operation while in sleep mode, the i 2 c slave module can receive addresses or data and when an address match or complete byte transfer occurs, wake the processor from sleep (if the mssp interrupt is enabled). 22.6.11 effects of a reset a reset disables the mssp module and terminates the current transfer. 22.6.12 multi-master mode in multi-master mode, the interrupt generation on the detection of the start and stop conditions allows the determination of when the bus is free. the stop (p) and start (s) bits are cleared from a reset or when the mssp module is disabled. control of the i 2 c bus may be taken when the p bit of the sspstat register is set, or the bus is idle, with both the s and p bits clear. when the bus is busy, enabling the ssp interrupt will gener- ate the interrupt when the stop condition occurs. in multi-master operation, the sda line must be monitored for arbitration to see if the signal level is the expected output level. this check is performed by hardware with the result placed in the bclif bit. the states where arbitration can be lost are: ? address transfer ? data transfer ? a start condition ? a repeated start condition ? an acknowledge condition 22.6.13 multi -master communication, bus collision and bus arbitration multi-master mode support is achieved by bus arbitra- tion. when the master outputs address/data bits onto the sda pin, arbitration takes place when the master outputs a ? 1 ? on sda, by letting sda float high and another master asserts a ? 0 ?. when the scl pin floats high, data should be stable. if the expected data on sda is a ? 1 ? and the data sampled on the sda pin is ? 0 ?, then a bus collision has taken place. the master will set the bus collision interrupt flag, bclif and reset the i 2 c port to its idle state (figure 22-28). if a transmit was in progress when the bus collision occurred, the transmission is halted, the bf flag is cleared, the sda and scl lines are deasserted and the sspbuf can be written to. when the user services the bus collision interrupt service routine and if the i 2 c bus is free, the user can resume communication by asserting a start condition. if a start, repeated start, stop or acknowledge condi- tion was in progress when the bus collision occurred, the condition is aborted, the sda and scl lines are deas- serted and the respective control bits in the sspcon2 register are cleared. when the user services the bus col- lision interrupt service routine and if the i 2 c bus is free, the user can resume communication by asserting a start condition. the master will continue to monitor the sda and scl pins. if a stop condition occurs, the sspif bit will be set. a write to the sspbuf will start the transmission of data at the first data bit, regardless of where the transmitter left off when the bus collision occurred. in multi-master mode, the interrupt generation on the detection of start and stop conditions allows the deter- mination of when the bus is free. control of the i 2 c bus can be taken when the p bit is set in the sspstat register, or the bus is idle and the s and p bits are cleared. figure 22-29: bus collision timing for transmit and acknowledge sda scl bclif sda released sda line pulled low by another source sample sda. while scl is high, data doesn?t match what is driven bus collision has occurred. set bus collision interrupt (bclif) by the master. by master data changes while scl = 0
pic16f193x/lf193x ds41364c-page 318 preliminary ? 2009 microchip technology inc. 22.6.13.1 bus collision during a start condition during a start condition, a bus collision occurs if: a) sda or scl are sampled low at the beginning of the start condition (figure 22-29). b) scl is sampled low before sda is asserted low (figure 22-30). during a start condition, both the sda and the scl pins are monitored. if the sda pin is already low, or the scl pin is already low, then all of the following occur: ? the start condition is aborted, ? the bclif flag is set and ? the mssp module is reset to its idle state (figure 22-29). the start condition begins with the sda and scl pins deasserted. when the sda pin is sampled high, the baud rate generator is loaded and counts down. if the scl pin is sampled low while sda is high, a bus colli- sion occurs because it is assumed that another master is attempting to drive a data ? 1 ? during the start condition. if the sda pin is sampled low during this count, the brg is reset and the sda line is asserted early (figure 22-31). if, however, a ? 1 ? is sampled on the sda pin, the sda pin is asserted low at the end of the brg count. the baud rate generator is then reloaded and counts down to zero; if the scl pin is sampled as ? 0 ? during this time, a bus collision does not occur. at the end of the brg count, the scl pin is asserted low. figure 22-30: bus collision during start condition (sda only) note: the reason that bus collision is not a factor during a start condition is that no two bus masters can assert a start condition at the exact same time. therefore, one master will always assert sda before the other. this condition does not cause a bus colli- sion because the two masters must be allowed to arbitrate the first address fol- lowing the start condition. if the address is the same, arbitration must be allowed to continue into the data portion, repeated start or stop conditions. sda scl sen sda sampled low before sda goes low before the sen bit is set. s bit and sspif set because ssp module reset into idle state. sen cleared automatically because of bus collision. s bit and sspif set because set sen, enable start condition if sda = 1 , scl = 1 sda = 0 , scl = 1 . bclif s sspif sda = 0 , scl = 1 . sspif and bclif are cleared by software sspif and bclif are cleared by software set bclif, start condition. set bclif.
? 2009 microchip technology inc. preliminary ds41364c-page 319 pic16f193x/lf193x figure 22-31: bus collision d uring start condition (scl = 0 ) figure 22-32: brg reset due to sda arbitration during start condition sda scl sen bus collision occurs. set bclif. scl = 0 before sda = 0 , set sen, enable start sequence if sda = 1 , scl = 1 t brg t brg sda = 0 , scl = 1 bclif s sspif interrupt cleared by software bus collision occurs. set bclif. scl = 0 before brg time-out, ? 0 ?? 0 ? ? 0 ? ? 0 ? sda scl sen set s less than t brg t brg sda = 0 , scl = 1 bclif s sspif s interrupts cleared by software set sspif sda = 0 , scl = 1 , scl pulled low after brg time-out set sspif ? 0 ? sda pulled low by other master. reset brg and assert sda. set sen, enable start sequence if sda = 1 , scl = 1
pic16f193x/lf193x ds41364c-page 320 preliminary ? 2009 microchip technology inc. 22.6.13.2 bus collision during a repeated start condition during a repeated start condition, a bus collision occurs if: a) a low level is sampled on sda when scl goes from low level to high level. b) scl goes low before sda is asserted low, indicating that another master is attempting to transmit a data ? 1 ?. when the user releases sda and the pin is allowed to float high, the brg is loaded with sspadd and counts down to zero. the scl pin is then deasserted and when sampled high, the sda pin is sampled. if sda is low, a bus collision has occurred (i.e., another master is attempting to transmit a data ? 0 ?, figure 22-32). if sda is sampled high, the brg is reloaded and begins counting. if sda goes from high-to-low before the brg times out, no bus collision occurs because no two masters can assert sda at exactly the same time. if scl goes from high-to-low before the brg times out and sda has not already been asserted, a bus collision occurs. in this case, another master is attempting to transmit a data ? 1 ? during the repeated start condition, see figure 22-33. if, at the end of the brg time-out, both scl and sda are still high, the sda pin is driven low and the brg is reloaded and begins counting. at the end of the count, regardless of the status of the scl pin, the scl pin is driven low and the repeated start condition is complete. figure 22-33: bus collision during a repeat ed start condition (case 1) figure 22-34: bus collision during repeat ed start condition (case 2) sda scl rsen bclif s sspif sample sda when scl goes high. if sda = 0 , set bclif and release sda and scl. cleared by software ? 0 ? ? 0 ? sda scl bclif rsen s sspif interrupt cleared by software scl goes low before sda, set bclif. release sda and scl. t brg t brg ? 0 ?
? 2009 microchip technology inc. preliminary ds41364c-page 321 pic16f193x/lf193x 22.6.13.3 bus collision during a stop condition bus collision occurs during a stop condition if: a) after the sda pin has been deasserted and allowed to float high, sda is sampled low after the brg has timed out. b) after the scl pin is deasserted, scl is sampled low before sda goes high. the stop condition begins with sda asserted low. when sda is sampled low, the scl pin is allowed to float. when the pin is sampled high (clock arbitration), the baud rate generator is loaded with sspadd and counts down to 0. after the brg times out, sda is sampled. if sda is sampled low, a bus collision has occurred. this is due to another master attempting to drive a data ? 0 ? (figure 22-34). if the scl pin is sampled low before sda is allowed to float high, a bus collision occurs. this is another case of another master attempting to drive a data ? 0 ? (figure 22-35). figure 22-35: bus collision during a stop condition (case 1) figure 22-36: bus collision during a stop condition (case 2) sda scl bclif pen p sspif t brg t brg t brg sda asserted low sda sampled low after t brg , set bclif ? 0 ? ? 0 ? sda scl bclif pen p sspif t brg t brg t brg assert sda scl goes low before sda goes high, set bclif ? 0 ? ? 0 ?
pic16f193x/lf193x ds41364c-page 322 preliminary ? 2009 microchip technology inc. 22.7 baud rate generator the mssp module has a baud rate generator avail- able for clock generation in both i 2 c and spi master modes. the baud rate generator (brg) reload value is placed in the sspadd register (register 22-6). when a write occurs to sspbuf, the baud rate gen- erator will automatically begin counting down. once the given operation is complete, the internal clock will automatically stop counting and the clock pin will remain in its last state. an internal signal ?reload? in figure 22-36 triggers the value from sspadd to be loaded into the brg counter. this occurs twice for each oscillation of the module clock line. the logic dictating when the reload signal is asserted depends on the mode the mssp is being operated in. table 22-3 demonstrates clock rates based on instruction cycles and the brg value loaded into sspadd. equation 22-1: figure 22-37: baud rate genera tor block diagram table 22-3: mssp clock rate w/brg f clock f osc sspadd 1 + () 4 () ---------------------------------------------- = note: values of 0x00, 0x01 and 0x02 are not valid for sspadd when used as a baud rate generator for i 2 c. this is an implementation limitation. f osc f cy brg value f clock (2 rollovers of brg) 32 mhz 8 mhz 13h 400 khz (1) 32 mhz 8 mhz 19h 308 khz 32 mhz 8 mhz 4fh 100 khz 16 mhz 4 mhz 09h 400 khz (1) 16 mhz 4 mhz 0ch 308 khz 16 mhz 4 mhz 27h 100 khz 4 mhz 1 mhz 09h 100 khz 4 mhz 1 mhz 00h 250 khz (2) note 1: the i 2 c interface does not conform to the 400 khz i 2 c specification (which applies to rates greater than 100 khz) in all details, but may be used with care where higher rates are required by the application. 2: spi mode only. sspm<3:0> brg down counter sspclk f osc /2 sspadd<7:0> sspm<3:0> scl reload control reload
? 2009 microchip technology inc. preliminary ds41364c-page 323 pic16f193x/lf193x 23.0 data eeprom and flash program memory control the data eeprom and flash program memory are readable and writable during normal operation (full v dd range). these memories are not directly mapped in the register file space. instead, they are indirectly addressed through the special function registers (sfrs). there are six sfrs used to access these memories: ? eecon1 ? eecon2 ? eedatl ?eedath ? eeadrl ?eeadrh when interfacing the data memory block, eedatl holds the 8-bit data for read/write, and eeadrl holds the address of the eedatl location being accessed. these devices have 256 bytes of data eeprom with an address range from 0h to 0ffh. when accessing the program memory block of the pic16f1936/pic16f1937 devices, the eedatl and eedath registers form a 2-byte word that holds the 14-bit data for read/write, and the eeadrl and eeadrh registers form a 2-byte word that holds the 15-bit address of the program memory location being read. the eeprom data memory allows byte read and write. an eeprom byte write automatically erases the loca- tion and writes the new data (erase before write). the write time is controlled by an on-chip timer. the write/erase voltages are generated by an on-chip charge pump rated to operate over the voltage range of the device for byte or word operations. depending on the setting of the flash program memory self write enable bits wrt<1:0> of the configuration word register 2, the device may or may not be able to write certain blocks of the program memory. however, reads from the program memory are always allowed. when the device is code-protected, the device programmer can no longer access data or program memory. when code-protected, the cpu may continue to read and write the data eeprom memory and flash program memory. 23.1 eeadrl and eeadrh registers the eeadrl and eeadrh registers can address up to a maximum of 256 bytes of data eeprom or up to a maximum of 32k words of program memory. when selecting a program address value, the msb of the address is written to the eeadrh register and the lsb is written to the eeadrl register. when selecting a eeprom address value, only the lsb of the address is written to the eeadrl register. 23.1.1 eecon1 and eecon2 registers eecon1 is the control register for ee memory accesses. control bit eepgd determines if the access will be a program or data memory access. when clear, any subsequent operations will operate on the eeprom memory. when set, any subsequent operations will operate on the program memory. on reset, eeprom is selected by default. control bits rd and wr initiate read and write, respectively. these bits cannot be cleared, only set, in software. they are cleared in hardware at completion of the read or write operation. the inability to clear the wr bit in software prevents the accidental, premature termination of a write operation. the wren bit, when set, will allow a write operation to occur. on power-up, the wren bit is clear. the wrerr bit is set when a write operation is interrupted by a reset during normal operation. in these situations, following reset, the user can check the wrerr bit and execute the appropriate error handling routine. interrupt flag bit eeif of the pir2 register is set when write is complete. it must be cleared in the software. reading eecon2 will read all ? 0 ?s. the eecon2 reg- ister is used exclusively in the data eeprom write sequence. to enable writes, a specific pattern must be written to eecon2.
pic16f193x/lf193x ds41364c-page 324 preliminary ? 2009 microchip technology inc. register 23-1: eedatl: eeprom data register r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u eedatl7 eedatl6 eedatl5 eedatl4 eedatl3 eedatl2 eedatl1 eedatl0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 eedatl<7:0> : 8 least significant data bits of data eeprom or read from program memory register 23-2: eedath: eeprom data high byte register u-0 u-0 r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u r/w-x/u ? ? eedath5 eedath4 eedath3 eedath2 eedath1 eedath0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-6 unimplemented: read as ? 0 ? bit 5-0 eedath<5:0> : 6 most significant data bits from program memory register 23-3: eeadrl: eeprom address register r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 eeadr7 eeadr6 eeadr5 eeadr4 eeadr3 eeadr2 eeadr1 eeadr0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 eeadrl<7:0> : 8 least significant address bits for eeprom or program memory register 23-4: eeadrh: eeprom address high byte register u-0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 r/w-0/0 ? eeadrh6 eeadrh5 eeadrh4 eeadrh3 eeadrh2 eeadrh1 eeadrh0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? u = bit is unchanged x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7 unimplemented: read as ? 0 ? bit 6-0 eeadrh<6:0> : specifies the 7 most significant address bits or high bits for program memory reads
? 2009 microchip technology inc. preliminary ds41364c-page 325 pic16f193x/lf193x register 23-5: eecon1: ee prom control 1 register r/w-0/0 r/w-0/0 r/w-0/0 r/w/hc-0/0 r/w-x/q r/w-0/0 r/s/hc-0/0 r/s/hc-0/0 eepgd cfgs lwlo free wrerr wren wr rd bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? s = bit can only be set x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared hc = bit is cleared by hardware bit 7 eepgd: flash program/data eeprom memory select bit 1 = accesses program space flash memory 0 = accesses data eeprom memory bit 6 cfgs: flash program/data eeprom or configuration select bit 1 = accesses configuration, user id and device id registers 0 = accesses flash program or data eeprom memory bit 5 lwlo: load write latches only bit if eepgd = 1 or cfgs = 1 : ( accessing program flash) 1 = the next wr command does not initiate a write to the pfm; only the program memory latches are updated. 0 = the next wr command writes a value from eedath:eedatl into program memory latches and initiates a write to the pfm of all the data stored in the program memory latches. if eepgd = 0 and cfgs = 1 : (accessing data eeprom) lwlo is ignored. the next wr command initiates a write to the data eeprom. bit 4 free: program flash erase enable bit if eepgd = 1 or cfgs = 1 : ( accessing program flash) 1 = perform an program flash erase operation on the next wr command (cleared by hardware after completion of erase). 0 = perform a program flash write operation on the next wr command. if eepgd = 0 and cfgs = 0 : (accessing data eeprom) free is ignored. the next wr command will initiate both a erase cycle and a write cycle. bit 3 wrerr: eeprom error flag bit 1 = condition could indicate an improper program or erase sequence attempt or termination (bit is set automatically on any set attempt (write ? 1 ?) of the wr bit. 0 = the program or erase operation completed normally. bit 2 wren: program/erase enable bit 1 = allows program/erase cycles 0 = inhibits programming/erasing of program flash and data eeprom bit 1 wr: write control bit 1 = initiates a program flash or data eeprom program/erase operation. the operation is self-timed and the bit is cleared by hardware once operation is complete. the wr bit can only be set (not cleared) in software. 0 = program/erase operation to the flash or data eeprom is complete and inactive. bit 0 rd: read control bit 1 = initiates an program flash or data eeprom read. read takes one cycle. rd is cleared in hardware. the rd bit can only be set (not cleared) in software. 0 = does not initiate a program flash or data eeprom data read.
pic16f193x/lf193x ds41364c-page 326 preliminary ? 2009 microchip technology inc. register 23-6: eecon2: ee prom control 2 register r-0/0 r-0/0 r-0/0 r-0/0 r-0/0 r-0/0 r-0/0 r-0/0 eeunlk7 eeunlk6 eeunlk5 eeunlk4 eeunlk3 eeunlk2 eeunlk1 eeunlk0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as ?0? s = bit can only be set x = bit is unknown -n/n = value at por and bor/value at all other resets ?1? = bit is set ?0? = bit is cleared bit 7-0 eeunlk<7:0>: data eeprom unlock pattern bits to unlock writes, a 55h must be written first, followed by an aah, before setting the wr bit of the eecon1 register. the value written to this register is used to unlock the writes. there are specific timing requirements on these writes. refer to section 23.1.3 ?writing to the data eeprom memory? for more information.
? 2009 microchip technology inc. preliminary ds41364c-page 327 pic16f193x/lf193x 23.1.2 reading the data eeprom memory to read a data memory location, the user must write the address to the eeadrl register, clear the eepgd and cfgs control bits of the eecon1 register, and then set control bit rd. the data is available at the very next cycle, in the eedatl register; therefore, it can be read in the next instruction. eedatl will hold this value until another read or until it is written to by the user (during a write operation). example 23-1: data eeprom read 23.1.3 writing to the data eeprom memory to write an eeprom data location, the user must first write the address to the eeadrl register and the data to the eedatl register. then the user must follow a specific sequence to initiate the write for each byte. the write will not initiate if the above sequence is not followed exactly (write 55h to eecon2, write aah to eecon2, then set wr bit) for each byte. interrupts should be disabled during this code segment. additionally, the wren bit in eecon1 must be set to enable write. this mechanism prevents accidental writes to data eeprom due to errant (unexpected) code execution (i.e., lost programs). the user should keep the wren bit clear at all times, except when updating eeprom. the wren bit is not cleared by hardware. after a write sequence has been initiated, clearing the wren bit will not affect this write cycle. the wr bit will be inhibited from being set unless the wren bit is set. at the completion of the write cycle, the wr bit is cleared in hardware and the ee write complete interrupt flag bit (eeif) is set. the user can either enable this interrupt or poll this bit. eeif must be cleared by software. example 23-2: data eeprom write note: data eeprom can be read regardless of the setting of the cpd bit. banksel eeadrl ; movlw data_ee_addr ; movwf eeadrl ;data memory ;address to read bcf eecon1, cfgs ;deselect config space bcf eecon1, eepgd;point to data memory bsf eecon1, rd ;ee read movf eedatl, w ;w = eedatl bcf status, rp1 ;bank 0 banksel eeadrl ; movlw data_ee_addr ; movwf eeadrl ;data memory address to write movlw data_ee_data ; movwf eedatl ;data memory value to write bcf eecon1, cfgs ;deselect configuration space bcf eecon1, eepgd ;point to data memory bsf eecon1, wren ;enable writes bcf intcon, gie ;disable ints. btfsc intcon, gie ;see an576 goto $-2 movlw 55h ; movwf eecon2 ;write 55h movlw aah ; movwf eecon2 ;write aah bsf eecon1, wr ;set wr bit to begin write bcf eecon1, wren ;disable writes btfsc eecon1, wr ;wait for write to complete goto $-2 ;done required sequence
pic16f193x/lf193x ds41364c-page 328 preliminary ? 2009 microchip technology inc. 23.1.4 reading the flash program memory to read a program memory location, the user must: 1. write the least and most significant address bits to the eeadrl and eeadrh registers. 2. clear the cfgs bit of the eecon1 register. 3. set the eepgd control bit of the eecon1 register. 4. then, set control bit rd of the eecon1 register. once the read control bit is set, the program memory flash controller will use the second instruction cycle to read the data. this causes the second instruction immediately following the ? bsf eecon1,rd ? instruction to be ignored. the data is available in the very next cycle, in the eedatl and eedath registers; therefore, it can be read as two bytes in the following instructions. eedatl and eedath registers will hold this value until another read or until it is written to by the user. example 23-3: flash program read note 1: the two instructions following a program memory read are required to be nop s. this prevents the user from executing a two-cycle instruction on the next instruction after the rd bit is set. 2: data eeprom can be read regardless of the setting of the cpd bit. banksel eeadrl ; movlw ms_prog_ee_addr ; movwf eeadrh ;ms byte of program address to read movlw ls_prog_ee_addr ; movwf eeadrl ;ls byte of program address to read banksel eecon1 ; bsf eecon1, eepgd ;point to program memory bsf eecon1, rd ;ee read ; ;first instruction after bsf eecon1,rd executes normally nop nop ;any instructions here are ignored as program ;memory is read in second cycle after bsf eecon1,rd ; banksel eedatl ; movf eedatl, w ;w = ls byte of program memory movwf lowpmbyte ; movf eedath, w ;w = ms byte of program eedatl movwf highpmbyte ; bcf status, rp1 ;bank 0 required sequence
? 2009 microchip technology inc. preliminary ds41364c-page 329 pic16f193x/lf193x example 23-4: flash program memory read figure 23-1: flash program me mory read cycle execution * this code block will read 1 word of program * memory at the memory address: prog_addr_hi : prog_addr_lo * data will be returned in the variables; * prog_data_hi, prog_data_lo banksel eeadrl ; select bank for eeprom registers movlw prog_addr_lo ; movwf eeadrl ; store lsb of address movlw prog_addr_hi ; movwl eeadrh ; store msb of address bcf eecon1,cfgs ; select flash and eeprom space bsf eecon1,eepgd ; select program memory bcf intcon,gie ; disable interrupts bsf eecon1,rd ; initiate read nop ; executed (figure 23-1) nop ; ignored (figure 23-1) bsf intcon,gie ; restore interrupts movf eedatl,w ; get lsb of word movwf prog_data_lo ; store in user location movf eedath,w ; get msb of word movwf prog_data_hi ; store in user location q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 bsf eecon1,rd executed here instr(pc + 1) executed here forced nop executed here pc pc + 1 eeadrh,eeadrl pc+3 pc + 5 flash addr rd bit eedath,eedatl pc + 3 pc + 4 instr (pc + 1) instr(pc - 1) executed here instr(pc + 3) executed here instr(pc + 4) executed here flash data eedath eedatl register eerhlt instr (pc) instr (pc + 3) instr (pc + 4)
pic16f193x/lf193x ds41364c-page 330 preliminary ? 2009 microchip technology inc. 23.2 erasing program memory while executing code, program memory can only be erased by rows. a row consists of 32 words where the eeadrl<4:0> = 00000 . to erase a row: 1. load the eeadrh and eeadrl registers with the address of new row to be erased. 2. clear the cfgs bit of the eecon1 register. 3. set the eepgd bit of the eecon1 register. 4. set the free bit of the eecon1 register. 5. write 55h, then aah, to eecon2 (flash programming unlock sequence). 6. set control bit wr of the eecon1 register to begin the write operation. 23.3 writing to flash program memory before writing, program memory should be erased using the erase program memory command. no automatic erase occurs upon the initiation of the write; if the program flash needs to be erased before writing, the row (32 words) must be erased previously. flash program memory may only be written to if the destination address is in a segment of memory that is not write-protected, as defined in bits wrt<1:0> of the configuration word register 2. flash program memory must be written in eight-word blocks. see figure 23-2 for more details. a block consists of eight words with sequential addresses, with a lower boundary defined by an address, where eeadrl<2:0> = 000 . all block writes to program memory are done as 32-word erase by eight-word write operations. the write operation is edge-aligned and cannot occur across boundaries. when the lwlo bit is ? 1 ?, the write sequence will only load the buffer register and will not actually initiate the write to program flash: 1. set the eepgd, wren and lwlo bits of the eecon1 register. 2. write 55h, then aah, to eecon2 (flash programming unlock sequence). 3. set control bit wr of the eecon1 register to begin the write operation. to write program data, it must first be loaded into the buffer registers (see figure 23-1). this is accomplished by first writing the destination address to eeadrl and eeadrh and then writing the data to eedata and eedath. after the address and data have been set up, then the following sequence of events must be executed: 1. set the eepgd control bit of the eecon1 register. 2. set the lwlo bit of the eecon1 register. 3. write 55h, then aah, to eecon2 (flash programming sequence). 4. set the wr control bit of the eecon1 register. up to eight buffer register locations can be written to with correct data. if less than eight words are being writ- ten to in the block of eight words, then the data for the unprogrammed words should be set to all ones. after the ? bsf eecon1,wr ? instruction, the processor requires two cycles to set up the erase/write operation. the user must place two nop instructions after the wr bit is set. since data is being written to buffer registers, the writing of the first seven words of the block appears to occur immediately. the processor will halt internal operations for the typical 2 ms, only during the cycle in which the erase takes place (i.e., the last word of the sixteen-word block erase). this is not sleep mode as the clocks and peripherals will continue to run. after the eight-word write cycle, the processor will resume oper- ation with the third instruction after the eecon1 write instruction. an example of the complete eight-word write sequence is shown in example 23-5. the initial address is loaded into the eeadrh and eeadrl register pair; the eight words of data are loaded using indirect addressing.
? 2009 microchip technology inc. preliminary ds41364c-page 331 pic16f193x/lf193x figure 23-2: block writes to 8k flash program memory 14 14 14 14 program memory buffer register eeadrl<2:0> = 000 buffer register eeadrl<2:0> = 001 buffer register eeadrl<2:0> = 010 buffer register eeadrl<2:0> = 111 eedata eedath 75 07 0 6 8 first word of block to be written
pic16f193x/lf193x ds41364c-page 332 preliminary ? 2009 microchip technology inc. example 23-5: writing to flash program memory ; this write routine assumes the following: ; 1. a valid starting address (the least significant bits = 00)is loaded in addrh:addrl ; 2. the 8 bytes of data are loaded, starting at the address in dataddr ; 3. addrh, addrl and dataddr are all located in shared data memory 0x70 - 0x7f ; banksel eeadrh ; bank 3 movf addrh,w ; load initial address movwf eeadrh ; movf addrl,w ; movwf eeadrl ; movf dataaddrl,w ; load initial data address movwf fsr0l ; movf dataaddrh,w ; load initial data address movwf fsr0h ; loop moviw indf0++ ; load first data byte into lower movwf eedatl ; moviw indf0++ ; load second data byte into upper movwf eedath ; bsf eecon1,eepgd ; point to program memory bcf eecon1,cfgs ; not configuration space bsf eecon1,wren ; enable writes bsf eecon1,lwlo ; only load write latches movlw 55h ; start of required write sequence: movwf eecon2 ; write 55h movlw aah ; movwf eecon2 ; write aah bsf eecon1,wr ; set wr bit to begin write nop ; any instructions here are ignored as processor ; halts to begin write sequence nop ; processor will stop here and wait for write complete ; after write processor continues with 3rd instruction movf eeadr,w ; check if lower two bits of address are ?00? xorlw 0x08 ; check if we?re on the last of 8 addresses andlw 0x08 ; btfsc status,z ; exit if last of eight words, goto start_write ; incf eeadr,f ; still loading latches increment address goto loop ; write next latches start_write bcf eecon1,lwlo ; no more latches only; actually start write movlw 55h ; start of required write sequence: movwf eecon2 ; write 55h movlw aah ; movwf eecon2 ; write aah bsf eecon1,wr ; set wr bit to begin write nop ; any instructions here are ignored as processor ; halts to begin write sequence nop ; processor will stop here and wait for write complete ; after write processor continues with 3rd instruction bcf eecon1,wren ; disable writes required sequence required sequence
? 2009 microchip technology inc. preliminary ds41364c-page 333 pic16f193x/lf193x 23.4 configuration word and device id access instead of accessing program memory or eeprom data memory, the user id?s, device id/revision id and configuration words can be accessed when cfgs = 1 . this is the region that would be pointed to by pc<15> = 1 , but not all addresses are accessible. different access may exist for reads and writes. refer to table 23-1. when read access is initiated on an unallowed address, the eedath:eedatl registers are cleared. writes can be disabled via the wrt configuration bits. refer to the configuration word 2 register. table 23-1: pfm and fuse access via eecon1/eedath:eedatl registers (when cfgs = 1 ) example 23-3: conf iguration word and device id access address function read access write access 8000h-8003h user ids yes yes 8006h device id/revision id yes no 8007h-8008h configuration words 1 and 2 yes no * this code block will read 1 word of program * memory at the memory address: prog_addr_hi : prog_addr_lo * data will be returned in the variables; * prog_data_hi, prog_data_lo banksel eeadrl ; select bank 2 movlw prog_addr_lo ; movwf eeadrl ; store lsb of address movlw prog_addr_hi ; movwl eeadrh ; store msb of address bcf eecon1,cfgs ; deselect configuration space bsf eecon1,eepgd ; select program memory bcf intcon,gie ; disable interrupts bsf eecon1,rd ; initiate read nop ; executed (figure 23-1) nop ; ignored (figure 23-1) bsf intcon,gie ; restore interrupts movf eedatl,w ; get lsb of word movwf prog_data_lo ; store in user location movf eedath,w ; get msb of word movwf prog_data_hi ; store in user location
pic16f193x/lf193x ds41364c-page 334 preliminary ? 2009 microchip technology inc. 23.5 write verify depending on the application, good programming practice may dictate that the value written to the data eeprom or program memory should be verified (see example 23-6) to the desired value to be written. example 23-6: write verify 23.5.1 using the data eeprom the data eeprom is a high-endurance, byte addressable array that has been optimized for the storage of frequently changing information (e.g., program variables or other data that are updated often). when variables in one section change frequently, while variables in another section do not change, it is possible to exceed the total number of write cycles to the eeprom (specification d124) without exceeding the total number of write cycles to a single byte (specifications d120 and d120a). if this is the case, then a refresh of the array must be performed. for this reason, variables that change infrequently (such as constants, ids, calibration, etc.) should be stored in flash program memory. 23.6 protection against spurious write there are conditions when the user may not want to write to the data eeprom memory. to protect against spurious eeprom writes, various mechanisms have been built-in. on power-up, wren is cleared. also, the power-up timer (64 ms duration) prevents eeprom write. the write initiate sequence and the wren bit together help prevent an accidental write during: ? brown-out ? power glitch ? software malfunction 23.7 data eeprom operation during code-protect data memory can be code-protected by programming the cpd bit in the configuration word register 1 (register 10-1) to ? 0 ?. when the data memory is code-protected, only the cpu is able to read and write data to the data eeprom. it is recommended to code-protect the program memory when code-protecting data memory. this prevents anyone from replacing your program with a program that will access the contents of the data eeprom. table 23-2: summary of registers associated with data eeprom banksel eedatl ; movf eedatl, w ;eedatl not changed ;from previous write bsf eecon1, rd ;yes, read the ;value written xorwf eedatl, w ; btfss status, z ;is data the same goto write_err ;no, handle error : ;yes, continue name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page eecon1 eepgd cfgs lwlo free wrerr wren wr rd 325 eecon2 eeprom control register 2 (not a physical register) 326* eeadrl eeadrl7 eeadrl6 eeadrl5 eeadrl 4 eeadrl3 eeadrl2 eeadrl1 eeadrl0 324 eeadrh ? eeadrh6 eeadrh5 eeadrh4 eeadrh3 eeadrh2 eeadrh1 eeadrh0 324 eedatl eedatl7 eedatl6 eedatl5 eedat l4 eedatl3 eedatl2 eedalt1 eedatl0 324 eedath ? ? eedath5 eedath4 eedath3 eedath2 eedath1 eedath0 324 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie2 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie 77 pir2 osfif c2if c1if eeif bclif lcdif ? ccp2if 80 legend: x = unknown, u = unchanged, ? = unimplemented read as ? 0 ?, q = value depends upon condition. shaded cells are not used by data eeprom module. * page provides register information.
? 2009 microchip technology inc. preliminary ds41364c-page 335 pic16f193x/lf193x 24.0 power-down mode (sleep) the power-down mode is entered by executing a sleep instruction. if the watchdog timer is enabled: ? wdt will be cleared but keeps running. ?pd bit of the status register is cleared. ?to bit of the status register is set. ? oscillator driver is turned off. ? timer1 oscillator is unaffected ? i/o ports maintain the status they had before sleep was executed (driving high, low or high- impedance). for lowest current consumption in this mode, all i/o pins should be either at v dd or v ss , with no external circuitry drawing current from the i/o pin. i/o pins that are high-impedance inputs should be pulled high or low externally to avoid switching currents caused by float- ing inputs. the t0cki input should also be at v dd or v ss for lowest current consumption. the contribution from on-chip pull-ups on portb should be considered. enabled resets remain functional during sleep. 24.1 wake-up from sleep the device can wake-up from sleep through one of the following events: 1. external reset input on mclr pin, if enabled. 2. bor reset, if enabled. 3. watchdog timer wake-up (if wdt was enabled). 4. any external interrupt. 5. certain peripheral interrupts (see individual peripheral for more information). the first two events will cause a device reset. the last three events are considered a continuation of program execution. the to and pd bits in the status register can be used to determine the cause of device reset. the pd bit, which is set on power-up, is cleared when sleep is invoked. to bit is cleared if wdt wake-up occurred. certain peripherals cannot generate interrupts since during sleep, no on-chip clocks are present. when the sleep instruction is being executed, the next instruction (pc + 1) is prefetched. for the device to wake-up through an interrupt event, the corresponding interrupt enable bit must be set (enabled). wake-up is regardless of the state of the gie bit. if the gie bit is clear (disabled), the device continues execution at the instruction after the sleep instruction. if the gie bit is set (enabled), the device executes the instruction after the sleep instruction, then branches to the interrupt address (0004h). in cases where the execution of the instruction following sleep is not desirable, the user should have a nop after the sleep instruction. the wdt is cleared when the device wakes up from sleep, regardless of the source of wake-up. note: if the global interrupts are disabled (gie is cleared), but any interrupt source has both its interrupt enable bit and the correspond- ing interrupt flag bits set, the device will immediately wake-up from sleep. the sleep instruction is completely executed.
pic16f193x/lf193x ds41364c-page 336 preliminary ? 2009 microchip technology inc. 24.2 wake-up using interrupts when global interrupts are disabled (gie cleared) and any interrupt source has both its interrupt enable bit and interrupt flag bit set, one of the following will occur: ? if the interrupt occurs before the execution of a sleep instruction, the sleep instruction will complete as a nop . therefore, the wdt and wdt prescaler and postscaler (if enabled) will not be cleared, the to bit will not be set and the pd bit will not be cleared. ? if the interrupt occurs during or after the execution of a sleep instruction, the device will immediately wake-up from sleep. the sleep instruction will be completely executed before the wake-up. therefore, the wdt and wdt prescaler and postscaler (if enabled) will be cleared, the to bit will be set and the pd bit will be cleared. even if the flag bits were checked before executing a sleep instruction, it may be possible for flag bits to become set before the sleep instruction completes. to determine whether a sleep instruction executed, test the pd bit. if the pd bit is set, the sleep instruction was executed as a nop . figure 24-1: wake-up from sleep through interrupt table 24-1: summary of registers associated with power-down mode q1 q2 q3 q4 q1 q2 q3 q4 q1 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 osc1 (1) clkout (4) int pin intf flag (intcon reg.) gie bit (intcon reg.) instruction flow pc instruction fetched instruction executed pc pc + 1 pc + 2 inst(pc) = sleep inst(pc - 1) inst(pc + 1) sleep processor in sleep interrupt latency (3) inst(pc + 2) inst(pc + 1) inst(0004h) inst(0005h) inst(0004h) dummy cycle pc + 2 0004h 0005h dummy cycle t ost (2) pc + 2 note 1: xt, hs or lp oscillator mode assumed. 2: t ost = 1024 t osc (drawing not to scale). this delay does not apply to ec and rc oscillator modes. 3: gie = 1 assumed. in this case after wake-up, the processor jumps to 0004h. if gie = 0 , execution will continue in-line. 4: clkout is not available in xt, hs, or lp oscillator modes, but shown here for timing reference. name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 register on page iocbf iocbf7 iocbf6 iocbf5 iocbf 4iocbf3iocbf2iocbf1iocbf0 106 iocbn iocbn7 iocbn6 iocbn5 iocbn4 iocbn3 iocbn2 iocbn1 iocbn0 106 iocbp iocbp7 iocbp6 iocbp5 iocbp4 iocbp3 iocbp2 io cbp1 iocbp0 106 intcon gie peie tmr0ie inte iocie tmr0if intf iocif 75 pie1 tmr1gie adie rcie txie sspie ccp1ie tmr2ie tmr1ie 76 pie2 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie 77 pir1 tmr1gif adif rcif txif sspif ccp1if tmr2if tmr1if 79 pir2 osfie c2ie c1ie eeie bclie lcdie ? ccp2ie 80 legend: x = unknown, u = unchanged, ? = unimplemented, read as ? 0 ?. shaded cells are not used in power-down mode.
? 2009 microchip technology inc. preliminary ds41364c-page 337 pic16f193x/lf193x 25.0 in-circuit serial programming? (icsp?) icsp? programming allows customers to manufacture circuit boards with unprogrammed devices. programming can be done after the assembly process allowing the device to be programmed with the most recent firmware or a custom firmware. five pins are needed for icsp? programming: ? icspclk ? icspdat ?mclr /v pp ?v dd ?v ss in program/verify mode the program memory, user ids and the configuration words are programmed through serial communications. the icspdat pin is a bidirectional i/o used for transferring the serial data and the icspclk pin is the clock input. for more infor- mation on icsp? refer to the ? pic16193x/pic16lf193x memory programming specification ? (ds41360a) 25.1 high-voltage programming mode the device is placed into high-voltage program/verify mode by holding the icspclk and icspdat pins low then raising the voltage on mclr /v pp to v ihh . 25.2 low-voltage programming mode the low-voltage programming mode allows the pic16f193x/lf193x devices to be programmed using v dd only, without high voltage. when the lvp bit of the configuration word 2 register is set to ? 1 ?, the low-voltage icsp programming entry is enabled. to disable the low-voltage icsp mode, the lvp bit must be programmed to ? 0 ?. entry into the low-voltage icsp program/verify modes requires the following steps: 1. mclr is brought to v il . 2. a 32-bit key sequence is presented on icspdat, while clocking icspclk. once the key sequence is complete, mclr must be held at v il for as long as program/verify mode is to be maintained. figure 25-1: typical connect ion for icsp? programming note: the icd 2 produces a v pp voltage greater than the maximum v pp specification of the pic16f193x/lf193x. when using this programmer, an external circuit is required to keep the v pp voltage within the device specifications. v dd v pp v ss external device to be data clock v dd mclr /v pp v ss icspdat icspclk * * * to normal connections * isolation devices (as required). 10k programming signals programmed v dd
pic16f193x/lf193x ds41364c-page 338 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 339 pic16f193x/lf193x 26.0 instruction set summary each pic16 instruction is a 14-bit word containing the operation code (opcode) and all required operands. the opcodes are broken into three broad categories. ? byte oriented ? bit oriented ? literal and control the literal and control category contains the most var- ied instruction word format. table 26-3 lists the instructions recognized by the mpasm tm assembler. all instructions are executed within a single instruction cycle, with the following exceptions, which may take two or three cycles: ? subroutine takes two cycles ( call , callw ) ? returns from interrupts or subroutines take two cycles ( return , retlw , retfie ) ? program branching takes two cycles ( goto , bra , brw , btfss , btfsc , decfsz , incsfz ) ? one additional instruction cycle will be used when any instruction references an indirect file register and the msb of the appropriate file select register is set. one instruction cycle consists of 4 oscillator cycles; for an oscillator frequency of 4 mhz, this gives a nominal instruction execution rate of 1 mhz. all instruction examples use the format ? 0xhh ? to represent a hexadecimal number, where ? h ? signifies a hexadecimal digit. 26.1 read-modify-write operations any instruction that specifies a file register as part of the instruction performs a read-modify-write (r-m-w) operation. the register is read, the data is modified, and the result is stored according to either the instruc- tion, or the destination designator ?d?. a read operation is performed on a register even if the instruction writes to that register. table 26-1: opcode field descriptions table 26-2: abbreviation descriptions field description f register file address (0x00 to 0x7f) w working register (accumulator) b bit address within an 8-bit file register k literal field, constant data or label x don?t care location (= 0 or 1 ). the assembler will generate code with x = 0 . it is the recommended form of use for compatibility with all microchip software tools. d destination select; d = 0 : store result in w , d = 1 : store result in file register f. default is d = 1. n fsr or indf number. (0-1) mm pre-post increment-decrement mode selection field description pc program counter to time-out bit c carry bit dc digit carry bit z zero bit pd power-down bit
pic16f193x/lf193x ds41364c-page 340 preliminary ? 2009 microchip technology inc. figure 26-1: general format for instructions byte-oriented file register operations 13 8 7 6 0 d = 0 for destination w opcode d f (file #) d = 1 for destination f f = 7-bit file register address bit-oriented file register operations 13 10 9 7 6 0 opcode b (bit #) f (file #) b = 3-bit bit address f = 7-bit file register address literal and control operations 13 8 7 0 opcode k (literal) k = 8-bit immediate value 13 11 10 0 opcode k (literal) k = 11-bit immediate value general call and goto instructions only movlp instruction only 13 5 4 0 opcode k (literal) k = 5-bit immediate value movlb instruction only 13 9 8 0 opcode k (literal) k = 9-bit immediate value bra instruction only fsr offset instructions 13 7 6 5 0 opcode n k (literal) n = appropriate fsr fsr increment instructions 13 7 6 0 opcode k (literal) k = 7-bit immediate value 13 3 2 1 0 opcode n m (mode) n = appropriate fsr m = 2-bit mode value k = 6-bit immediate value 13 0 opcode opcode only
? 2009 microchip technology inc. preliminary ds41364c-page 341 pic16f193x/lf193x table 26-3: pic16f193x/lf 193x enhanced instruction set mnemonic, operands description cycles 14-bit opcode status affected notes msb lsb byte-oriented file register operations addwf addwfc andwf asrf lslf lsrf clrf clrw comf decf incf iorwf movf movwf rlf rrf subwf subwfb swapf xorwf f, d f, d f, d f, d f, d f, d f ? f, d f, d f, d f, d f, d f f, d f, d f, d f, d f, d f, d add w and f add with carry w and f and w with f arithmetic right shift logical left shift logical right shift clear f clear w complement f decrement f increment f inclusive or w with f move f move w to f rotate left f through carry rotate right f through carry subtract w from f subtract with borrow w from f swap nibbles in f exclusive or w with f 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 00 11 00 11 11 11 00 00 00 00 00 00 00 00 00 00 00 11 00 00 0111 1101 0101 0111 0101 0110 0001 0001 1001 0011 1010 0100 1000 0000 1101 1100 0010 1011 1110 0110 dfff dfff dfff dfff dfff dfff lfff 0000 dfff dfff dfff dfff dfff 1fff dfff dfff dfff dfff dfff dfff ffff ffff ffff ffff ffff ffff ffff 00xx ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff ffff c, dc, z c, dc, z z c, z c, z c, z z z z z z z z c c c, dc, z c, dc, z z 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 byte oriented skip operations decfsz incfsz f, d f, d decrement f, skip if 0 increment f, skip if 0 1(2) 1(2) 00 00 1011 1111 dfff dfff ffff ffff 1, 2 1, 2 bit-oriented file register operations bcf bsf f, b f, b bit clear f bit set f 1 1 01 01 00bb 01bb bfff bfff ffff ffff 2 2 bit-oriented skip operations btfsc btfss f, b f, b bit test f, skip if clear bit test f, skip if set 1 (2) 1 (2) 01 01 10bb 11bb bfff bfff ffff ffff 1, 2 1, 2 literal operations addlw andlw iorlw movlb movlp movlw sublw xorlw k k k k k k k k add literal and w and literal with w inclusive or literal with w move literal to bsr move literal to pclath move literal to w subtract w from literal exclusive or literal with w 1 1 1 1 1 1 1 1 11 11 11 00 11 11 11 11 1110 1001 1000 0000 0001 0000 1100 1010 kkkk kkkk kkkk 001k 1kkk kkkk kkkk kkkk kkkk kkkk kkkk kkkk kkkk kkkk kkkk kkkk c, dc, z z z c, dc, z z note 1: if the program counter (pc) is modified, or a conditional test is true, the instruction requires two cycles. the second cycle is executed as a nop . 2: if this instruction addresses an indf register and the msb of the corresponding fsr is set, this instruction will require one additional instruction cycle.
pic16f193x/lf193x ds41364c-page 342 preliminary ? 2009 microchip technology inc. table 26-3: pic16f193x/lf193x e nhanced instruction set (continued) mnemonic, operands description cycles 14-bit opcode status affected notes msb lsb control operations bra brw call callw goto retfie retlw return k ? k ? k k k ? relative branch relative branch with w call subroutine call subroutine with w go to address return from interrupt return with literal in w return from subroutine 2 2 2 2 2 2 2 2 11 00 10 00 10 00 11 00 001k 0000 0kkk 0000 1kkk 0000 0100 0000 kkkk 0000 kkkk 0000 kkkk 0000 kkkk 0000 kkkk 1011 kkkk 1010 kkkk 1001 kkkk 1000 inherent operations clrwdt nop option reset sleep tris ? ? ? ? ? f clear watchdog timer no operation load option_reg register with w software device reset go into standby mode load tris register with w 1 1 1 1 1 1 00 00 00 00 00 00 0000 0000 0000 0000 0000 0000 0110 0000 0110 0000 0110 0110 0100 0000 0010 0001 0011 01kk to , pd to , pd c-compiler optimized addfsr moviw movwi n, k mm n n mm k[n] mm n n mm k[n] add literal to fsrn move indfn to w, with pre/post inc/dec move indfn to w, with pre/post inc/dec move indfn to w, indexed indirect. move w to indfn, with pre/post inc/dec move w to indfn, with pre/post inc/dec move w to indfn, indexed indirect. 1 1 1 1 1 1 1 11 00 00 11 00 00 11 0001 0000 0000 1111 0000 0000 1111 0nkk 0001 0001 0nkk 0001 0001 1nkk kkkk 0mmn 0nmm kkkk 1mmn 1nmm kkkk z z z 2 2 2 2 2 2 note 1: if the program counter (pc) is modified, or a conditional test is true, the instruction requires two cycles. the second cycle is executed as a nop . 2: if this instruction addresses an indf register and the msb of the corresponding fsr is set, this instruction will require one additional instruction cycle.
? 2009 microchip technology inc. preliminary ds41364c-page 343 pic16f193x/lf193x 26.2 instruction descriptions addfsr add literal to fsrn syntax: [ label ] addfsr n, k operands: -32 k 31 n [ 0, 1] operation: fsr(n) + k fsr(n) status affected: none description: the signed 6-bit literal ?k? is added to the contents of the fsrnh:fsrnl register pair. fsrn is limited to the range 0000h - ffffh. moving beyond these bounds will cause the fsr to wrap around. addlw add literal and w syntax: [ label ] addlw k operands: 0 k 255 operation: (w) + k (w) status affected: c, dc, z description: the contents of the w register are added to the eight-bit literal ?k? and the result is placed in the w register. addwf add w and f syntax: [ label ] addwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) + (f) (destination) status affected: c, dc, z description: add the contents of the w register with register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?. addwfc add w and carry bit to f syntax: [ label ] addwfc f {,d} operands: 0 f 127 d [0,1] operation: (w) + (f) + (c) dest status affected: c, dc, z description: add w, the carry flag and data mem- ory location ?f?. if ?d? is ? 0 ?, the result is placed in w. if ?d? is ? 1 ?, the result is placed in data memory location ?f?. andlw and literal with w syntax: [ label ] andlw k operands: 0 k 255 operation: (w) .and. (k) (w) status affected: z description: the contents of w register are and?ed with the eight-bit literal ?k?. the result is placed in the w register. andwf and w with f syntax: [ label ] andwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) .and. (f) (destination) status affected: z description: and the w register with register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?. asrf arithmetic right shift syntax: [ label ] asrf f {,d} operands: 0 f 127 d [0,1] operation: (f<7>) dest<7> (f<7:1>) dest<6:0>, (f<0>) c, status affected: c, z description: the contents of register ?f? are shifted one bit to the right through the carry flag. the msb remains unchanged. if ?d? is ? 0 ?, the result is placed in w. if ?d? is ? 1 ?, the result is stored back in reg- ister ?f?. register f c
pic16f193x/lf193x ds41364c-page 344 preliminary ? 2009 microchip technology inc. bcf bit clear f syntax: [ label ] bcf f,b operands: 0 f 127 0 b 7 operation: 0 (f) status affected: none description: bit ?b? in register ?f? is cleared. bra relative branch syntax: [ label ] bra k operands: -256 k 255 operation: (pc) + k pc status affected: none description: add the signed 9-bit literal ?k? to the pc. since the pc will have incre- mented to fetch the next instruction, the new address will be pc + 1 + k. this instruction is a two-cycle instruc- tion. brw relative branch with w syntax: [ label ] brw operands: none operation: (pc) + (w) pc status affected: none description: add the contents of w (unsigned) to the pc. since the pc will have incre- mented to fetch the next instruction, the new address will be pc + 1 + (w). this instruction is a two-cycle instruc- tion. bsf bit set f syntax: [ label ] bsf f,b operands: 0 f 127 0 b 7 operation: 1 (f) status affected: none description: bit ?b? in register ?f? is set. btfsc bit test f, skip if clear syntax: [ label ] btfsc f,b operands: 0 f 127 0 b 7 operation: skip if (f) = 0 status affected: none description: if bit ?b? in register ?f? is ? 1 ?, the next instruction is executed. if bit ?b?, in register ?f?, is ? 0 ?, the next instruction is discarded, and a nop is executed instead, making this a 2-cycle instruction. btfss bit test f, skip if set syntax: [ label ] btfss f,b operands: 0 f 127 0 b < 7 operation: skip if (f) = 1 status affected: none description: if bit ?b? in register ?f? is ? 0 ?, the next instruction is executed. if bit ?b? is ? 1 ?, then the next instruction is discarded and a nop is executed instead, making this a 2-cycle instruction.
? 2009 microchip technology inc. preliminary ds41364c-page 345 pic16f193x/lf193x call call subroutine syntax: [ label ] call k operands: 0 k 2047 operation: (pc)+ 1 tos, k pc<10:0>, (pclath<4:3>) pc<12:11> status affected: none description: call subroutine. first, return address (pc + 1) is pushed onto the stack. the eleven-bit immediate address is loaded into pc bits <10:0>. the upper bits of the pc are loaded from pclath. call is a two-cycle instruc- tion. callw subroutine call with w syntax: [ label ] callw operands: none operation: (pc) +1 tos, (w) pc<7:0>, (pclath<6:0>) pc<14:8> status affected: none description: subroutine call with w. first, the return address (pc + 1) is pushed onto the return stack. then, the con- tents of w is loaded into pc<7:0>, and the contents of pclath into pc<14:8>. callw is a two-cycle instruction. clrf clear f syntax: [ label ] clrf f operands: 0 f 127 operation: 00h (f) 1 z status affected: z description: the contents of register ?f? are cleared and the z bit is set. clrw clear w syntax: [ label ] clrw operands: none operation: 00h (w) 1 z status affected: z description: w register is cleared. zero bit (z) is set. clrwdt clear watchdog timer syntax: [ label ] clrwdt operands: none operation: 00h wdt 0 wdt prescaler, 1 to 1 pd status affected: to , pd description: clrwdt instruction resets the watch- dog timer. it also resets the prescaler of the wdt. status bits to and pd are set. comf complement f syntax: [ label ] comf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f ) (destination) status affected: z description: the contents of register ?f? are com- plemented. if ?d? is ? 0 ?, the result is stored in w. if ?d? is ? 1 ?, the result is stored back in register ?f?. decf decrement f syntax: [ label ] decf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) - 1 (destination) status affected: z description: decrement register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?.
pic16f193x/lf193x ds41364c-page 346 preliminary ? 2009 microchip technology inc. decfsz decrement f, skip if 0 syntax: [ label ] decfsz f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) - 1 (destination); skip if result = 0 status affected: none description: the contents of register ?f? are decre- mented. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. if the result is ? 1 ?, the next instruction is executed. if the result is ? 0 ?, then a nop is executed instead, making it a 2-cycle instruction. goto unconditional branch syntax: [ label ] goto k operands: 0 k 2047 operation: k pc<10:0> pclath<4:3> pc<12:11> status affected: none description: goto is an unconditional branch. the eleven-bit immediate value is loaded into pc bits <10:0>. the upper bits of pc are loaded from pclath<4:3>. goto is a two-cycle instruction. incf increment f syntax: [ label ] incf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) + 1 (destination) status affected: z description: the contents of register ?f? are incre- mented. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. incfsz increment f, skip if 0 syntax: [ label ] incfsz f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) + 1 (destination), skip if result = 0 status affected: none description: the contents of register ?f? are incre- mented. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. if the result is ? 1 ?, the next instruction is executed. if the result is ? 0 ?, a nop is executed instead, making it a 2-cycle instruction. iorlw inclusive or literal with w syntax: [ label ] iorlw k operands: 0 k 255 operation: (w) .or. k (w) status affected: z description: the contents of the w register are or?ed with the eight-bit literal ?k?. the result is placed in the w register. iorwf inclusive or w with f syntax: [ label ] iorwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) .or. (f) (destination) status affected: z description: inclusive or the w register with regis- ter ?f?. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?.
? 2009 microchip technology inc. preliminary ds41364c-page 347 pic16f193x/lf193x lslf logical left shift syntax: [ label ] lslf f {,d} operands: 0 f 127 d [0,1] operation: (f<7>) c (f<6:0>) dest<7:1> 0 dest<0> status affected: c, z description: the contents of register ?f? are shifted one bit to the left through the carry flag. a ? 0 ? is shifted into the lsb. if ?d? is ? 0 ?, the result is placed in w. if ?d? is ? 1 ?, the result is stored back in register ?f?. lsrf logical right shift syntax: [ label ] lslf f {,d} operands: 0 f 127 d [0,1] operation: 0 dest<7> (f<7:1>) dest<6:0>, (f<0>) c, status affected: c, z description: the contents of register ?f? are shifted one bit to the right through the carry flag. a ? 0 ? is shifted into the msb. if ?d? is ? 0 ?, the result is placed in w. if ?d? is ? 1 ?, the result is stored back in register ?f?. register f 0 c register f c 0 movf move f syntax: [ label ] movf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) (dest) status affected: z description: the contents of register f is moved to a destination dependent upon the status of d. if d = 0 , destination is w register. if d = 1 , the destination is file register f itself. d = 1 is useful to test a file register since status flag z is affected. words: 1 cycles: 1 example: movf fsr, 0 after instruction w = value in fsr register z= 1
pic16f193x/lf193x ds41364c-page 348 preliminary ? 2009 microchip technology inc. moviw move indfn to w syntax: [ label ] moviw ++indfn [ label ] moviw --indfn [ label ] moviw indfn++ [ label ] moviw indfn-- [ label ] moviw [k]indfn [ label ] moviw indfn operands: n [0,1] mm [00, 01, 10, 11]. -32 k 31 if not present, k = 0 . operation: indfn w effective address is determined by ? fsr + 1 (preincrement) ? fsr - 1 (predecrement) ? fsr + k (relative offset) after the move, the fsr value will be either: ? fsr + 1 (all increments) ? fsr - 1 (all decrements) ? unchanged status affected: z mm mode syntax 00 preincrement ++indfn 01 predecrement --indfn 10 postincrement indfn++ 11 postdecrement indfn-- description: this instruction is used to move data between w and one of the indirect registers (indfn). before/after this move, the pointer (fsrn) is updated by pre/post incrementing/decrementing it. fsrn is limited to the range 0000h - ffffh. incrementing/decrementing it beyond these bounds will cause it to wrap around. the increment/decrement operation on fsrn will not affect any status bits. movlb move literal to bsr syntax: [ label ] movlb k operands: 0 k 15 operation: k bsr status affected: none description: the five-bit literal ?k? is loaded into the bank select register (bsr). movlp move literal to pclath syntax: [ label ] movlp k operands: 0 k 127 operation: k pclath status affected: none description: the seven-bit literal ?k? is loaded into the pclath register. movlw move literal to w syntax: [ label ] movlw k operands: 0 k 255 operation: k (w) status affected: none description: the eight-bit literal ?k? is loaded into w register. the ?don?t cares? will assem- ble as ? 0 ?s. words: 1 cycles: 1 example: movlw 0x5a after instruction w = 0x5a movwf move w to f syntax: [ label ] movwf f operands: 0 f 127 operation: (w) (f) status affected: none description: move data from w register to register ?f?. words: 1 cycles: 1 example: movwf option before instruction option = 0xff w = 0x4f after instruction option = 0x4f w = 0x4f
? 2009 microchip technology inc. preliminary ds41364c-page 349 pic16f193x/lf193x movwi move w to indfn syntax: [ label ] movwi ++indfn [ label ] movwi --indfn [ label ] movwi indfn++ [ label ] movwi indfn-- [ label ] movwi [k]indfn [ label ] movwi indfn operands: n [0,1] mm [00, 01, 10, 11]. -32 k 31 if not present, k = 0 . operation: w indfn effective address is determined by ? fsr + 1 (preincrement) ? fsr - 1 (predecrement) ? fsr + k (relative offset) after the move, the fsr value will be either: ? fsr + 1 (all increments) ? fsr - 1 (all decrements) unchanged status affected: none mm mode syntax 00 preincrement ++indfn 01 predecrement --indfn 10 postincrement indfn++ 11 postdecrement indfn-- description: this instruction is used to move data between w and one of the indirect registers (indfn). before/after this move, the pointer (fsrn) is updated by pre/post incrementing/decrementing it. fsrn is limited to the range 0000h - ffffh. incrementing/decrementing it beyond these bounds will cause it to wrap around. the increment/decrement operation on fsrn will not affect any status bits. nop no operation syntax: [ label ] nop operands: none operation: no operation status affected: none description: no operation. words: 1 cycles: 1 example: nop option load option_reg register with w syntax: [ label ] option operands: none operation: (w) option_reg status affected: none description: move data from w register to option_reg register. reset software reset syntax: [ label ] reset operands: none operation: execute a device reset. resets the nri flag of the pcon register. status affected: none description: this instruction provides a way to execute a hardware reset by soft- ware.
pic16f193x/lf193x ds41364c-page 350 preliminary ? 2009 microchip technology inc. retfie return from interrupt syntax: [ label ] retfie operands: none operation: tos pc, 1 gie status affected: none description: return from interrupt. stack is poped and top-of-stack (tos) is loaded in the pc. interrupts are enabled by setting global interrupt enable bit, gie (intcon<7>). this is a two-cycle instruction. words: 1 cycles: 2 example: retfie after interrupt pc = tos gie = 1 retlw return with literal in w syntax: [ label ] retlw k operands: 0 k 255 operation: k (w); tos pc status affected: none description: the w register is loaded with the eight bit literal ?k?. the program counter is loaded from the top of the stack (the return address). this is a two-cycle instruction. words: 1 cycles: 2 example: table call table;w contains table ;offset value ? ;w now has table value ? ? addwf pc ;w = offset retlw k1 ;begin table retlw k2 ; ? ? ? retlw kn ; end of table before instruction w = 0x07 after instruction w = value of k8 return return from subroutine syntax: [ label ] return operands: none operation: tos pc status affected: none description: return from subroutine. the stack is poped and the top of the stack (tos) is loaded into the program counter. this is a two-cycle instruction. rlf rotate left f through carry syntax: [ label ] rlf f,d operands: 0 f 127 d [ 0 , 1 ] operation: see description below status affected: c description: the contents of register ?f? are rotated one bit to the left through the carry flag. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f?. words: 1 cycles: 1 example: rlf reg1,0 before instruction reg1 = 1110 0110 c=0 after instruction reg1 = 1110 0110 w = 1100 1100 c=1 register f c
? 2009 microchip technology inc. preliminary ds41364c-page 351 pic16f193x/lf193x rrf rotate right f through carry syntax: [ label ] rrf f,d operands: 0 f 127 d [ 0 , 1 ] operation: see description below status affected: c description: the contents of register ?f? are rotated one bit to the right through the carry flag. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed back in register ?f?. sleep enter sleep mode syntax: [ label ]sleep operands: none operation: 00h wdt, 0 wdt prescaler, 1 to , 0 pd status affected: to , pd description: the power-down status bit, pd is cleared. time-out status bit, to is set. watchdog timer and its pres- caler are cleared. the processor is put into sleep mode with the oscillator stopped. register f c sublw subtract w from literal syntax: [ label ]sublw k operands: 0 k 255 operation: k - (w) ( w) status affected: c, dc, z description: the w register is subtracted (2?s com- plement method) from the eight-bit literal ?k?. the result is placed in the w register. subwf subtract w from f syntax: [ label ] subwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f) - (w) ( destination) status affected: c, dc, z description: subtract (2?s complement method) w register from register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in register ?f. subwfb subtract w from f with borrow syntax: subwfb f {,d} operands: 0 f 127 d [0,1] operation: (f) ? (w) ? (b ) dest status affected: c, dc, z description: subtract w and the borrow flag (carry) from register ?f? (2?s comple- ment method). if ?d? is ? 0 ?, the result is stored in w. if ?d? is ? 1 ?, the result is stored back in register ?f?. c = 0 w > k c = 1 w k dc = 0 w<3:0> > k<3:0> dc = 1 w<3:0> k<3:0> c = 0 w > f c = 1 w f dc = 0 w<3:0> > f<3:0> dc = 1 w<3:0> f<3:0>
pic16f193x/lf193x ds41364c-page 352 preliminary ? 2009 microchip technology inc. swapf swap nibbles in f syntax: [ label ] swapf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (f<3:0>) (destination<7:4>), (f<7:4>) (destination<3:0>) status affected: none description: the upper and lower nibbles of regis- ter ?f? are exchanged. if ?d? is ? 0 ?, the result is placed in the w register. if ?d? is ? 1 ?, the result is placed in register ?f?. tris load tris register with w syntax: [ label ] tris f operands: 5 f 7 operation: (w) tris register ?f? status affected: none description: move data from w register to tris register. when ?f? = 5, trisa is loaded. when ?f? = 6, trisb is loaded. when ?f? = 7, trisc is loaded. xorlw exclusive or literal with w syntax: [ label ] xorlw k operands: 0 k 255 operation: (w) .xor. k ( w) status affected: z description: the contents of the w register are xor?ed with the eight-bit literal ?k?. the result is placed in the w register. xorwf exclusive or w with f syntax: [ label ] xorwf f,d operands: 0 f 127 d [ 0 , 1 ] operation: (w) .xor. (f) ( destination) status affected: z description: exclusive or the contents of the w register with register ?f?. if ?d? is ? 0 ?, the result is stored in the w register. if ?d? is ? 1 ?, the result is stored back in regis- ter ?f?.
? 2009 microchip technology inc. preliminary ds41364c-page 353 pic16f193x/lf193x 27.0 development support the pic ? microcontrollers are supported with a full range of hardware and software development tools: ? integrated development environment - mplab ? ide software ? assemblers/compilers/linkers - mpasm tm assembler - mplab c18 and mplab c30 c compilers -mplink tm object linker/ mplib tm object librarian - mplab asm30 assembler/linker/library ? simulators - mplab sim software simulator ?emulators - mplab ice 2000 in-circuit emulator - mplab real ice? in-circuit emulator ? in-circuit debugger - mplab icd 2 ? device programmers - picstart ? plus development programmer - mplab pm3 device programmer - pickit? 2 development programmer ? low-cost demonstration and development boards and evaluation kits 27.1 mplab integrated development environment software the mplab ide software brings an ease of software development previously unseen in the 8/16-bit micro- controller market. the mplab ide is a windows ? operating system-based application that contains: ? a single graphical interface to all debugging tools - simulator - programmer (sold separately) - emulator (sold separately) - in-circuit debugger (sold separately) ? a full-featured editor with color-coded context ? a multiple project manager ? customizable data windows with direct edit of contents ? high-level source code debugging ? visual device initializer for easy register initialization ? mouse over variable inspection ? drag and drop variables from source to watch windows ? extensive on-line help ? integration of select third party tools, such as hi-tech software c compilers and iar c compilers the mplab ide allows you to: ? edit your source files (either assembly or c) ? one touch assemble (or compile) and download to pic mcu emulator and simulator tools (automatically updates all project information) ? debug using: - source files (assembly or c) - mixed assembly and c - machine code mplab ide supports multiple debugging tools in a single development paradigm, from the cost-effective simulators, through low-cost in-circuit debuggers, to full-featured emulators. this eliminates the learning curve when upgrading to tools with increased flexibility and power.
pic16f193x/lf193x ds41364c-page 354 preliminary ? 2009 microchip technology inc. 27.2 mpasm assembler the mpasm assembler is a full-featured, universal macro assembler for all pic mcus. the mpasm assembler generates relocatable object files for the mplink object linker, intel ? standard hex files, map files to detail memory usage and symbol reference, absolute lst files that contain source lines and generated machine code and coff files for debugging. the mpasm assembler features include: ? integration into mplab ide projects ? user-defined macros to streamline assembly code ? conditional assembly for multi-purpose source files ? directives that allow complete control over the assembly process 27.3 mplab c18 and mplab c30 c compilers the mplab c18 and mplab c30 code development systems are complete ansi c compilers for microchip?s pic18 and pic24 families of microcon- trollers and the dspic30 and dspic33 family of digital signal controllers. these compilers provide powerful integration capabilities, superior code optimization and ease of use not found with other compilers. for easy source level debugging, the compilers provide symbol information that is optimized to the mplab ide debugger. 27.4 mplink object linker/ mplib object librarian the mplink object linker combines relocatable objects created by the mpasm assembler and the mplab c18 c compiler. it can link relocatable objects from precompiled libraries, using directives from a linker script. the mplib object librarian manages the creation and modification of library files of precompiled code. when a routine from a library is called from a source file, only the modules that contain that routine will be linked in with the application. this allows large libraries to be used efficiently in many different applications. the object linker/library features include: ? efficient linking of single libraries instead of many smaller files ? enhanced code maintainability by grouping related modules together ? flexible creation of libraries with easy module listing, replacement, deletion and extraction 27.5 mplab asm30 assembler, linker and librarian mplab asm30 assembler produces relocatable machine code from symbolic assembly language for dspic30f devices. mplab c30 c compiler uses the assembler to produce its object file. the assembler generates relocatable object files that can then be archived or linked with other relocatable object files and archives to create an executable file. notable features of the assembler include: ? support for the entire dspic30f instruction set ? support for fixed-point and floating-point data ? command line interface ? rich directive set ? flexible macro language ? mplab ide compatibility 27.6 mplab sim software simulator the mplab sim software simulator allows code development in a pc-hosted environment by simulat- ing the pic mcus and dspic ? dscs on an instruction level. on any given instruction, the data areas can be examined or modified and stimuli can be applied from a comprehensive stimulus controller. registers can be logged to files for further run-time analysis. the trace buffer and logic analyzer display extend the power of the simulator to record and track program execution, actions on i/o, most peripherals and internal registers. the mplab sim software simulator fully supports symbolic debugging using the mplab c18 and mplab c30 c compilers, and the mpasm and mplab asm30 assemblers. the software simulator offers the flexibility to develop and debug code outside of the hardware laboratory environment, making it an excellent, economical software development tool.
? 2009 microchip technology inc. preliminary ds41364c-page 355 pic16f193x/lf193x 27.7 mplab ice 2000 high-performance in-circuit emulator the mplab ice 2000 in-circuit emulator is intended to provide the product development engineer with a complete microcontroller design tool set for pic microcontrollers. software control of the mplab ice 2000 in-circuit emulator is advanced by the mplab integrated development environment, which allows editing, building, downloading and source debugging from a single environment. the mplab ice 2000 is a full-featured emulator system with enhanced trace, trigger and data monitor- ing features. interchangeable processor modules allow the system to be easily reconfigured for emulation of different processors. the architecture of the mplab ice 2000 in-circuit emulator allows expansion to support new pic microcontrollers. the mplab ice 2000 in-circuit emulator system has been designed as a real-time emulation system with advanced features that are typically found on more expensive development tools. the pc platform and microsoft ? windows ? 32-bit operating system were chosen to best make these features available in a simple, unified application. 27.8 mplab real ice in-circuit emulator system mplab real ice in-circuit emulator system is microchip?s next generation high-speed emulator for microchip flash dsc and mcu devices. it debugs and programs pic ? flash mcus and dspic ? flash dscs with the easy-to-use, powerful graphical user interface of the mplab integrated development environment (ide), included with each kit. the mplab real ice probe is connected to the design engineer?s pc using a high-speed usb 2.0 interface and is connected to the target with either a connector compatible with the popular mplab icd 2 system (rj11) or with the new high-speed, noise tolerant, low- voltage differential signal (lvds) interconnection (cat5). mplab real ice is field upgradeable through future firmware downloads in mplab ide. in upcoming releases of mplab ide, new devices will be supported, and new features will be added, such as software break- points and assembly code trace. mplab real ice offers significant advantages over competitive emulators including low-cost, full-speed emulation, real-time variable watches, trace analysis, complex breakpoints, a ruggedized probe interface and long (up to three meters) interconnection cables. 27.9 mplab icd 2 in-circuit debugger microchip?s in-circuit debugger, mplab icd 2, is a powerful, low-cost, run-time development tool, connecting to the host pc via an rs-232 or high-speed usb interface. this tool is based on the flash pic mcus and can be used to develop for these and other pic mcus and dspic dscs. the mplab icd 2 utilizes the in-circuit debugging capability built into the flash devices. this feature, along with microchip?s in-circuit serial programming tm (icsp tm ) protocol, offers cost- effective, in-circuit flash debugging from the graphical user interface of the mplab integrated development environment. this enables a designer to develop and debug source code by setting breakpoints, single step- ping and watching variables, and cpu status and peripheral registers. running at full speed enables testing hardware and applications in real time. mplab icd 2 also serves as a development programmer for selected pic devices. 27.10 mplab pm3 device programmer the mplab pm3 device programmer is a universal, ce compliant device programmer with programmable voltage verification at v ddmin and v ddmax for maximum reliability. it features a large lcd display (128 x 64) for menus and error messages and a modu- lar, detachable socket assembly to support various package types. the icsp? cable assembly is included as a standard item. in stand-alone mode, the mplab pm3 device programmer can read, verify and program pic devices without a pc connection. it can also set code protection in this mode. the mplab pm3 connects to the host pc via an rs-232 or usb cable. the mplab pm3 has high-speed communications and optimized algorithms for quick programming of large memory devices and incorporates an sd/mmc card for file storage and secure data applications.
pic16f193x/lf193x ds41364c-page 356 preliminary ? 2009 microchip technology inc. 27.11 picstart plus development programmer the picstart plus development programmer is an easy-to-use, low-cost, prototype programmer. it connects to the pc via a com (rs-232) port. mplab integrated development environment software makes using the programmer simple and efficient. the picstart plus development programmer supports most pic devices in dip packages up to 40 pins. larger pin count devices, such as the pic16c92x and pic17c76x, may be supported with an adapter socket. the picstart plus development programmer is ce compliant. 27.12 pickit 2 development programmer the pickit? 2 development programmer is a low-cost programmer and selected flash device debugger with an easy-to-use interface for programming many of microchip?s baseline, mid-range and pic18f families of flash memory microcontrollers. the pickit 2 starter kit includes a prototyping development board, twelve sequential lessons, software and hi-tech?s picc? lite c compiler, and is designed to help get up to speed quickly using pic ? microcontrollers. the kit provides everything needed to program, evaluate and develop applications using microchip?s powerful, mid-range flash memory family of microcontrollers. 27.13 demonstration, development and evaluation boards a wide variety of demonstration, development and evaluation boards for various pic mcus and dspic dscs allows quick application development on fully func- tional systems. most boards include prototyping areas for adding custom circuitry and provide application firmware and source code for examination and modification. the boards support a variety of features, including leds, temperature sensors, switches, speakers, rs-232 interfaces, lcd displays, potentiometers and additional eeprom memory. the demonstration and development boards can be used in teaching environments, for prototyping custom circuits and for learning about various microcontroller applications. in addition to the picdem? and dspicdem? demon- stration/development board series of circuits, microchip has a line of evaluation kits and demonstration software for analog filter design, k ee l oq ? security ics, can, irda ? , powersmart battery management, seeval ? evaluation system, sigma-delta adc, flow rate sensing, plus many more. check the microchip web page (www.microchip.com) for the complete list of demonstration, development and evaluation kits.
? 2009 microchip technology inc. preliminary ds41364c-page 357 pic16f193x/lf193x 28.0 electrical specifications absolute maximum ratings (?) ambient temperature under bias................................................................................................. ...... -40c to +125c storage temperature ............................................................................................................ ............ -65c to +150c voltage on v dd with respect to v ss , pic16f193x ............................................................................. -0.3v to +6.5v voltage on v cap pin with respect to v ss , pic16f193x ....................................................................... -0.3v to +4.0v voltage on v dd with respect to v ss , pic16lf193x ........................................................................... -0.3v to +4.0v voltage on mclr with respect to vss ................................................................................................. -0.3v to +9.0v voltage on all other pins with respect to v ss ........................................................................... -0.3v to (v dd + 0.3v) total power dissipation (1) ............................................................................................................................... 800 mw maximum current out of v ss pin ...................................................................................................................... 95 m a maximum current into v dd pin ......................................................................................................................... 7 0 ma clamp current, i k (v pin < 0 or v pin > v dd ) ............................................................... ................................................. 20 ma maximum output current sunk by any i/o pin..................................................................................... ............... 25 ma maximum output current sourced by any i/o pin .................................................................................. ............ 25 ma maximum current sunk by all ports (2) , -40c t a +85c for industrial ........................................................ 200 ma maximum current sunk by all ports (2) , -40c t a +125c for extended........................................................ 90 ma maximum current sourced by all ports (2) , 40c t a +85c for industrial ................................................... 140 ma maximum current sourced by all ports (2) , -40c t a +125c for extended................................................... 65 ma note 1: power dissipation is calculated as follows: p dis = v dd x {i dd ? i oh } + {(v dd ? v oh ) x i oh } + (v o l x i ol ). ? notice: stresses above those listed under ?absolute maximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure above maximum rating conditions for extended periods may affect device reliability.
pic16f193x/lf193x ds41364c-page 358 preliminary ? 2009 microchip technology inc. figure 28-1: pic16f193x voltage frequency graph, -40c t a +125c figure 28-2: pic16lf193x volt age frequency graph, -40c t a +125c 1.8 2.5 2.0 0 2.3 frequency (mhz) v dd (v) note 1: the shaded region indicates the permissible combinations of voltage and frequency. 2: refer to table 28-1 for each oscillator mode?s supported frequencies. 432 10 16 5.5 3.6 1.8 2.5 2.0 0 2.3 frequency (mhz) v dd (v) note 1: the shaded region indicates the permissible combinations of voltage and frequency. 2: refer to table 28-1 for each oscillator mode?s supported frequencies. 432 10 16 3.6
? 2009 microchip technology inc. preliminary ds41364c-page 359 pic16f193x/lf193x figure 28-3: hfintosc frequency accuracy over device v dd and temperature 125 25 2.0 0 60 85 v dd (v) 4.0 5.0 4.5 temperature ( c ) 2.5 3.0 3.5 5.5 1.8 -40 -20 + 5% 2% + 5%
pic16f193x/lf193x ds41364c-page 360 preliminary ? 2009 microchip technology inc. 28.1 dc characteristics: pic16f193x/lf193x-i/e (industrial, extended) pic16lf193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended pic16f193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param. no. sym. characteristic min. typ? max. units conditions d001 v dd supply voltage pic16lf193x 1.8 2.3 ? ? 3.6 3.6 v v f osc 16 mhz: f osc 32 mhz ( note 2 ) d001 pic16f193x 1.8 2.3 ? ? 5.5 5.5 v v f osc 16 mhz: f osc 32 mhz ( note 2 ) d002* v dr ram data retention voltage (1) pic16lf193x 1.5 ? ? v device in sleep mode d002* pic16f193x 1.7 ? ? v device in sleep mode v por * power-on reset release voltage ?1.6? v v porr * power-on reset rearm voltage pic16lf193x ? 0.8 ? v device in sleep mode pic16f193x ? 1.7 ? v device in sleep mode d003 v adfvr fixed voltage reference voltage for adc, initial accuracy 6 7 7 8 7 8 4 4 6 6 4 4 % 1.024v, v dd 1.8v, 85c 1.024v, v dd 1.8v, 125c 2.048v, v dd 2.5v, 85c 2.048v, v dd 2.5v, 125c 4.096v, v dd 4.75v, 85c 4.096v, v dd 4.75v, 125c d003a v cdafvr fixed voltage reference voltage for comparator and dac, initial accuracy 7 8 8 9 8 8 5 5 7 7 4 4 % 1.024v, v dd 1.8v, 85c 1.024v, v dd 1.8v, 125c 2.048v, v dd 2.5v, 85c 2.048v, v dd 2.5v, 125c 4.096v, v dd 4.75v, 85c 4.096v, v dd 4.75v, 125c d003b v lcdfvr fixed voltage reference voltage for lcd bias, initial accuracy 9 9.5 9 9 % 3.072v, v dd 3.6v, 85c 3.072v, v dd 3.6v, 125c d003c* tcv fvr temperature coefficient, fixed voltage reference ? -130 ? ppm/c d003d* v fvr / v in line regulation, fixed voltage ref- erence ? 0.270 ? %/v d004* s vdd v dd rise rate to ensure internal power-on reset signal 0.05 ? ? v/ms see section 3.2 ?power-on reset (por)? for details. * these parameters are characterized but not tested. ? data in ?typ? column is at 3.3v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: this is the limit to which v dd can be lowered in sleep mode without losing ram data. 2: pll required for 32 mhz operation.
? 2009 microchip technology inc. preliminary ds41364c-page 361 pic16f193x/lf193x figure 28-4: por and por rearm with slow rising v dd v dd v por v porr v ss v ss npor t por (3) por rearm note 1: when npor is low, the device is held in reset. 2: t por 1 s typical. 3: t vlow 2.7 s typical. t vlow (2)
pic16f193x/lf193x ds41364c-page 362 preliminary ? 2009 microchip technology inc. 28.2 dc characteristics: pic16f193x/lf193x-i/e (industrial, extended) pic16lf193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended pic16f193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. device characteristics min. typ? max. units conditions v dd note supply current (i dd ) (1, 2) d009 ldo regulator ? 350 ? a ? hs, ec or intosc/intoscio (8-16 mh z ) clock modes with all v cap pins disabled ? 50 ? a ? all v cap pins disabled ? 30 ? a ? v cap enabled on ra0, ra5 or ra6 ? 5 ? a ? lp clock mode and sleep (requires fvr and bor to be disabled) d010 ? 7.0 16 a1.8f osc = 32 khz lp oscillator mode (note 4) , -40c t a +85c ?9.0 20 a3.0 d010 ? 24 40 a 1.8 f osc = 32 khz lp oscillator mode (note 4, 5) , -40c t a +85c ? 30 45 a 3.0 ? 32 50 a 5.0 d010a ? 7.0 ? a1.8 f osc = 32 khz lp oscillator mode (note 4) -40c t a +125c ?9.0 ? a3.0 d010a ? 24 ? a 1.8 f osc = 32 khz lp oscillator mode (note 4, 5) -40c t a +125c ? 30 ? a 3.0 ? 32 ? a 5.0 d011 ? 150 200 a1.8f osc = 1 mhz xt oscillator mode ? 270 325 a3.0 d011 ? 160 255 a 1.8 f osc = 1 mhz xt oscillator mode (note 5) ? 280 475 a 3.0 ? 390 690 a 5.0 d012 ? 430 495 a1.8f osc = 4 mhz xt oscillator mode ? 750 1000 a3.0 d012 ? 450 645 a 1.8 f osc = 4 mhz xt oscillator mode (note 5) ? 770 1100 a 3.0 ? 930 1320 a 5.0 legend: tbd = to be determined note 1: the test conditions for all i dd measurements in active operation mode ar e: osc1 = external square wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. 2: the supply current is mainly a function of the operating voltage and frequency. other factors, such as i/o pin loading and switching rate, oscillator type, internal code execution pa ttern and temperature, also have an impact on the current consumption. 3: for rc oscillator configurations, current through r ext is not included. the current through the resistor can be extended by the formula i r = v dd /2r ext (ma) with r ext in k . 4: fvr and bor are disabled. 5: 0.1 f capacitor on v cap (ra0). 6: 8 mhz crystal oscillator with 4x pll enabled.
? 2009 microchip technology inc. preliminary ds41364c-page 363 pic16f193x/lf193x supply current (i dd ) (1, 2) d013 ? 90 125 a1.8f osc = 500 khz ec oscillator low-power mode ? 170 200 a3.0 d013 ? 100 180 a 1.8 f osc = 500 khz ec oscillator low-power mode (note 5) ? 180 310 a 3.0 ? 225 350 a 5.0 d014 ? 450 650 a1.8f osc = 4 mhz ec oscillator mode medium power mode ? 830 1100 a3.0 d014 ? 475 735 a 1.8 f osc = 4 mhz ec oscillator mode (note 5) medium power mode ? 850 1200 a 3.0 ? 980 1390 a 5.0 d015 ? 5.3 7.3 ma 3.0 f osc = 32 mhz ec oscillator high-power mode ?6.0 8.0 ma 3.6 d015 ? 5.3 7.3 ma 3.0 f osc = 32 mhz ec oscillator high-power mode (note 5) ? 6.0 8.0 ma 5.0 d016 ? 5 12 a1.8f osc = 32 khz lfintosc mode, 85c ?8 16 a3.0 d016 ? 21 35 a 1.8 f osc = 32 khz lfintosc mode, 85c (note 5) ? 27 40 a 3.0 ? 28 45 a 5.0 28.2 dc characteristics: pic16f193x/lf193x-i/e (industrial, extended) (continued) pic16lf193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended pic16f193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. device characteristics min. typ? max. units conditions v dd note legend: tbd = to be determined note 1: the test conditions for all i dd measurements in active operation mode are: osc1 = external square wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. 2: the supply current is mainly a function of the operating voltage and frequency. other factors, such as i/o pin loading and switching rate, oscillator type, internal code execution pa ttern and temperature, also have an impact on the current consumption. 3: for rc oscillator configurations, current through r ext is not included. the current through the resistor can be extended by the formula i r = v dd /2r ext (ma) with r ext in k . 4: fvr and bor are disabled. 5: 0.1 f capacitor on v cap (ra0). 6: 8 mhz crystal oscillator with 4x pll enabled.
pic16f193x/lf193x ds41364c-page 364 preliminary ? 2009 microchip technology inc. d017 ? 130 175 a1.8f osc = 500 khz mfintosc mode ? 190 250 a3.0 d017 ? 150 250 a 1.8 f osc = 500 khz mfintosc mode (note 5) ? 210 345 a 3.0 ? 270 425 a 5.0 d018 ? 980 1300 a1.8f osc = 8 mhz hfintosc mode ? 1780 2000 a3.0 d018 ? 1.0 1.48 ma 1.8 f osc = 8 mhz hfintosc mode (note 5) ? 1.8 2.2 ma 3.0 ? 2.0 2.8 ma 5.0 d019 ? 1.5 2 ma 1.8 f osc = 16 mhz hfintosc mode ?2.8 3.5 ma 3.0 d019 ? 1.7 2.23 ma 1.8 f osc = 16 mhz hfintosc mode (note 5) ? 2.9 4.3 ma 3.0 ? 3.1 4.6 ma 5.0 d020 ? 410 550 a1.8f osc = 4 mhz extrc mode (note 3, note 5) ? 710 950 a3.0 d020 ? 430 695 a 1.8 f osc = 4 mhz extrc mode (note 3, note 5) ? 730 1060 a 3.0 ? 860 1350 a 5.0 d021 ? 5.3 7.3 ma 3.0 f osc = 32 mhz hs oscillator mode (note 6) ?6.0 8.0 ma 3.6 d021 ? 5.3 7.3 ma 3.0 f osc = 32 mhz hs oscillator mode (note 5, note 6) ? 6.0 8.0 ma 5.0 28.2 dc characteristics: pic16f193x/lf193x-i/e (industrial, extended) (continued) pic16lf193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended pic16f193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. device characteristics min. typ? max. units conditions v dd note legend: tbd = to be determined note 1: the test conditions for all i dd measurements in active operation mode ar e: osc1 = external square wave, from rail-to-rail; all i/o pins tri-stated, pulled to v dd ; mclr = v dd ; wdt disabled. 2: the supply current is mainly a function of the operating voltage and frequency. other factors, such as i/o pin loading and switching rate, oscillator type, internal code execution pa ttern and temperature, also have an impact on the current consumption. 3: for rc oscillator configurations, current through r ext is not included. the current through the resistor can be extended by the formula i r = v dd /2r ext (ma) with r ext in k . 4: fvr and bor are disabled. 5: 0.1 f capacitor on v cap (ra0). 6: 8 mhz crystal oscillator with 4x pll enabled.
? 2009 microchip technology inc. preliminary ds41364c-page 365 pic16f193x/lf193x 28.3 dc characteristics: pic16f193x/lf193x-i/e (power-down) pic16lf193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended pic16f193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. device characteristics min. typ? max. +85c max. +125c units conditions v dd note power-down base current (i pd ) (2) d023 ? 0.06 1 ? a 1.8 wdt, bor, fvr, and t1osc disabled, all peripherals inactive ?0.08 2 ? a3.0 d023 ? 15 35 ? a 1.8 wdt, bor, fvr, and t1osc disabled, all peripherals inactive ? 18 40 ? a 3.0 ? 19 45 ? a 5.0 d024 ? 0.5 6 ? a 1.8 lpwdt current (note 1) ?0.8 7 ? a3.0 d024 ? 16 35 ? a 1.8 lpwdt current (note 1) ? 19 40 ? a 3.0 ? 20 45 ? a 5.0 d025 ? 8.5 23 ? a 1.8 fvr current (note 3) ?8.5 26 ? a3.0 d025 ? 32 50 ? a 1.8 fvr current (note 3, note 5) ? 39 72 ? a 3.0 ? 70 120 ? a 5.0 d026 ? 7.5 tbd ? a 3.0 bor current (note 1, note 3) d026 ? 34 57 ? a 3.0 bor current (note 1, note 3, note 5) ? 67 100 ? a 5.0 d027 ? 0.6 5 ? a 1.8 t1osc current (note 1) ?1.8 6 ? a3.0 d027 ? 16 35 ? a 1.8 t1osc current (note 1) ? 21 40 ? a 3.0 ? 25 45 ? a 5.0 * these parameters are char acterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. legend: tbd = to be determined note 1: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 2: the power-down current in sleep mode does not depend on the oscillator type. power-down current is measured with the part in sleep mode, with all i/o pins in high-impedance state and tied to v dd . 3: fixed voltage reference is automatic ally enabled whenever the bor is enabled. 4: a/d oscillator source is f rc . 5: 0.1 f capacitor on v cap (ra0).
pic16f193x/lf193x ds41364c-page 366 preliminary ? 2009 microchip technology inc. power-down base current (i pd ) (2) d028 ? 0.1 5 ? a 1.8 a/d current (note 1, note 4) , no conversion in progress ?0.1 6 ? a3.0 d028 ? 16 35 ? a 1.8 a/d current (note 1, note 4) , no conversion in progress ? 21 40 ? a 3.0 ? 25 50 ? a 5.0 d029 ? 250 ? ? a 1.8 a/d current (note 1, note 4) , conversion in progress ?250 ? ? a3.0 d029 ? 280 ? ? a 1.8 a/d current (note 1, note 4, note 5) , conversion in progress ? 280 ? ? a 3.0 ? 280 ? ? a 5.0 d030 ? 3.5 7 ? a 1.8 cap sense, low power mode ?7 9 ? a3.0 d030 ? 17 38 ? a 1.8 cap sense, low power mode ? 21 50 ? a 3.0 ? 22 70 ? a 5.0 d031 ? 1 ? ? a 3.6 lcd bias ladder, low-power ?10 ? ? a3.6 lcd bias ladder, medium-power ?100 ? ? a3.6 lcd bias ladder, high-power d031 ? 1 ? ? a 5.0 lcd bias ladder, low-power ? 10 ? ? a 5.0 lcd bias ladder, medium-power ? 100 ? ? a 5.0 lcd bias ladder, high-power 28.3 dc characteristics: pic16f193x/lf193x-i/e (power-down) (continued) pic16lf193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended pic16f193x standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. device characteristics min. typ? max. +85c max. +125c units conditions v dd note * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. legend: tbd = to be determined note 1: the peripheral current is the sum of the base i dd or i pd and the additional current consumed when this peripheral is enabled. the peripheral current can be determined by subtracting the base i dd or i pd current from this limit. max values should be used when calculating total current consumption. 2: the power-down current in sleep mode does not depend on the oscillator type. power-down current is measured with the part in sleep mode, with all i/o pins in high-impedance state and tied to v dd . 3: fixed voltage reference is automatic ally enabled whenever the bor is enabled. 4: a/d oscillator source is f rc . 5: 0.1 f capacitor on v cap (ra0).
? 2009 microchip technology inc. preliminary ds41364c-page 367 pic16f193x/lf193x 28.4 dc characteristics: pic16f193x/lf193x-i/e dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. sym. characteristic min. typ? max. units conditions v il input low voltage i/o port: d032 with ttl buffer ? ? 0.8 v 4.5v v dd 5.5v d032a ? ? 0.15 v dd v1.8v v dd 4.5v d033 with schmitt trigger buffer ? ? 0.2 v dd v2.0v v dd 5.5v with i 2 c? levels ? ? 0.3 v dd v with smbus? levels ? ? 0.8 v 2.7v v dd 5.5v d034 mclr , osc1 (rc mode) (1) ??0.2v dd v d034a osc1 (hs mode) ? ? 0.3 v dd v v ih input high voltage i/o ports: ? ? d040 with ttl buffer 2.0 ? ? v 4.5v v dd 5.5v d040a 0.25 v dd + 0.8 ??v1.8v v dd 4.5v d041 with schmitt trigger buffer 0.8 v dd ??v2.0v v dd 5.5v with i 2 c? levels 0.7 v dd ??v with smbus? levels 2.1 ? ? v 2.7v v dd 5.5v d042 mclr 0.8 v dd ??v d043a osc1 (hs mode) 0.7 v dd ??v d043b osc1 (rc mode) 0.9 v dd ??v (note 1) i il input leakage current (2) d060 i/o ports ? 5 5 125 1000 na na v ss v pin v dd , pin at high- impedance @ 85c 125c d061 mclr (3) ? 50 200nav ss v pin v dd @ 85c i pur weak pull-up current d070* 25 25 100 140 200 300 a v dd = 3.3v, v pin = v ss v dd = 5.0v, v pin = v ss v ol output low voltage (4) d080 i/o ports ??0.6v i ol = 8ma, v dd = 5v i ol = 6ma, v dd = 3.3v i ol = 1.8ma, v dd = 1.8v v oh output high voltage (4) d090 i/o ports v dd - 0.7 ? ? v i oh = 3.5ma, v dd = 5v i oh = 3ma, v dd = 3.3v i oh = 1ma, v dd = 1.8v legend: tbd = to be determined * these parameters are char acterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1/clkin pin is a schm itt trigger input. it is not recommended to use an external clock in rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages. 4: including osc2 in clkout mode.
pic16f193x/lf193x ds41364c-page 368 preliminary ? 2009 microchip technology inc. capacitive loading specs on output pins d101* cosc2 osc2 pin ? ? 15 pf in xt, hs and lp modes when external clock is used to drive osc1 d101a* c io all i/o pins ? ? 50 pf v cap capacitor charging d102 charging current ? 200 ? a d102a source/sink capability when charging complete ?0.0?ma 28.4 dc characteristics: pic16f193x/lf193x-i/e (continued) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +85c for industrial -40c t a +125c for extended param no. sym. characteristic min. typ? max. units conditions legend: tbd = to be determined * these parameters ar e characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: in rc oscillator configuration, the osc1/clkin pin is a schm itt trigger input. it is not recommended to use an external clock in rc mode. 2: negative current is defined as current sourced by the pin. 3: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages. 4: including osc2 in clkout mode.
? 2009 microchip technology inc. preliminary ds41364c-page 369 pic16f193x/lf193x 28.5 memory programming requirements dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions program memory programming specifications d110 v ihh voltage on mclr /v pp /re3 pin 8.0 ? 9.0 v (note 3, note 4) d111 i ddp supply current during programming ??10ma d112 v dd for bulk erase 2.7 ? v dd max. v d113 v pew v dd for write or row erase v dd min. ?v dd max. v d114 i pppgm current on mclr /v pp during erase/ write ??1.0ma d115 i ddpgm current on v dd during erase/write ? 5.0 ma data eeprom memory d116 e d byte endurance 100k ? ?e/w-40 c to +85 c d117 v drw v dd for read/write v dd min. ?v dd max. v d118 t dew erase/write cycle time ? 4.0 5.0 ms d119 t retd characteristic retention 40 ? ? year provided no other specifications are violated d120 t ref number of total erase/write cycles before refresh (2) 1m 10m ? e/w -40c to +85c program flash memory d121 e p cell endurance 10k ? ?e/w-40 c to +85 c ( note 1 ) d122 v pr v dd for read v dd min. ?v dd max. v d123 t iw self-timed write cycle time ? 2 2.5 ms d124 t retd characteristic retention 40 ? ? year provided no other specifications are violated ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: self-write and block erase. 2: refer to section 23.5.1 ?using the data eeprom? for a more detailed discussion on data eeprom endurance. 3: required only if single-supply programming is disabled. 4: the mplab icd 2 does not support variable v pp output. circuitry to limit the icd 2 v pp voltage must be placed between the icd 2 and target system when programming or debugging with the icd 2.
pic16f193x/lf193x ds41364c-page 370 preliminary ? 2009 microchip technology inc. 28.6 thermal considerations standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic typ. units conditions th01 ja thermal resistance junction to ambient 60 c/w 28-pin spdip package 80 c/w 28-pin soic package 90 c/w 28-pin ssop package 27.5 c/w 28-pin uqfn 4x4mm package 27.5 c/w 28-pin qfn 6x6mm package 47.2 c/w 40-pin pdip package 46 c/w 44-pin tqfp package 24.4 c/w 44-pin qfn 8x8mm package th02 jc thermal resistance junction to case 31.4 c/w 28-pin spdip package 24 c/w 28-pin soic package 24 c/w 28-pin ssop package 24 c/w 28-pin uqfn 4x4mm package 24 c/w 28-pin qfn 6x6mm package 24.7 c/w 40-pin pdip package 14.5 c/w 44-pin tqfp package 20 c/w 44-pin qfn 8x8mm package th03 t jmax maximum junction temperature 150 c th04 pd power dissipation ? w pd = p internal + p i / o th05 p internal internal power dissipation ? w p internal = i dd x v dd (1) th06 p i / o i/o power dissipation ? w p i / o = (i ol * v ol ) + (i oh * (v dd - v oh )) th07 p der derated power ? w p der = pd max (t j - t a )/ ja (2) note 1: i dd is current to run the chip alone without driving any load on the output pins. 2: t a = ambient temperature 3: t j = junction temperature
? 2009 microchip technology inc. preliminary ds41364c-page 371 pic16f193x/lf193x 28.7 timing parameter symbology the timing parameter symbols have been created with one of the following formats: figure 28-5: load conditions 1. tpps2pps 2. tpps t f frequency t time lowercase letters (pp) and their meanings: pp cc ccp1 osc osc1 ck clkout rd rd cs cs rw rd or wr di sdi sc sck do sdo ss ss dt data in t0 t0cki io i/o port t1 t1cki mc mclr wr wr uppercase letters and their meanings: s ffall pperiod hhigh rrise i invalid (high-impedance) v valid l low z high-impedance v ss c l legend: c l = 50 pf for all pins, 15 pf for osc2 output load condition pin
pic16f193x/lf193x ds41364c-page 372 preliminary ? 2009 microchip technology inc. 28.8 ac characteristics: pic16f193x/lf193x-i/e figure 28-6: clock timing table 28-1: clock oscillator timing requirements osc1/clkin osc2/clkout q4 q1 q2 q3 q4 q1 os02 os03 os04 os04 osc2/clkout (lp,xt,hs modes) (clkout mode) standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions os01 f osc external clkin frequency (1) dc ? 0.5 mhz ec oscillator mode (low) dc ? 4 mhz ec oscillator mode (medium) dc ? 32 mhz ec oscillator mode (high) oscillator frequency (1) ? 32.768 ? khz lp oscillator mode 0.1 ? 4 mhz xt oscillator mode 1 ? 4 mhz hs oscillator mode, v dd 2.3v 1 ? 20 mhz hs oscillator mode, v dd > 2.3v dc ? 4 mhz rc oscillator mode os02 t osc external clkin period (1) 27 ? ? s lp oscillator mode 250 ? ns xt oscillator mode 50 ? ns hs oscillator mode 31.25 ? ns ec oscillator mode oscillator period (1) ? 30.5 ? s lp oscillator mode 250 ? 10,000 ns xt oscillator mode 50 ? 1,000 ns hs oscillator mode 250 ? ? ns rc oscillator mode os03 t cy instruction cycle time (1) 200 t cy dc ns t cy = 4/f osc os04* tosh, to sl external clkin high, external clkin low 2?? s lp oscillator 100 ? ? ns xt oscillator 20 ? ? ns hs oscillator os05* tosr, to sf external clkin rise, external clkin fall 0? ns lp oscillator 0? ns xt oscillator 0? ns hs oscillator * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stat ed. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in an unstable oscillator operation and/or hig her than expected current con- sumption. all devices are tested to operate at ?min? values with an external clock applied to osc1 pin. when an external clock input is used, the ?max? cycle time limit is ?dc? (no clock) for all devices.
? 2009 microchip technology inc. preliminary ds41364c-page 373 pic16f193x/lf193x table 28-2: oscillator parameters table 28-3: pll clock timing specifications (v dd = 2.7v to 5.5v) standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic freq. tolerance min. typ? max. units conditions os08 hf osc internal calibrated hfintosc frequency (2) 2% ? 16.0 ? mhz 0c t a +85c, v dd 2.5v 5% ? 16.0 ? mhz -40c t a +125c, v dd 2.5v os08a mf osc internal calibrated mfintosc frequency (2) 2% ? 500 ? khz 0c t a +85c 5% ? 500 ? khz -40c t a +125c os10* t iosc st hfintosc wake-up from sleep start-up time mfintosc wake-up from sleep start-up time ??58 s ? ? 20 30 s * these parameters are char acterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time bas e period. all specified values are based on characterization data for that particular oscillator ty pe under standard operating conditions with the device executing code. exceeding these specified limits may result in an uns table oscillator operation and/o r higher than expected current consumption. all devices are tested to operate at ?min? valu es with an external clock applied to the osc1 pin. when an external clock input is used, the ?max? cycle ti me limit is ?dc? (no clock) for all devices. 2: to ensure these oscillator frequency tolerances, v dd and v ss must be capacitively decoupled as close to the device as possible. 0.1 f and 0.01 f values in parallel are recommended. 3: by design. param no. sym. characteristic min. typ? max. units conditions f10 f osc oscillator frequency range 4 ? 8 mhz f11 f sys on-chip vco system frequency 16 ? 32 mhz f12 t rc pll start-up time (lock time) ? ? 2 ms f13* clk clkout stability (jitter) -0.25% ? +0.25% % * these parameters are characterized but not tested. ? data in ?typ? column is at 5v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested.
pic16f193x/lf193x ds41364c-page 374 preliminary ? 2009 microchip technology inc. figure 28-7: clkout and i/o timing f osc clkout i/o pin (input) i/o pin (output) q4 q1 q2 q3 os11 os19 os13 os15 os18, os19 os20 os21 os17 os16 os14 os12 os18 old value new value write fetch read execute cycle
? 2009 microchip technology inc. preliminary ds41364c-page 375 pic16f193x/lf193x table 28-4: clkout and i/o timing parameters figure 28-8: reset, watchdog timer, os cillator start-up timer and power-up timer timing standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions os11 tosh2ckl f osc to clkout (1) ??70nsv dd = 3.3-5.0v os12 tosh2ckh f osc to clkout (1) ??72nsv dd = 3.3-5.0v os13 tckl2iov clkout to port out valid (1) ??20ns os14 tiov2ckh port input valid before clkout (1) t osc + 200 ns ? ? ns os15 tosh2iov fosc (q1 cycle) to port out valid ? 50 70* ns v dd = 3.3-5.0v os16 tosh2ioi fosc (q2 cycle) to port input invalid (i/o in hold time) 50 ? ? ns v dd = 3.3-5.0v os17 tiov2osh port input valid to fosc (q2 cycle) (i/o in setup time) 20 ? ? ns os18 tior port output rise time (2) ? ? 40 15 72 32 ns v dd = 1.8v v dd = 3.3-5.0v os19 tiof port output fall time (2) ? ? 28 15 55 30 ns v dd = 1.8v v dd = 3.3-5.0v os20* tinp int pin input high or low time 25 ? ? ns os21* tioc interrupt-on-change new input level time 25 ? ? ns * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25 c unless otherwise stated. note 1: measurements are taken in rc mode where clkout output is 4 x t osc . 2: includes osc2 in clkout mode. v dd mclr internal por pwrt time-out osc start-up time internal reset (1) watchdog timer 33 32 30 31 34 i/o pins 34 note 1: asserted low. reset (1)
pic16f193x/lf193x ds41364c-page 376 preliminary ? 2009 microchip technology inc. figure 28-9: brown-out rese t timing and characteristics v bor v dd (device in brown-out reset) (device not in brown-out reset) 33 (1) note 1: 64 ms delay only if pwrte bit in the configuration word register is programmed to ? 0 ?. 2 ms delay if pwrte = 0 and vregen = 1 . reset (due to bor) v bor and v hyst 37
? 2009 microchip technology inc. preliminary ds41364c-page 377 pic16f193x/lf193x table 28-5: reset, watchdog timer, oscill ator start-up timer, power-up timer and brown-out reset parameters figure 28-10: timer0 and timer1 external clock timings standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions 30 t mc lmclr pulse width (low) 2 5 ? ? ? ? s s v dd = 3.3-5v, -40c to +85c v dd = 3.3-5v 31 t wdtlp low-power watchdog timer time-out period (no prescaler) 10 18 27 ms v dd = 3.3v-5v 32 t ost oscillator start-up timer period (1), (2) ? 1024 ? tosc (note 3) 33* t pwrt power-up timer period, pwrte = 0 40 65 140 ms 34* t ioz i/o high-impedance from mclr low or watchdog timer reset ??2.0 s 35 v bor brown-out reset voltage 2.38 1.80 2.5 1.9 2.73 2.11 vborv=2.5v borv=1.9v 36* v hyst brown-out reset hysteresis 0 25 50 mv -40c to +85c 37* t bordc brown-out reset dc response time 135 sv dd v bor * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: instruction cycle period (t cy ) equals four times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. exceeding these specified limits may result in an unstable oscillator operation and/or higher than expected current consumption. all devices ar e tested to operate at ?min? values with an external clock applied to the osc1 pin. when an external clock input is used, the ?max? cycle time limit is ?dc? (no clock) for all devices. 2: by design. 3: period of the slower clock. 4: to ensure these voltage tolerances, v dd and v ss must be capacitively decoupled as close to the device as possible. 0.1 f and 0.01 f values in parallel are recommended. t0cki t1cki 40 41 42 45 46 47 49 tmr0 or tmr1
pic16f193x/lf193x ds41364c-page 378 preliminary ? 2009 microchip technology inc. table 28-6: timer0 and timer1 external clock requirements figure 28-11: capture/com pare/pwm timings (ccp) table 28-7: capture/compare/pwm requirements (ccp) standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions 40* t t 0h t0cki high pulse width no prescaler 0.5 t cy + 20 ? ? ns with prescaler 10 ? ? ns 41* t t 0l t0cki low pulse width no prescaler 0.5 t cy + 20 ? ? ns with prescaler 10 ? ? ns 42* t t 0p t0cki period greater of: 20 or t cy + 40 n ? ? ns n = prescale value (2, 4, ..., 256) 45* t t 1h t1cki high time synchronous, no prescaler 0.5 t cy + 20 ? ? ns synchronous, with prescaler 15 ? ? ns asynchronous 30 ? ? ns 46* t t 1l t1cki low time synchronous, no prescaler 0.5 t cy + 20 ? ? ns synchronous, with prescaler 15 ? ? ns asynchronous 30 ? ? ns 47* t t 1p t1cki input period synchronous greater of: 30 or t cy + 40 n ? ? ns n = prescale value (1, 2, 4, 8) asynchronous 60 ? ? ns 48 f t 1 timer1 oscillator input frequency range (oscillator enabled by setting bit t1oscen) 32.4 32.768 33.1 khz 49* tckez tmr 1 delay from external clock edge to timer increment 2 t osc ?7 t osc ? timers in sync mode * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions cc01* tccl ccpx input low time no prescaler 0.5t cy + 20 ? ? ns with prescaler 20 ? ? ns cc02* tcch ccpx input high time no prescaler 0.5t cy + 20 ? ? ns with prescaler 20 ? ? ns cc03* tccp ccpx input period 3t cy + 40 n ? ? ns n = prescale value (1, 4 or 16) * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are fo r design guidance only and are not tested. note: refer to figure 28.5 for load conditions. (capture mode) cc01 cc02 cc03 ccpx
? 2009 microchip technology inc. preliminary ds41364c-page 379 pic16f193x/lf193x table 28-8: pic16f193x/lf193x a/ d converter (adc) characteristics : table 28-9: pic16f193x/lf193x a/d conversion requirements standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions ad01 n r resolution ? ? 10 bit ad02 e il integral error ? ? 1.7 lsb v ref = 3.0v ad03 e dl differential error ? ? 1 lsb no missing codes v ref = 3.0v ad04 e off offset error ? ? 2 lsb v ref = 3.0v ad05 e gn gain error ? ? 1.5 lsb v ref = 3.0v ad06 v ref reference voltage (3) 1.8 ? v dd v ad07 v ain full-scale range v ss ?v ref v ad08 z ain recommended impedance of analog voltage source ?? 50 k can go higher if external 0.01 f capacitor is present on input pin. * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise st ated. these parameters are for design guidance only and are not tested. note 1: total absolute error includes integral, differential, offset and gain errors. 2: the a/d conversion result never dec reases with an increase in the input voltage and has no missing codes. 3: adc v ref is from external v ref , v dd pin or fv ref , whichever is selected as reference input. 4: when adc is off, it will not consum e any current other than leakage current. the power-down current specification includes any such leakage from the adc module. standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param no. sym. characteristic min. typ? max. units conditions ad130* t ad a/d clock period 1.0 ? 9.0 st osc -based a/d internal rc oscillator period 1.0 1.6 6.0 s adcs<1:0> = 11 (adrc mode) ad131 t cnv conversion time (not including acquisition time) (1) ?11?t ad set go/done bit to conversion complete ad132* t acq acquisition time ? 5.0 ? s * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stat ed. these parameters are for des ign guidance only and are not tested. note 1: the adres register may be read on the following t cy cycle.
pic16f193x/lf193x ds41364c-page 380 preliminary ? 2009 microchip technology inc. figure 28-12: pic16f193x/lf193x a/d conversion timing (normal mode) figure 28-13: pic16f193x/lf193x a/d conversion timing (sleep mode) ad131 ad130 bsf adcon0, go q4 a/d clk a/d data adres adif go sample old_data sampling stopped done new_data 765 3210 note 1: if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. 1 t cy 4 ad134 (t osc /2 (1) ) 1 t cy ad132 ad132 ad131 ad130 bsf adcon0, go q4 a/d clk a/d data adres adif go sample old_data sampling stopped done new_data 7 5 3210 note 1: if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. ad134 4 6 1 t cy (t osc /2 + t cy (1) ) 1 t cy
? 2009 microchip technology inc. preliminary ds41364c-page 381 pic16f193x/lf193x table 28-10: comparator specifications table 28-11: digital-to-analog conv erter (dac) specifications figure 28-14: usart synchronous transmission (master/slave) timing operating conditions: 1.8v < v dd < 5.5v, -40c < t a < +125c (unless otherwise stated). param no. sym. characteristics min. typ. max. units comments cm01 v ioff input offset voltage ? 7.5 60 mv cm02 v icm input common mode voltage 0 ? v dd v cm03 cmrr common mode rejection ratio ? 50 ? db cm04 t resp response time ? 150 400 ns note 1 cm05 t mc 2 ov comparator mode change to output valid* ?? 10 s cm06 c hyster comparator hysterisis ? 65 ? mv * these parameters are characterized but not tested. note 1: response time measured with one comparator input at v dd /2, while the other input transitions from v ss to v dd . operating conditions: 1.8v < v dd < 5.5v, -40c < t a < +125c (unless otherwise stated). param no. sym. characteristics min. typ. max. units comments dac01* c lsb step size (2) ?v dd /32 ? v dac02* c acc absolute accuracy ? ? 1/2 lsb dac03* c r unit resistor value (r) ? tbd ? dac04* c st settling time (1) ??10 s * these parameters are characterized but not tested. legend: tbd = to be determined note 1: settling time measured while dacr<4:0> transitions from ? 0000 ? to ? 1111 ?. note: refer to figure 28-5 for load conditions. us121 us121 us120 us122 ck dt
pic16f193x/lf193x ds41364c-page 382 preliminary ? 2009 microchip technology inc. table 28-12: usart synchronous tran smission requirements figure 28-15: usart synchrono us receive (master/slave) timing table 28-13: usart synchronous rece ive requirements standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param. no. symbol characteristic min. max. units conditions us120 t ck h2 dt v sync xmit (m aster and s lave ) clock high to data-out valid 3.0-5.5v ? 80 ns 1.8-5.5v ? 100 ns us121 t ckrf clock out rise time and fall time (master mode) 3.0-5.5v ? 45 ns 1.8-5.5v ? 50 ns us122 t dtrf data-out rise time and fall time 3.0-5.5v ? 45 ns 1.8-5.5v ? 50 ns standard operating conditions (unless otherwise stated) operating temperature -40c t a +125c param. no. symbol characteristic min. max. units conditions us125 t dt v2 ckl sync rcv (m aster and s lave ) data-hold before ck (dt hold time) 10 ? ns us126 t ck l2 dtl data-hold after ck (dt hold time) 15 ? ns note: refer to figure 28-5 for load conditions. us125 us126 ck dt
? 2009 microchip technology inc. preliminary ds41364c-page 383 pic16f193x/lf193x figure 28-16: spi master mode timing (cke = 0 , smp = 0 ) figure 28-17: spi master mode timing (cke = 1 , smp = 1 ) ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi sp70 sp71 sp72 sp73 sp74 sp75, sp76 sp78 sp79 sp80 sp79 sp78 msb lsb bit 6 - - - - - -1 msb in lsb in bit 6 - - - -1 note: refer to figure 28-5 for load conditions. ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi sp81 sp71 sp72 sp74 sp75, sp76 sp78 sp80 msb sp79 sp73 msb in bit 6 - - - - - -1 lsb in bit 6 - - - -1 lsb note: refer to figure 28-5 for load conditions.
pic16f193x/lf193x ds41364c-page 384 preliminary ? 2009 microchip technology inc. figure 28-18: spi slav e mode timing (cke = 0 ) figure 28-19: spi slav e mode timing (cke = 1 ) ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi sp70 sp71 sp72 sp73 sp74 sp75, sp76 sp77 sp78 sp79 sp80 sp79 sp78 msb lsb bit 6 - - - - - -1 msb in bit 6 - - - -1 lsb in sp83 note: refer to figure 28-5 for load conditions. ss sck (ckp = 0 ) sck (ckp = 1 ) sdo sdi sp70 sp71 sp72 sp82 sp74 sp75, sp76 msb bit 6 - - - - - -1 lsb sp77 msb in bit 6 - - - -1 lsb in sp80 sp83 note: refer to figure 28-5 for load conditions.
? 2009 microchip technology inc. preliminary ds41364c-page 385 pic16f193x/lf193x table 28-14: spi mode requirements figure 28-20: i 2 c? bus start/stop bits timing param no. symbol characteristic min. typ? max. units conditions sp70* t ss l2 sc h, t ss l2 sc l ss to sck or sck input t cy ??ns sp71* t sc h sck input high time (slave mode) t cy + 20 ? ? ns sp72* t sc l sck input low time (slave mode) t cy + 20 ? ? ns sp73* t di v2 sc h, t di v2 sc l setup time of sdi data input to sck edge 100 ? ? ns sp74* t sc h2 di l, t sc l2 di l hold time of sdi data input to sck edge 100 ? ? ns sp75* t do r sdo data output rise time 3.0-5.5v ? 10 25 ns 1.8-5.5v ? 25 50 ns sp76* t do f sdo data output fall time ? 10 25 ns sp77* t ss h2 do zss to sdo output high-impedance 10 ? 50 ns sp78* t sc r sck output rise time (master mode) 3.0-5.5v ? 10 25 ns 1.8-5.5v ? 25 50 ns sp79* t sc f sck output fall time (master mode) ? 10 25 ns sp80* t sc h2 do v, t sc l2 do v sdo data output valid after sck edge 3.0-5.5v ? ? 50 ns 1.8-5.5v ? ? 145 ns sp81* t do v2 sc h, t do v2 sc l sdo data output setup to sck edge tcy ? ? ns sp82* t ss l2 do v sdo data output valid after ss edge ? ? 50 ns sp83* t sc h2 ss h, t sc l2 ss h ss after sck edge 1.5t cy + 40 ? ? ns * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. note : refer to figure 28-5 for load conditions. sp91 sp92 sp93 scl sda start condition stop condition sp90
pic16f193x/lf193x ds41364c-page 386 preliminary ? 2009 microchip technology inc. table 28-15: i 2 c? bus start/stop bits requirements figure 28-21: i 2 c? bus data timing param no. symbol characteristic min. typ max. units conditions sp90* t su : sta start condition 100 khz mode 4700 ? ? ns only relevant for repeated start condition setup time 400 khz mode 600 ? ? sp91* t hd : sta start condition 100 khz mode 4000 ? ? ns after this period, the first clock pulse is generated hold time 400 khz mode 600 ? ? sp92* t su : sto stop condition 100 khz mode 4700 ? ? ns setup time 400 khz mode 600 ? ? sp93 t hd : sto stop condition 100 khz mode 4000 ? ? ns hold time 400 khz mode 600 ? ? * these parameters are characterized but not tested. note: refer to figure 28-5 for load conditions. sp90 sp91 sp92 sp100 sp101 sp103 sp106 sp107 sp109 sp109 sp110 sp102 scl sda in sda out
? 2009 microchip technology inc. preliminary ds41364c-page 387 pic16f193x/lf193x table 28-16: i 2 c? bus data requirements param. no. symbol characteristic min. max. units conditions sp100* t high clock high time 100 khz mode 4.0 ? s device must operate at a minimum of 1.5 mhz 400 khz mode 0.6 ? s device must operate at a minimum of 10 mhz ssp module 1.5t cy ? sp101* t low clock low time 100 khz mode 4.7 ? s device must operate at a minimum of 1.5 mhz 400 khz mode 1.3 ? s device must operate at a minimum of 10 mhz ssp module 1.5t cy ? sp102* t r sda and scl rise time 100 khz mode ? 1000 ns 400 khz mode 20 + 0.1c b 300 ns c b is specified to be from 10-400 pf sp103* t f sda and scl fall time 100 khz mode ? 250 ns 400 khz mode 20 + 0.1c b 250 ns c b is specified to be from 10-400 pf sp106* t hd : dat data input hold time 100 khz mode 0 ? ns 400 khz mode 0 0.9 s sp107* t su : dat data input setup time 100 khz mode 250 ? ns (note 2) 400 khz mode 100 ? ns sp109* t aa output valid from clock 100 khz mode ? 3500 ns (note 1) 400 khz mode ? ? ns sp110* t buf bus free time 100 khz mode 4.7 ? s time the bus must be free before a new transmission can start 400 khz mode 1.3 ? s sp111 c b bus capacitive loading ? 400 pf * these parameters are characterized but not tested. note 1: as a transmitter, the device must provide this internal minimum delay time to bridge the undefined region (min. 300 ns) of the falling edge of scl to avoid unintended generation of start or stop conditions. 2: a fast mode (400 khz) i 2 c ? bus device can be used in a standard mode (100 khz) i 2 c bus system, but the requirement t su : dat 250 ns must then be met. this will automatically be the case if the device does not stretch the low period of the scl signal. if such a device does stretch the low period of the scl signal, it must output the next data bit to the sda line t r max. + t su : dat = 1000 + 250 = 1250 ns (according to the standard mode i 2 c bus specification), before the scl line is released.
pic16f193x/lf193x ds41364c-page 388 preliminary ? 2009 microchip technology inc. table 28-17: cap sense os cillator specifications figure 28-22: cap sense oscillator param. no. symbol characteristic min. typ? max. units conditions cs01 i src current source high -3 -8 -15 a medium -0.8 -1.5 -3 a low -0.1 -0.3 -0.4 a cs02 i snk current sink high 2.5 7.5 14 a medium 0.6 1.5 2.9 a low 0.1 0.25 0.6 a cs03 vc th cap threshold ? 0.8 ? mv cs04 vc tl cap threshold ? 0.4 ? mv cs05 vc hyst cap hysterisis (v cth -v ctl ) high medium low 350 250 175 525 375 300 725 500 \425 mv mv mv * these parameters are characterized but not tested. ? data in ?typ? column is at 3.0v, 25c unless otherwise stated. these parameters are for design guidance only and are not tested. i src vc th vc tl i snk enabled enabled
? 2009 microchip technology inc. preliminary ds41364c-page 389 pic16f193x/lf193x 29.0 dc and ac characteristics graphs and charts graphs and charts are not available at this time.
pic16f193x/lf193x ds41364c-page 390 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 391 pic16f193x/lf193x 30.0 packaging information 30.1 package marking information * standard picmicro ? device marking consists of microchip part number, year code, week code and traceability code. for picmicro device marking beyond this, certain price adders apply. please check with your microchip sales office. for qtp devices, any special marking adders are included in qtp price. legend: xx...x customer-specific information y year code (last digit of calendar year) yy year code (last 2 digits of calendar year) ww week code (week of january 1 is week ?01?) nnn alphanumeric traceability code pb-free jedec designator for matte tin (sn) * this package is pb-free. the pb-free jedec designator ( ) can be found on the outer packaging for this package. note : in the event the full microchip part number cannot be marked on one line, it will be carried over to the next line, thus limiting the number of available characters for customer-specific information. 3 e 3 e 3 e 28-lead spdip xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx yywwnnn example pic16f1936 0810017 -i/sp 3 e 40-lead pdip xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx yywwnnn example pic16f1937 0810017 -i/p example 28-lead qfn/uqfn xxxxxxxx xxxxxxxx yywwnnn 16f1936 -i/ml 0810017 3 e
pic16f193x/lf193x ds41364c-page 392 preliminary ? 2009 microchip technology inc. package marking information (continued) 3 e 28-lead soic xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx yywwnnn example 0810017 28-lead ssop xxxxxxxxxxxx xxxxxxxxxxxx yywwnnn example pic16f1936 0810017 xxxxxxxxxx 44-lead qfn xxxxxxxxxx xxxxxxxxxx yywwnnn example pic16f1937 -i/ml 0810017 44-lead tqfp xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx yywwnnn example pic16f1937 0810017 -i/so 3 e pic16f1936 -i/ss 3 e -i/pt 3 e
? 2009 microchip technology inc. preliminary ds41364c-page 393 pic16f193x/lf193x 30.2 package details the following sections give the technical details of the packages. 
       
      
 !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   +%&,  & !& - '!
!#.#

&"#'
#%! 

& "!
!
#%! 

& "!
!! 
&$#/  !#  '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 7,8. '!
9'&! 7 7: ; 7"') 
%! 7 < &  1,
&
&  = =  
##4 4!!   -  1!&
&   = = 
"# &

"# >#& .  - -- 
##4>#& .  <  :  9&  - -?   &
& 9  -  9# 4!!  <   6  9#>#& )    9
* 9#>#& )  <  :  
* + 1 = = - note 1 n 12 d e1 eb c e l a2 e b b1 a1 a 3 
   

  * ,1
pic16f193x/lf193x ds41364c-page 394 preliminary ? 2009 microchip technology inc. #         $     !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   +%&,  & !& - '!
!#.#

&"#'
#%! 

& "!
!
#%! 

& "!
!! 
&$#/  !#  '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 7,8. '!
9'&! 7 7: ; 7"') 
%! 7  &  1,
&
&  = =  
##4 4!!   =  1!&
&   = = 
"# &

"# >#& .  = ? 
##4>#& . < = < :  9&  < =   &
& 9  =  9# 4!!  < =  6  9#>#& ) - =  9
* 9#>#& )  = - :  
* + 1 = =  n note 1 e1 d 123 a a1 b1 be c eb e l a2 
   

  * ,?1
? 2009 microchip technology inc. preliminary ds41364c-page 395 pic16f193x/lf193x    % &' !   ( )  $*$   %&! + , -..  /   (, !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   4!!*!"&# - '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! .32 % '!
("!"*&
"&&
 (%
%
'&
 "
!!
 !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 99. . '!
9'&! 7 7: ; 7"') 
%! 7 < &  ?1, :  8 &  <   &#
%%     ,
&& 4!! - .3 :  >#& . ?1, .$
!##>#& . -? -  :  9&  ?1, .$
!##9&  -? -  ,
&&>#& ) - - - ,
&&9& 9    ,
&&&
.$
!## @  = = d exposed d2 e b k e2 e l n note 1 1 2 2 1 n a a1 a3 top view bottom view pad 
   

  * ,1
pic16f193x/lf193x ds41364c-page 396 preliminary ? 2009 microchip technology inc.    % &' !   ( )  $*$   %&! + , -..  /   (, !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4
? 2009 microchip technology inc. preliminary ds41364c-page 397 pic16f193x/lf193x ##   % &' !   ( )  *   %&! !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   4!!*!"&# - '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! .32 % '!
("!"*&
"&&
 (%
%
'&
 "
!!
 !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 99. . '!
9'&! 7 7: ; 7"') 
%! 7  &  ?1, :  8 &  <   &#
%%     ,
&& 4!! - .3 :  >#& . <1, .$
!##>#& . ?- ? ?< :  9&  <1, .$
!##9&  ?- ? ?< ,
&&>#& )  - -< ,
&&9& 9 -   ,
&&&
.$
!## @  = = d exposed pad d2 e b k l e2 2 1 n note 1 2 1 e n bottom view top view a3 a1 a 
   

  * ,-1
pic16f193x/lf193x ds41364c-page 398 preliminary ? 2009 microchip technology inc. ##   % &' !   ( )  *   %&! !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4
? 2009 microchip technology inc. preliminary ds41364c-page 399 pic16f193x/lf193x   
 0  
0  1 ' 2-.   
0/ !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   +%&,  & !& - '!
!#.#

&"#'
#%! 

& "!
!
#%! 

& "!
!! 
&$#''  !#  '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! .32 % '!
("!"*&
"&&
 (%
%
'&
 "
!!
 !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 99. . '!
9'&! 7 7: ; 7"') 
%! 7 < &  1, :  8 &  = = ? 
##4 4!!   = = &#
%%+   = - :  >#& . -1, 
##4>#& . 1, :  9&  1, , '% a
&
b  =  3
&9& 9  =  3
& & 9 .3 3
&
 c = #& ) - =  
# %&
 c = c 
# %&1
&&
'  c = c c h h l l1 a2 a1 a note 1 12 3 b e e e1 d n 
   

  * ,1
pic16f193x/lf193x ds41364c-page 400 preliminary ? 2009 microchip technology inc.   
,3
 0  
  .-   
0 !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   '!
!#.#

&"#'
#%! 

& "!
!
#%! 

& "!
!! 
&$#''  !# - '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! .32 % '!
("!"*&
"&&
 (%
%
'&
 "
!!
 !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 99. . '!
9'&! 7 7: ; 7"') 
%! 7 < &  ?1, :  8 &  = =  
##4 4!!  ?  < &#
%%   = = :  >#& .  < < 
##4>#& .  - ? :  9&     3
&9& 9    3
& & 9 .3 9# 4!!   =  3
& c c #& )  = -< l l1 c a2 a1 a e e1 d n 1 2 note 1 b e 
   

  * ,-1
? 2009 microchip technology inc. preliminary ds41364c-page 401 pic16f193x/lf193x ##   4, % &5 4  6*6*6  ' -  4%& !"   !"#$%&" '  ()"&'"!&)
&#*& &  & #   , '% !&
 ! 
&
d!e'   - '!
!#.#

&"#'
#%! 

& "!
!
#%! 

& "!
!! 
&$#''  !#  '!
#&
   .0 1,2 1!'!
 
&$& "!
**&
"&&
 ! .32 % '!
("!"*&
"&&
 (%
%
'&
 "
!!
 !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4 6&! 99. . '!
9'&! 7 7: ; 7"') 
%9#! 7  9#&  <1, :  8 &  = =  
##4 4!!     &#
%%   =  3
&9& 9  ?  3
& & 9 .3 3
& c -c c :  >#& . 1, :  9&  1, 
##4>#& . 1, 
##49&  1, 9# 4!!   =  9#>#& ) - -  
# %&
c c -c 
# %&1
&&
' c c -c a e e1 d d1 e b note 1 note 2 n 123 c a1 l a2 l1 
   

  * ,?1
pic16f193x/lf193x ds41364c-page 402 preliminary ? 2009 microchip technology inc. ##   4, % &5 4  6*6*6  ' -  4%& !" 3
& '
!&" & 4# *!( !!& 
  4 %&

&#& && 255***'
  
'5 4
? 2009 microchip technology inc. preliminary ds41364c-page 403 pic16f193x/lf193x note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging
pic16f193x/lf193x ds41364c-page 404 preliminary ? 2009 microchip technology inc. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging
? 2009 microchip technology inc. preliminary ds41364c-page 405 pic16f193x/lf193x appendix a: data sheet revision history revision a original release (12/2008) revision b (04/2009) revised data sheet title; revised features section. revision c (09/2009) revised figure 13-1; revised equation 13-1; revised section 23.2; revised example 23-4; revised register sspstat; revised register ccpxcon; revised electrical specifications; added uqfn package. appendix b: migrating from other pic ? devices this discusses some of the issues in migrating from other pic ? devices to the pic16f193x/lf193x family of devices. b.1 pic16f917 to pic16f193x/lf193x table b-1: feature comparison feature pic16f917 pic16f1937 max. operating speed 20 mhz 32 mhz max. program memory (words) 8k 8k max. sram (bytes) 368 512 a/d resolution 10-bit 10-bit timers (8/16-bit) 2/1 4/1 oscillator modes 4 8 brown-out reset y y internal pull-ups rb<7:0> rb<7:0> interrupt-on-change rb<7:4> rb<7:0> comparator 2 2 ausart/eusart 1/0 0/1 extended wdt y y software control option of wdt/bor ny intosc frequencies 30 khz - 8mhz 500 khz - 32 mhz clock switching y y capacitive sensing n y ccp/eccp 2/0 2/3 enhanced pic16 cpu n y mssp/ssp 0/1 1/0 lcd y y
pic16f193x/lf193x ds41364c-page 406 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 407 pic16f193x/lf193x index a a/d specifications............................................................ 379 absolute maximum ratings .............................................. 357 ac characteristics industrial and extended ............................................ 372 load conditions ........................................................ 371 ackstat ......................................................................... 312 ackstat status flag ...................................................... 312 adc .................................................................................. 133 acquisition requirements ......................................... 142 associated registers.................................................. 144 block diagram........................................................... 133 calculating acquisition time..................................... 142 channel selection..................................................... 134 configuration............................................................. 134 configuring interrupt ................................................. 138 conversion clock...................................................... 134 conversion procedure .............................................. 138 internal sampling switch (r ss ) impedance.............. 142 interrupts................................................................... 136 operation .................................................................. 137 operation during sleep ............................................ 137 port configuration ..................................................... 134 reference voltage (v ref )......................................... 134 source impedance.................................................... 142 special event trigger................................................ 137 starting an a/d conversion ...................................... 136 adcon0 register....................................................... 38, 139 adcon1 register....................................................... 38, 140 addfsr ........................................................................... 343 addwfc .......................................................................... 343 adresh register............................................................... 38 adresh register (adfm = 0) ......................................... 140 adresh register (adfm = 1) ......................................... 141 adresl register (adfm = 0).......................................... 141 adresl register (adfm = 1).......................................... 141 alternate pin function......................................................... 86 analog-to-digital converter. see adc ansela register ............................................................... 88 anselb register ............................................................... 93 anseld register ............................................................... 99 ansele register ............................................................. 103 apfcon register............................................................... 86 assembler mpasm assembler................................................... 354 b baudcon register.......................................................... 226 bf ............................................................................. 312, 314 bf status flag .......................................................... 312, 314 block diagram capacitive sensing ................................................... 179 block diagrams (ccp) capture mode operation ............................... 189 adc .......................................................................... 133 adc transfer function ............................................. 143 analog input model ........................................... 143, 149 ccp pwm................................................................. 193 clock source............................................................. 109 comparator ............................................................... 146 compare ................................................................... 191 crystal operation ...................................................... 112 digital-to-analog converter (dac) ........................... 154 eusart receive ..................................................... 216 eusart transmit .................................................... 215 external rc mode .................................................... 113 fail-safe clock monitor (fscm)............................... 121 generic i/o port.......................................................... 85 interrupt logic............................................................. 71 lcd bias voltage generation .................................. 251 lcd clock generation.............................................. 250 mclr circuit .............................................................. 61 on-chip reset circuit................................................. 59 peripheral interrupt logic ........................................... 72 pic16f193x/lf193x ................................................. 15 pwm (enhanced) ..................................................... 197 resonator operation ................................................ 112 timer0 ...................................................................... 159 timer1 ...................................................................... 163 timer1 gate.............................................. 168, 169, 170 timer2/4/6 ................................................................ 175 voltage reference.................................................... 157 voltage reference output buffer example .............. 157 borcon register.............................................................. 65 bra .................................................................................. 344 break character (12-bit) transmit and receive ............... 235 brown-out reset (bor)...................................................... 64 specifications ........................................................... 377 timing and characteristics ....................................... 376 c c compilers mplab c18 .............................................................. 354 mplab c30 .............................................................. 354 call................................................................................. 345 callw ............................................................................. 345 capacitive sensing ........................................................... 179 associated registers w/ capacitive sensing............. 183 specifications ........................................................... 388 capture module. see enhanced capture/compare/ pwm(eccp) capture/compare/pwm ................................................... 185 capture/compare/pwm (ccp) ........................................ 187 associated registers w/ capture ............................. 190 associated registers w/ compare ........................... 192 associated registers w/ pwm ................................. 213 capture mode ........................................................... 189 ccpx pin configuration............................................ 189 clock selection......................................................... 187 compare mode ......................................................... 191 ccpx pin configuration.................................... 191 software interrupt mode ........................... 189, 191 special event trigger ....................................... 191 timer1 mode selection............................. 189, 191 prescaler .................................................................. 189 pwm mode............................................................... 193 duty cycle ........................................................ 194 effects of reset ................................................ 196 example pwm frequencies and resolutions, 20 mhz ................................ 195 example pwm frequencies and resolutions, 32 mhz ................................ 195 example pwm frequencies and resolutions, 8 mhz .................................. 195 operation in sleep mode.................................. 196 resolution ........................................................ 195
pic16f193x/lf193x ds41364c-page 408 preliminary ? 2009 microchip technology inc. setup for operation........................................... 196 system clock frequency changes................... 196 pwm period .............................................................. 194 setup for pwm operation ......................................... 196 ccp1con register ...................................................... 42, 43 ccpr1h register ......................................................... 42, 43 ccpr1l register.......................................................... 42, 43 ccptmrs0 register ........................................................ 187 ccptmrs1 register ........................................................ 188 ccpxas register.............................................................. 206 ccpxcon (eccpx) register ........................................... 186 clock accuracy with asynchronous operation ................. 224 clock sources external modes ......................................................... 111 ec ..................................................................... 111 hs ..................................................................... 112 lp...................................................................... 112 ost................................................................... 111 rc..................................................................... 113 xt ..................................................................... 112 internal modes .......................................................... 113 frequency selection ......................................... 117 hfintosc........................................................ 114 internal oscillator clock switch timing............. 117 intosc ............................................................ 113 intoscio......................................................... 113 lfintosc ........................................................ 114 mfintosc ....................................................... 114 clock switching................................................................. 119 cmout register............................................................... 151 cmxcon0 register .......................................................... 150 cmxcon1 register .......................................................... 151 code examples a/d conversion ......................................................... 138 changing between capture prescalers .................... 189 initializing porta....................................................... 87 initializing portb....................................................... 91 initializing portc....................................................... 95 initializing portd....................................................... 98 initializing porte..................................................... 103 write verify ............................................................... 334 writing to flash program memory ............................ 332 comparator associated registers ................................................ 152 operation .................................................................. 145 comparator module .......................................................... 145 cx output state versus input conditions ................. 147 comparator specifications ................................................ 381 comparator voltage reference (cv ref ) associated registers ................................................ 158 comparators c2out as t1 gate ................................................... 165 compare module. see enhanced capture/compare/ pwm (eccp) config1 register............................................................ 128 config2 register............................................................ 130 core registers .................................................................... 51 cpscon0 register .......................................................... 182 cpscon1 register .......................................................... 183 customer change notification service ............................. 414 customer notification service........................................... 414 customer support ............................................................. 414 d daccon0 (digital-to-anal og converter control 0) register .................................................................... 155 daccon1 (digital-to-anal og converter control 1) register .................................................................... 155 data eeprom memory.................................................... 323 associated registers ................................................ 334 code protection ........................................................ 334 reading .................................................................... 327 writing ...................................................................... 327 data memory ...................................................................... 26 dc and ac characteristics............................................... 389 dc characteristics extended and industrial ............................................ 367 industrial and extended ............................................ 360 development support ....................................................... 353 device configuration ........................................................ 127 code protection ........................................................ 131 configuration word................................................... 127 user id ..................................................................... 131 device overview................................................................. 15 digital-to-analog converter (dac) ................................... 153 associated registers ................................................ 156 effects of a reset ..................................................... 153 operation during sleep ............................................ 153 specifications ........................................................... 381 e eccp/ccp. see enhanced capture/compare/pwm eeadr registers ............................................................. 323 eeadrh registers........................................................... 323 eeadrl register ............................................................. 324 eeadrl registers ........................................................... 323 eecon1 register..................................................... 323, 325 eecon2 register..................................................... 323, 326 eedath register............................................................. 324 eedatl register ............................................................. 324 eeprom data memory avoiding spurious write ........................................... 334 write verify ............................................................... 334 effects of reset pwm mode ............................................................... 196 electrical specifications .................................................... 357 enhanced capture/compare/pwm timer resources ...................................................... 186 enhanced capture/compare/pwm (eccp)..................... 186 enhanced pwm mode.............................................. 197 auto-restart ..................................................... 207 auto-shutdown.................................................. 205 direction change in full-bridge output mode.. 203 full-bridge application...................................... 201 full-bridge mode .............................................. 201 half-bridge application ..................................... 200 half-bridge application examples .................... 208 half-bridge mode.............................................. 200 output relationships (active-high and active-low)............................................... 198 output relationships diagram.......................... 199 programmable dead band delay..................... 208 shoot-through current...................................... 208 start-up considerations .................................... 205 specifications ........................................................... 378 enhanced mid-range cpu.................................................. 16 enhanced universal synchronous asynchronous receiver transmitter (eusart) .............................. 215
? 2009 microchip technology inc. preliminary ds41364c-page 409 pic16f193x/lf193x errata .................................................................................. 13 eusart ........................................................................... 215 associated registers baud rate generator........................................ 228 asynchronous mode ................................................. 217 12-bit break transmit and receive .................. 235 associated registers receive..................................................... 223 transmit.................................................... 219 auto-wake-up on break ................................... 233 baud rate generator (brg) ............................ 227 clock accuracy ................................................. 224 receiver............................................................ 220 setting up 9-bit mode with address detect....... 222 transmitter........................................................ 217 baud rate generator (brg) auto baud rate detect ..................................... 232 baud rate error, calculating ............................ 227 baud rates, asynchronous modes .................. 229 formulas ........................................................... 228 high baud rate select (brgh bit) .................. 227 synchronous master mode ............................... 236, 240 associated registers receive..................................................... 239 transmit.................................................... 237 reception.......................................................... 238 transmission .................................................... 236 synchronous slave mode associated registers receive..................................................... 241 transmit.................................................... 240 reception.......................................................... 241 transmission .................................................... 240 extended instruction set addfsr ................................................................... 343 f fail-safe clock monitor..................................................... 121 fail-safe condition clearing ..................................... 121 fail-safe detection ................................................... 121 fail-safe operation................................................... 121 reset or wake-up from sleep................................... 121 firmware instructions........................................................ 339 flash program memory .................................................... 323 erasing...................................................................... 330 writing....................................................................... 330 fsr register ............ 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50 fvrcon (fixed voltage reference control) register ..... 158 i i 2 c mode (mssp) acknowledge sequence timing................................ 316 bus collision during a repeated start condition ................... 320 during a stop condition.................................... 321 effects of a reset...................................................... 317 i 2 c clock rate w/brg.............................................. 322 master mode operation .......................................................... 308 reception.......................................................... 314 start condition timing .............................. 310, 311 transmission .................................................... 312 multi-master communication, bus collision and arbitration ......................................................... 317 multi-master mode .................................................... 317 read/write bit information (r/w bit)........................ 293 slave mode transmission .................................................... 298 sleep operation........................................................ 317 stop condition timing .............................................. 316 indf register ............ 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50 indirect addressing, indf and fsr registers ................... 55 instruction format............................................................. 340 instruction set................................................................... 339 addlw..................................................................... 343 addwf .................................................................... 343 addwfc.................................................................. 343 andlw..................................................................... 343 andwf .................................................................... 343 bra .......................................................................... 344 call......................................................................... 345 callw ..................................................................... 345 lslf ......................................................................... 347 lsrf ........................................................................ 347 movf ....................................................................... 347 moviw ..................................................................... 348 movlb ..................................................................... 348 movwi ..................................................................... 349 option.................................................................... 349 reset...................................................................... 349 subwfb .................................................................. 351 tris ......................................................................... 352 bcf .......................................................................... 344 bsf........................................................................... 344 btfsc...................................................................... 344 btfss ...................................................................... 344 call......................................................................... 345 clrf ........................................................................ 345 clrw ....................................................................... 345 clrwdt .................................................................. 345 comf ....................................................................... 345 decf........................................................................ 345 decfsz ................................................................... 346 goto ....................................................................... 346 incf ......................................................................... 346 incfsz..................................................................... 346 iorlw...................................................................... 346 iorwf...................................................................... 346 movlw .................................................................... 348 movwf.................................................................... 348 nop.......................................................................... 349 retfie..................................................................... 350 retlw ..................................................................... 350 return................................................................... 350 rlf........................................................................... 350 rrf .......................................................................... 351 sleep ...................................................................... 351 sublw..................................................................... 351 subwf..................................................................... 351 swapf..................................................................... 352 xorlw .................................................................... 352 xorwf .................................................................... 352 intcon register................................................................ 75 internal oscillator block intosc specifications ................................................... 373 internal sampling switch (r ss ) impedance ..................... 142 internet address ............................................................... 414 interrupt-on-change......................................................... 105
pic16f193x/lf193x ds41364c-page 410 preliminary ? 2009 microchip technology inc. associated registers ................................................ 107 interrupts ............................................................................. 71 adc .......................................................................... 138 associated registers w/ interrupts ............................... 82 tmr1 ........................................................................ 167 intosc specifications ..................................................... 373 iocbf register................................................................. 106 iocbn register ................................................................ 106 iocbp register................................................................. 106 l lata register............................................................... 87, 95 latb register..................................................................... 92 latd register..................................................................... 98 late register................................................................... 101 lcd associated registers ................................................ 274 bias voltage generation ................................... 251, 252 clock source selection ............................................. 250 configuring the module ............................................. 273 disabling the module ................................................ 273 frame frequency...................................................... 256 interrupts................................................................... 269 lcdcon register .................................................... 243 lcdps register........................................................ 243 multiplex types ......................................................... 256 operation during sleep ............................................ 271 pixel control.............................................................. 256 prescaler................................................................... 250 segment enables...................................................... 256 waveform generation ............................................... 258 lcdcon register..................................................... 243, 245 lcdcst register ............................................................. 248 lcddatax registers ............................................... 249, 254 lcdps register........................................................ 243, 246 lp bits....................................................................... 250 lcdref register ............................................................. 247 lcdrl register ................................................................ 254 lcdsen registers ............................................................ 249 liquid crystal display (lcd) driver .................................. 243 load conditions ................................................................ 371 lslf.................................................................................. 347 lsrf ................................................................................. 347 m master synchronous serial port. see mssp...................... 61 internal ........................................................................ 61 memory organization.......................................................... 23 data ............................................................................ 26 program ...................................................................... 23 microchip internet web site .............................................. 414 migrating from other pic microcontroller devices............. 405 moviw.............................................................................. 348 movlb.............................................................................. 348 movwi.............................................................................. 349 mplab asm30 assembler, linker, librarian ................... 354 mplab icd 2 in-circuit debugger.................................... 355 mplab ice 2000 high-performance universal in-circuit emulator .................................................... 355 mplab integrated development environment software .................................................................... 353 mplab pm3 device programmer..................................... 355 mplab real ice in-circuit emulator system................. 355 mplink object linker/mplib object librarian ................ 354 mssp ................................................................................ 275 sspbuf register ..................................................... 285 sspsr register ....................................................... 285 o opcode field descriptions............................................. 339 option ............................................................................ 349 option register........................................................ 53, 161 osccon register............................................................ 110 oscillator associated registers ................................................ 122 oscillator module .............................................................. 109 ec............................................................................. 109 hfintosc ............................................................... 109 hs............................................................................. 109 intosc .................................................................... 109 lfintosc ................................................................ 109 lp ............................................................................. 109 mfintosc ............................................................... 109 rc ............................................................................ 109 xt ............................................................................. 109 oscillator parameters ....................................................... 373 oscillator specifications.................................................... 372 oscillator start-up timer (ost) specifications ........................................................... 377 oscillator switching fail-safe clock monitor ............................................ 121 two-speed clock start-up........................................ 119 oscstat register .......................................................... 115 osctune register.......................................................... 116 p p1a/p1b/p1c/p1d. see enhanced capture/compare/ pwm (eccp)............................................................ 197 packaging ......................................................................... 391 marking ............................................................. 391, 392 pdip details ............................................................. 393 pcl and pclath............................................................... 54 pcl register ............ 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50 pclath register ............ 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50 pcon register ............................................................. 38, 67 picstart plus development programmer..................... 356 pie1 register................................................................ 38, 76 pie2 register................................................................ 38, 77 pie3 register...................................................................... 78 pin diagram pic16f1933/1936/1938, piclf1933/1936/1938, 28-pin pdip/soic/ssop ..................................... 5 pic16f1933/1936/1938, piclf1933/1936/1938, 28-pin qfn ........................................................... 6 picf1934/1937/1939, piclf1934/1937/1939, 44-pin qfn ........................................................... 9 picf1934/1937/1939, piclf1934/1937/1939, 44-pin tqfp ....................................................... 10 picf1934/1937/1939,piclf1934/1937/1939, 40-pin pdip .......................................................... 8 pinout descriptions pic16f193x/pic16lf193x........................................ 17 pir1 register ............................................................... 37, 79 pir2 register ............................................................... 37, 80 pir3 register ..................................................................... 81 porta ............................................................................... 87 ansela register ....................................................... 88 associated registers .................................................. 90 porta register ................................................... 37, 39 specifications ........................................................... 375
? 2009 microchip technology inc. preliminary ds41364c-page 411 pic16f193x/lf193x porta register ................................................................. 87 portb................................................................................ 91 additional pin functions weak pull-up ...................................................... 91 anselb register ....................................................... 93 associated registers .................................................. 94 interrupt-on-change.................................................... 91 p1b/p1c/p1d. see enhanced capture/compare/ pwm+ (eccp+) ................................................. 91 pin descriptions and diagrams................................... 94 portb register ................................................... 37, 39 portb register ................................................................. 92 portc ............................................................................... 95 associated registers .................................................. 97 p1a. see enhanced capture/compare/pwm+ (eccp+) ............................................................. 95 pin descriptions and diagrams................................... 97 portc register ................................................... 37, 39 specifications............................................................ 375 portc register ................................................................. 95 portd ............................................................................... 98 additional pin functions anseld register ............................................... 99 associated registers ................................................ 100 p1b/p1c/p1d. see enhanced capture/compare/ pwm+ (eccp+) ................................................. 98 pin descriptions and diagrams................................. 100 portd register ................................................... 37, 39 portd register ................................................................. 98 porte.............................................................................. 101 ansele register ..................................................... 103 associated registers ................................................ 104 pin descriptions and diagrams................................. 104 porte register ................................................... 37, 39 porte register ............................................................... 101 power-down mode (sleep) ............................................... 335 associated registers ................................................ 336 power-on reset .................................................................. 61 power-up time-out sequence ............................................ 66 power-up timer (pwrt) .................................................... 61 specifications............................................................ 377 pr2 register................................................................. 37, 45 precision internal oscillator parameters........................... 373 program memory ................................................................ 23 map and stack (pic16f1933/lf1933, pic16f1934/lf1934) ......................................... 24 map and stack (pic16f1936/lf1936, pic16f1937/lf1937) ......................................... 24 map and stack (pic16f1938/lf1938, pic16f1939/lf1939) ......................................... 25 programming, device instructions .................................... 339 pstrxcon register ........................................................ 210 pulse steering................................................................... 210 pwm (eccp module) pulse steering........................................................... 210 steering synchronization .......................................... 212 pwm mode. see enhanced capture/compare/pwm ...... 197 pwmxcon register ......................................................... 209 r rcreg ............................................................................. 222 rcreg register................................................................. 40 rcsta register ......................................................... 40, 225 reader response ............................................................. 415 read-modify-write operations ......................................... 339 register rcreg register ...................................................... 232 registers adcon0 (adc control 0) ........................................ 139 adcon1 (adc control 1) ........................................ 140 adresh (adc result high) with adfm = 0) .......... 140 adresh (adc result high) with adfm = 1) .......... 141 adresl (adc result low) with adfm = 0)............ 141 adresl (adc result low) with adfm = 1)............ 141 ansela (porta analog select) .............................. 88 anselb (portb analog select) .............................. 93 anseld (portd analog select) .............................. 99 ansele (porte analog select) ............................ 103 apfcon (alternate pin function control) ................. 86 baudcon (baud rate control)............................... 226 borcon brown-out reset control) .......................... 65 ccptmrs0 (ccp timers control 0) ....................... 187 ccptmrs1 (ccp timers control 1) ....................... 188 ccpxas (ccpx auto-shutdown control) ................ 206 ccpxcon (eccpx control) .................................... 186 cmout (comparator output) .................................. 151 cmxcon0 (cx control) ............................................ 150 cmxcon1 (cx control 1)......................................... 151 configuration word 1................................................ 128 configuration word 2................................................ 130 cpscon0 (capacitive sensing control register 0) 182 cpscon1 (capacitive sensing control register 1) 183 daccon0 ................................................................ 155 daccon1 ................................................................ 155 eeadrl (eeprom address) .................................. 324 eecon1 (eeprom control 1) ................................ 325 eecon2 (eeprom control 2) ................................ 326 eedath (eeprom data) ....................................... 324 eedatl (eeprom data) ........................................ 324 fvrcon .................................................................. 158 intcon (interrupt control) ........................................ 75 iocbf (interrupt-on-change flag)........................... 106 iocbn (interrupt-on-change negative edge).......... 106 iocbp (interrupt-on-change positive edge)............ 106 lata (data latch porta) ........................................ 87 latb (data latch portb) ........................................ 92 latc (data latch portc) ........................................ 95 latd (data latch portd) ........................................ 98 late (data latch porte) ...................................... 101 lcdcon (lcd control) ........................................... 245 lcdcst (lcd contrast control) ............................. 248 lcddatax (lcd data).................................... 249, 254 lcdps (lcd phase)................................................ 246 lcdref (lcd reference voltage control) ............. 247 lcdrl (lcd reference voltage control)................ 254 lcdsen (lcd segment enable) ............................. 249 option_reg (option)................................... 53, 161 osccon (oscillator control)................................... 110 oscstat (oscillator status) ................................... 115 osctune (oscillator tuning).................................. 116 pcon (power control register)................................. 67 pcon (power control) ............................................... 67 pie1 (peripheral interrupt enable 1) .......................... 76 pie2 (peripheral interrupt enable 2) .......................... 77 pie3 (peripheral interrupt enable 3) .......................... 78 pir1 (peripheral interrupt register 1) ........................ 79 pir2 (peripheral interrupt request 2) ........................ 80 pir3 (peripheral interrupt request 3) ........................ 81 porta ....................................................................... 87 portb ....................................................................... 92 portc ....................................................................... 95
pic16f193x/lf193x ds41364c-page 412 preliminary ? 2009 microchip technology inc. portd ....................................................................... 98 porte...................................................................... 101 pstrxcon (pulse steering control) ....................... 210 pwmxcon (enhanced pwm control) ..................... 209 rcsta (receive status and control)....................... 225 special function, summary ........................................ 37 srcon0 (sr latch control 0) ................................. 124 srcon1 (sr latch control 1) ................................. 125 sspadd (mssp address and baud rate, i 2 c mode).......................................................... 282 sspcon1 (mssp control 1).................................... 279 sspcon2 (ssp control 2)....................................... 280 sspcon3 (ssp control 3)....................................... 281 sspmsk (ssp mask) ............................................... 282 sspstat (ssp status)............................................ 278 status ...................................................................... 52 t1con (timer1 control)........................................... 171 t1gcon (timer1 gate control) ............................... 172 trisa (tri-state porta) ........................................... 88 trisb (tri-state portb) ........................................... 93 trisc (tri-state portc) .......................................... 96 trisd (tri-state portd) .......................................... 99 trise (tri-state porte) ......................................... 103 txcon ...................................................................... 177 txsta (transmit status and control) ...................... 224 wdtcon (watchdog timer control).......................... 63 wpub (weak pull-up portb) ................................... 92 reset .............................................................................. 349 reset................................................................................... 59 reset instruction ................................................................. 66 resets ................................................................................. 59 associated registers .................................................. 70 revision history ................................................................ 405 s sck................................................................................... 283 sdi .................................................................................... 283 sdo .................................................................................. 283 serial clock, sck.............................................................. 283 serial data in (sdi) ........................................................... 283 serial data out (sdo) ...................................................... 283 shoot-through current ...................................................... 208 slave select (ss ) .............................................................. 283 software simulator (mplab sim)..................................... 354 spbrg.............................................................................. 227 spbrg register ........................................................... 39, 40 spbrgh ........................................................................... 227 special event trigger........................................................ 137 special function registers (sfrs) ..................................... 37 spi mode (mssp) associated registers ................................................ 288 serial clock............................................................... 283 serial data in ............................................................ 283 serial data out ......................................................... 283 slave select .............................................................. 283 spi clock .................................................................. 285 typical connection ................................................... 284 sr latch ........................................................................... 123 srcon0 register............................................................. 124 srcon1 register..................................................... 125, 283 sspadd register ....................................................... 41, 282 sspbuf register ............................................................... 41 sspcon 1 register.......................................................... 279 sspcon register............................................................... 41 sspcon2 register........................................................... 280 sspcon3 register........................................................... 281 sspmsk register ............................................................ 282 sspov ............................................................................. 314 sspov status flag .......................................................... 314 sspstat register ..................................................... 41, 278 r/w bit ..................................................................... 293 stack................................................................................... 54 accessing ................................................................... 55 reset .......................................................................... 55 stack overflow/underflow .................................................. 66 status register ............................................................... 52 subwfb .......................................................................... 351 t t1con register ......................................................... 37, 171 t1gcon register ............................................................ 172 t2con register ........................................................... 37, 45 thermal considerations.................................................... 370 timer0............................................................................... 159 associated registers ................................................ 161 operation .................................................................. 159 specifications ........................................................... 378 timer1............................................................................... 163 associated registers ................................................. 173 asynchronous counter mode ................................... 165 reading and writing ......................................... 165 clock source selection............................................. 164 interrupt .................................................................... 167 operation .................................................................. 164 operation during sleep ............................................ 167 oscillator................................................................... 165 prescaler .................................................................. 165 specifications ........................................................... 378 timer1 gate selecting source .............................................. 165 tmr1h register ....................................................... 163 tmr1l register........................................................ 163 timer2 associated registers ................................................. 178 timer2/4/6......................................................................... 175 associated registers ................................................. 178 timers timer1 t1con ............................................................. 171 t1gcon........................................................... 172 timer2/4/6 txcon.............................................................. 177 timing diagrams a/d conversion......................................................... 380 a/d conversion (sleep mode) .................................. 380 acknowledge sequence ........................................... 316 asynchronous reception.......................................... 222 asynchronous transmission..................................... 218 asynchronous transmission (back to back) ............ 218 auto wake-up bit (wue) during normal operation . 234 auto wake-up bit (wue) during sleep .................... 234 automatic baud rate calibration.............................. 232 baud rate generator with clock arbitration............. 309 brg reset due to sda arbitration during start condition .......................................................... 319 brown-out reset (bor)............................................ 376 brown-out reset situations ........................................ 64 bus collision during a repeated start condition (case 1)............................................................ 320 bus collision during a repeated start condition (case 2)............................................................ 320 bus collision during a start condition (scl = 0) ..... 319
? 2009 microchip technology inc. preliminary ds41364c-page 413 pic16f193x/lf193x bus collision during a stop condition (case 1) ....... 321 bus collision during a stop condition (case 2) ....... 321 bus collision during start condition (sda only) ...... 318 bus collision for transmit and acknowledge............ 317 clkout and i/o....................................................... 374 clock synchronization .............................................. 306 clock timing ............................................................. 372 comparator output ................................................... 145 enhanced capture/compare/pwm (eccp) ............. 378 fail-safe clock monitor (fscm) ............................... 122 first start bit timing ................................................. 310 full-bridge pwm output ........................................... 202 half-bridge pwm output .................................. 200, 208 i 2 c bus data ............................................................. 386 i 2 c bus start/stop bits.............................................. 385 i 2 c master mode (7 or 10-bit transmission) ............ 313 i 2 c master mode (7-bit reception)........................... 315 i 2 c stop condition receive or transmit mode ......... 316 int pin interrupt.......................................................... 73 internal oscillator switch timing............................... 118 lcd interrupt timing in quarter-duty cycle drive.... 270 lcd sleep entry/exit when slpen = 1 or cs = 00 . 272 pwm auto-shutdown ................................................ 207 firmware restart .............................................. 207 pwm direction change ............................................ 203 pwm direction change at near 100% duty cycle ... 204 pwm output (active-high)........................................ 198 pwm output (active-low) ........................................ 199 repeat start condition.............................................. 311 reset, wdt, ost and power-up timer ................... 375 send break character sequence ............................. 235 spi master mode (cke = 1, smp = 1) ..................... 383 spi mode (master mode).......................................... 285 spi slave mode (cke = 0) ....................................... 384 spi slave mode (cke = 1) ....................................... 384 synchronous reception (master mode, sren) ....... 239 synchronous transmission....................................... 237 synchronous transmission (through txen) ........... 237 time-out sequence case 1 ................................................................ 68 case 2 ................................................................ 69 case 3 ................................................................ 69 timer0 and timer1 external clock ........................... 377 timer1 incrementing edge........................................ 167 two speed start-up .................................................. 120 type-a in 1/2 mux, 1/2 bias drive ............................ 259 type-a in 1/2 mux, 1/3 bias drive ............................ 261 type-a in 1/3 mux, 1/2 bias drive ............................ 263 type-a in 1/3 mux, 1/3 bias drive ............................ 265 type-a in 1/4 mux, 1/3 bias drive ............................ 267 type-a/type-b in static drive................................... 258 type-b in 1/2 mux, 1/2 bias drive ............................ 260 type-b in 1/2 mux, 1/3 bias drive ............................ 262 type-b in 1/3 mux, 1/2 bias drive ............................ 264 type-b in 1/3 mux, 1/3 bias drive ............................ 266 type-b in 1/4 mux, 1/3 bias drive ............................ 268 usart synchronous receive (master/slave) ......... 382 usart synchronous transm ission (master/slave) . 381 wake-up from interrupt ............................................. 336 timing diagrams and specifications pll clock.................................................................. 373 timing parameter symbology........................................... 371 timing requirements i 2 c bus data ..................................................... 387, 386 spi mode .................................................................. 385 tmr0 register.................................................................... 37 tmr1h register ................................................................. 37 tmr1l register.................................................................. 37 tmr2 register.............................................................. 37, 45 tris ................................................................................. 352 trisa register............................................................. 38, 88 trisb ................................................................................. 91 trisb register............................................................. 38, 93 trisc ................................................................................. 95 trisc register............................................................. 38, 96 trisd ................................................................................. 98 trisd register............................................................. 38, 99 trise ............................................................................... 101 trise register........................................................... 38, 103 two-speed clock start-up mode...................................... 119 txcon (timer2/4/6) register .......................................... 177 txcon register ............................................................... 213 txreg ............................................................................. 217 txreg register ................................................................. 40 txsta register.......................................................... 40, 224 brgh bit .................................................................. 227 u usart synchronous master mode requirements, synchronous receive .............. 382 requirements, synchronous transmission...... 382 timing diagram, synchronous receive ........... 382 timing diagram, synchronous transmission... 381 v v ref . s ee adc reference voltage w wake-up on break ............................................................ 233 wake-up using interrupts ................................................. 336 watchdog timer (wdt)...................................................... 61 clock source .............................................................. 61 modes......................................................................... 62 period ......................................................................... 61 specifications ........................................................... 377 wcol ....................................................... 309, 312, 314, 316 wcol status flag.................................... 309, 312, 314, 316 wdtcon register ............................................................. 63 wpub register................................................................... 92 www address ................................................................. 414 www, on-line support ................... .................................. 13
pic16f193x/lf193x ds41364c-page 414 preliminary ? 2009 microchip technology inc. notes:
? 2009 microchip technology inc. preliminary ds41364c-page 415 pic16f193x/lf193x the microchip web site microchip provides online support via our www site at www.microchip.com. this web site is used as a means to make files and information easily available to customers. accessible by using your favorite internet browser, the web site contains the following information: ? product support ? data sheets and errata, application notes and sample programs, design resources, user?s guides and hardware support documents, latest software releases and archived software ? general technical support ? frequently asked questions (faq), technical support requests, online discussion groups, microchip consultant program member listing ? business of microchip ? product selector and ordering guides, latest microchip press releases, listing of seminars and events, listings of microchip sales offices, distributors and factory representatives customer change notification service microchip?s customer notification service helps keep customers current on microchip products. subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest. to register, access the microchip web site at www.microchip.com, click on customer change notification and follow the registration instructions. customer support users of microchip products can receive assistance through several channels: ? distributor or representative ? local sales office ? field application engineer (fae) ? technical support ? development systems information line customers should contact their distributor, representative or field application engineer (fae) for support. local sales offices are also available to help customers. a listing of sales offices and locations is included in the back of this document. technical support is available through the web site at: http://support.microchip.com
pic16f193x/lf193x ds41364c-page 416 preliminary ? 2009 microchip technology inc. reader response it is our intention to provide you with the best documentation possible to ensure successful use of your microchip prod- uct. if you wish to provide your comments on organization, clarity, subject matter, and ways in which our documentation can better serve you, please fax your comments to the technical publications manager at (480) 792-4150. please list the following information, and use this outline to provide us with your comments about this document. to : technical publications manager re: reader response total pages sent ________ from: name company address city / state / zip / country telephone: (_______) _________ - _________ application (optional): would you like a reply? y n device: literature number: questions: fax: (______) _________ - _________ ds41364c pic16f193x/lf193x 1. what are the best features of this document? 2. how does this document meet your hardware and software development needs? 3. do you find the organization of this document easy to follow? if not, why? 4. what additions to the document do you think would enhance the structure and subject? 5. what deletions from the document could be made without affecting the overall usefulness? 6. is there any incorrect or misleading information (what and where)? 7. how would you improve this document?
? 2009 microchip technology inc. preliminary ds41364c-page 417 pic16f193x/lf193x product identification system to order or obtain information, e. g., on pricing or delivery, refer to the factory or the listed sales office . part no. x /xx xxx pattern package temperature range device device: pic16f1933, pic16lf1933, pic16f1933t, pic16lf1933t (1) pic16f1934, pic16lf1934, pic16f1934t, pic16lf1934t (1) pic16f1936, pic16lf1936, pic16f1936t, pic16lf1936t (1) pic16f1937, pic16lf1937, pic16f1937t, pic16lf1937t (1) pic16f1938, pic16lf1938, pic16f1938t, pic16lf1938t (1) pic16f1939, pic16lf1939, pic16f1939t, pic16lf1939t (1) temperature range: i= -40 c to +85 c e= -40 c to +125 c package: mv = micro lead frame (uqfn) ml = micro lead frame (qfn) p = plastic dip pt = tqfp (thin quad flatpack) so = soic sp = skinny plastic dip ss = ssop pattern: 3-digit pattern code for qtp (blank otherwise) examples: a) pic16lf1937 - i/p = industrial temp., plastic dip package, low-voltage v dd limits. b) pic16f1934 - i/pt = industrial temp., tqfp package, standard v dd limits. c) pic16f1933 - e/ml = extended temp., qfn package, standard v dd limits. note 1: f = standard voltage range lf = low voltage range 2: t = in tape and reel for qfn, tqfp, soic and ssop packages only.
ds41364c-page 418 preliminary ? 2009 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: http://support.microchip.com web address: www.microchip.com atlanta duluth, ga tel: 678-957-9614 fax: 678-957-1455 boston westborough, ma tel: 774-760-0087 fax: 774-760-0088 chicago itasca, il tel: 630-285-0071 fax: 630-285-0075 cleveland independence, oh tel: 216-447-0464 fax: 216-447-0643 dallas addison, tx tel: 972-818-7423 fax: 972-818-2924 detroit farmington hills, mi tel: 248-538-2250 fax: 248-538-2260 kokomo kokomo, in tel: 765-864-8360 fax: 765-864-8387 los angeles mission viejo, ca tel: 949-462-9523 fax: 949-462-9608 santa clara santa clara, ca tel: 408-961-6444 fax: 408-961-6445 toronto mississauga, ontario, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific asia pacific office suites 3707-14, 37th floor tower 6, the gateway harbour city, kowloon hong kong tel: 852-2401-1200 fax: 852-2401-3431 australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-8528-2100 fax: 86-10-8528-2104 china - chengdu tel: 86-28-8665-5511 fax: 86-28-8665-7889 china - hong kong sar tel: 852-2401-1200 fax: 852-2401-3431 china - nanjing tel: 86-25-8473-2460 fax: 86-25-8473-2470 china - qingdao tel: 86-532-8502-7355 fax: 86-532-8502-7205 china - shanghai tel: 86-21-5407-5533 fax: 86-21-5407-5066 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-8203-2660 fax: 86-755-8203-1760 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 china - xiamen tel: 86-592-2388138 fax: 86-592-2388130 china - xian tel: 86-29-8833-7252 fax: 86-29-8833-7256 china - zhuhai tel: 86-756-3210040 fax: 86-756-3210049 asia/pacific india - bangalore tel: 91-80-3090-4444 fax: 91-80-3090-4080 india - new delhi tel: 91-11-4160-8631 fax: 91-11-4160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - yokohama tel: 81-45-471- 6166 fax: 81-45-471-6122 korea - daegu tel: 82-53-744-4301 fax: 82-53-744-4302 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - kuala lumpur tel: 60-3-6201-9857 fax: 60-3-6201-9859 malaysia - penang tel: 60-4-227-8870 fax: 60-4-227-4068 philippines - manila tel: 63-2-634-9065 fax: 63-2-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - hsin chu tel: 886-3-6578-300 fax: 886-3-6578-370 taiwan - kaohsiung tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan - taipei tel: 886-2-2500-6610 fax: 886-2-2508-0102 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - wels tel: 43-7242-2244-39 fax: 43-7242-2244-393 denmark - copenhagen tel: 45-4450-2828 fax: 45-4485-2829 france - paris tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - munich tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 spain - madrid tel: 34-91-708-08-90 fax: 34-91-708-08-91 uk - wokingham tel: 44-118-921-5869 fax: 44-118-921-5820 w orldwide s ales and s ervice 03/26/09


▲Up To Search▲   

 
Price & Availability of PIC16F1938T-ISP

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X