Part Number Hot Search : 
2SD12 5RH693 XXXGXX I7868A CDB5342 DS1239 06C10 BGD50
Product Description
Full Text Search
 

To Download PIC17C752T-33PT Datasheet File

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


  Datasheet File OCR Text:
  ? 2000 microchip technology inc. ds30289b-page 1 pic17c7xx microcontroller core features: ? only 58 single word instructions to learn  all single cycle instructions (121 ns), except for program branches and table reads/writes which are two-cycle  operating speed: - dc - 33 mhz clock input - dc - 121 ns instruction cycle  8 x 8 single-cycle hardware multiplier  interrupt capability  16 level deep hardware stack  direct, indirect, and relative addressing modes  internal/external program memory execution, capable of addressing 64 k x 16 program memory space peripheral features:  up to 66 i/o pins with individual direction control  10-bit, multi-channel analog-to-digital converter  high current sink/source for direct led drive  four capture input pins - captures are 16-bit, max resolution 121 ns  three pwm outputs (resolution is 1 to 10-bits)  tmr0: 16-bit timer/counter with 8-bit programmable prescaler  tmr1: 8-bit timer/counter  tmr2: 8-bit timer/counter  tmr3: 16-bit timer/counter  two universal synchronous asynchronous receiver transmitters (usart/sci) with independent baud rate generators  synchronous serial port (ssp) with spi? and i 2 c? modes (including i 2 c master mode) pin diagrams special microcontroller features:  power-on reset (por), power-up timer (pwrt) and oscillator start-up timer (ost)  watchdog timer (wdt) with its own on-chip rc oscillator for reliable operation  brown-out reset  code protection  power saving sleep mode  selectable oscillator options cmos technology:  low power, high speed cmos eprom technology  fully static design  wide operating voltage range (3.0v to 5.5v)  commercial and industrial temperature ranges  low power consumption - < 5 ma @ 5v, 4 mhz - 100 a typical @ 4.5v, 32 khz - < 1 a typical standby current @ 5v device memory program (x16) data (x8) pic17c752 8 k 678 pic17c756a 16 k 902 pic17c762 8 k 678 pic17c766 16 k 902 rf1/an5 rf0/an4 av dd av ss rg3/an0/v ref + rg2/an1/v ref - rg1/an2 rg0/an3 nc v ss v dd rg4/cap3 rg5/pwm3 rg7/tx2/ck2 rg6/rx2/dt2 ra4/rx1/dt1 ra5/tx1/ck1 rj0 rj1 rh6/an14 rh7/an15 rd1/ad9 rd0/ad8 re0/ale re1/oe re2/wr re3/cap4 mclr /v pp test v ss v dd rf7/an11 rf6/an10 rf5/an9 rf4/an8 rf3/an7 rf2/an6 nc rh2 rh3 rh4/an12 rh5/an13 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 987654 321 27 28 29 30 31 32 3334353637383940414243 pic17c76x ra0/int rb0/cap1 rb1/cap2 rb3/pwm2 rb4/tclk12 rb5/tclk3 rb2/pwm1 v ss nc osc2/clkout osc1/clkin v dd rb7/sdo ra3/sdi/sda ra2/ss /scl ra1/t0cki rd2/ad10 rd3/ad11 rd4/ad12 rd5/ad13 rd6/ad14 rd7/ad15 rc0/ad0 v dd nc v ss rc1/ad1 rc2/ad2 rc3/ad3 rc4/ad4 rc5/ad5 rc6/ad6 rc7/ad7 rb6/sck rj5 rj4 rj7 rj6 rj3 rj2 rh1 rh0 67 66 65 64 63 62 61 68 74 73 72 71 70 76 797877 80 838281 84 75 69 84 plcc high-performance 8-bit cmos eprom microcontrollers with 10-bit a/d
pic17c7xx ds30289b-page 2 ? 2000 microchip technology inc. pin diagrams cont.?d 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 9 8 7 6 5 4 3 2 1 68 67 66 65 64 63 62 61 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 ra0/int rb0/cap1 rb1/cap2 rb3/pwm2 rb4/tclk12 rb5/tclk3 rb2/pwm1 v ss nc osc2/clkout osc1/clkin v dd rb7/sdo ra3/sdi/sda ra2/ss /scl ra1/t0cki rd1/ad9 rd0/ad8 re0/ale re1/oe re2/wr re3/cap4 mclr /v pp test v ss v dd rf7/an11 rf6/an10 rf5/an9 rf4/an8 rf3/an7 rf2/an6 rd2/ad10 rd3/ad11 rd4/ad12 rd5/ad13 rd6/ad14 rd7/ad15 rc0/ad0 v dd nc v ss rc1/ad1 rc2/ad2 rc3/ad3 rc4/ad4 rc5/ad5 rc6/ad6 rc7/ad7 rf1/an5 rf0/an4 av dd av ss rg3/an0/v ref + rg2/an1/v ref - rg1/an2 rg0/an3 nc v ss v dd rg4/cap3 rg5/pwm3 rg7/tx2/ck2 rg6/rx2/dt2 ra4/rx1/dt1 ra5/tx1/ck1 nc rb6/sck pic17c75x 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 rd2/ad10 rd3/ad11 rd4/ad12 rd5/ad13 rd6/ad14 rd7/ad15 rc0/ad0 v dd v ss rc1/ad1 rc2/ad2 rc3/ad3 rc4/ad4 rc5/ad5 rc6/ad6 rc7/ad7 rd1/ad9 rd0/ad8 re0/ale re1/oe re2/wr re3/cap4 mclr /v pp test v ss v dd rf7/an11 rf6/an10 rf5/an9 rf4/an8 rf3/an7 rf2/an6 ra0/int rb0/cap1 rb1/cap2 rb3/pwm2 rb4/tclk12 rb5/tclk3 rb2/pwm1 v ss osc2/clkout osc1/clkin v dd rb7/sdo ra3/sdi/sda ra2/ss /scl ra1/t0cki rf1/an5 rf0/an4 av dd av ss rg3/an0/v ref + rg2/an1/v ref - rg1/an2 rg0/an3 v ss v dd rg4/cap3 rg5/pwm3 rg7/tx2/ck2 rg6/rx2/dt2 ra4/rx1/dt1 ra5/tx1/ck1 rb6/sck pic17c75x 68-pin plcc 64-pin tqfp
? 2000 microchip technology inc. ds30289b-page 3 pic17c7xx pin diagrams cont. ? d rf1/an5 rf0/an4 av dd av ss rg3/an0/v ref + rg2/an1/v ref - rg1/an2 rg0/an3 nc v ss v dd rg4/cap3 rg5/pwm3 rg7/tx2/ck2 rg6/rx2/dt2 ra4/rx1/dt1 ra5/tx1/ck1 rj0 rj1 rh6/an14 rh7/an15 rd1/ad9 rd0/ad8 re0/ale re1/oe re2/wr re3/cap4 mclr /v pp test v ss v dd rf7/an11 rf6/an10 rf5/an9 rf4/an8 rf3/an7 rf2/an6 nc rh2 rh3 rh4/an12 rh5/an13 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 987654321 27 28 29 30 31 32 33 34353637383940414243 pic17c76x ra0/int rb0/cap1 rb1/cap2 rb3/pwm2 rb4/tclk12 rb5/tclk3 rb2/pwm1 v ss nc osc2/clkout osc1/clkin v dd rb7/sdo ra3/sdi/sda ra2/ss /scl ra1/t0cki rd2/ad10 rd3/ad11 rd4/ad12 rd5/ad13 rd6/ad14 rd7/ad15 rc0/ad0 v dd nc v ss rc1/ad1 rc2/ad2 rc3/ad3 rc4/ad4 rc5/ad5 rc6/ad6 rc7/ad7 rb6/sck rj5 rj4 rj7 rj6 rj3 rj2 rh1 rh0 67 66 65 64 63 62 61 68 74 73 72 71 70 76 797877 80 838281 84 75 69 84-pin plcc 3 4 5 6 7 8 9 10 11 12 13 14 15 16 48 47 46 45 44 43 42 41 40 39 64 63 62 61 21 22 23 24 25 26 27 28 29 30 31 32 rd2/ad10 rd3/ad11 rd4/ad12 rd5/ad13 rd6/ad14 rd7/ad15 rc0/ad0 v dd v ss rc1/ad1 rc2/ad2 rc3/ad3 rc4/ad4 rc5/ad5 rc6/ad6 rc7/ad7 rd1/ad9 rd0/ad8 re0/ale re1/oe re2/wr re3/cap4 mclr /v pp test v ss v dd rf7/an11 rf6/an10 rf5/an9 rf4/an8 rf3/an7 rf2/an6 ra0/int rb0/cap1 rb1/cap2 rb3/pwm2 rb4/tclk12 rb5/tclk3 rb2/pwm1 v ss osc2/clkout osc1/clkin v dd rb7/sdo ra3/sdi/sda ra2/ss /scl ra1/t0cki rf1/an5 rf0/an4 av dd av ss rg3/an0/v ref + rg2/an1/v ref - rg1/an2 rg0/an3 v ss v dd rg4/cap3 rg5/pwm3 rg7/tx2/ck2 rg6/rx2/dt2 ra4/rx1/dt1 ra5/tx1/ck1 rb6/sck rj7 rj6 rh1 rh0 1 2 rh2 rh3 17 18 rh4/an12 rh5/an13 rh6/an14 rh7/an15 rj1 rj0 37 rj3 rj2 50 49 rj5 rj4 19 20 33 34 35 36 38 58 57 56 55 54 53 52 51 60 59 68 67 66 65 72 71 70 69 74 73 78 77 76 75 79 80 pic17c76x 80-pin tqfp
pic17c7xx ds30289b-page 4 ? 2000 microchip technology inc. table of contents 1.0 overview .................................................................................................................... .................................... 7 2.0 device varieties ............................................................................................................ ................................. 9 3.0 architectural overview ...................................................................................................... ........................... 11 4.0 on-chip oscillator circuit .................................................................................................. ........................... 17 5.0 reset....................................................................................................................... ..................................... 23 6.0 interrupts.................................................................................................................. .................................... 33 7.0 memory organization......................................................................................................... .......................... 43 8.0 table reads and table writes ................................................................................................ .................... 59 9.0 hardware multiplier ......................................................................................................... ............................. 67 10.0 i/o ports.................................................................................................................. ..................................... 71 11.0 overview of timer resources................................................................................................ ...................... 95 12.0 timer0..................................................................................................................... ..................................... 97 13.0 timer1, timer2, timer3, pwms and captures .................................................................................. ........ 101 14.0 universal synchronous asynchronous receiver transmitter (usart) modules...................................... 117 15.0 master synchronous serial port (mssp) module............................................................................... ....... 133 16.0 analog-to-digital converter (a/d) module ................................................................................... .............. 179 17.0 special features of the cpu ................................................................................................ ..................... 191 18.0 instruction set summary.................................................................................................... ........................ 197 19.0 development support ........................................................................................................ ........................ 233 20.0 pic17c7xx electrical characteristics ....................................................................................... ................ 239 21.0 pic17c7xx dc and ac characteristics........................................................................................ ............ 267 22.0 packaging information ...................................................................................................... ......................... 281 appendix a: modifications ....................................................................................................... ................................ 287 appendix b: compatibility....................................................................................................... ................................. 287 appendix c: what ? s new .......................................................................................................................... ............... 288 appendix d: what ? s changed...................................................................................................................... ............ 288 index .......................................................................................................................... ................................................ 289 on-line support ................................................................................................................ .......................................... 299 reader response ................................................................................................................ ....................................... 300 product identification system.................................................................................................. .................................... 301
? 2000 microchip technology inc. ds30289b-page 5 pic17c7xx 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 re fined and enhanced as new volumes and updates are introduced. if you have any questions or comments regarding 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 sheet, 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 version number, (e.g., ds30000a is version a of document ds30000). errata an errata sheet, describing minor operational differences from 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 lit- erature 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.
pic17c7xx ds30289b-page 6 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 7 pic17c7xx 1.0 overview this data sheet covers the pic17c7xx group of the pic17cxxx family of microcontrollers. the following devices are discussed in this data sheet:  pic17c752  pic17c756a  pic17c762  pic17c766 the pic17c7xx devices are 68/84-pin, eprom based members of the versatile pic17cxxx family of low cost, high performance, cmos, fully static, 8-bit microcontrollers. all picmicro ? microcontrollers employ an advanced risc architecture. the pic17cxxx has enhanced core features, 16-level deep stack, and multiple internal and external interrupt sources. the separate instruc- tion and data buses of the harvard architecture allow a 16-bit wide instruction word with a separate 8-bit wide data path. the two stage instruction pipeline allows all instructions to execute in a single cycle, except for pro- gram branches (which require two cycles). a total of 58 instructions (reduced instruction set) are available. additionally, a large register set gives some of the architectural innovations used to achieve a very high performance. for mathematical intensive applications, all devices have a single cycle 8 x 8 hardware multiplier. pic17cxxx microcontrollers typically achieve a 2:1 code compression and a 4:1 speed improvement over other 8-bit microcontrollers in their class. pic17c7xx devices have up to 902 bytes of ram and 66 i/o pins. in addition, the pic17c7xx adds several peripheral features, useful in many high performance applications, including:  four timer/counters  four capture inputs  three pwm outputs  two independent universal synchronous asyn- chronous receiver transmitters (usarts)  an a/d converter (multi-channel, 10-bit resolution)  a synchronous serial port (spi and i 2 c w/ master mode) these special features reduce external components, thus reducing cost, enhancing system reliability and reducing power consumption. there are four oscillator options, of which the single pin rc oscillator provides a low cost solution, the lf oscil- lator is for low frequency crystals and minimizes power consumption, xt is a standard crystal and the ec is for external clock input. the sleep (power-down) mode offers additional power saving. wake-up from sleep can occur through several external and internal interrupts and device resets. a highly reliable watchdog timer with its own on-chip rc oscillator provides protection against software mal- function. there are four configuration options for the device operational mode:  microprocessor  microcontroller  extended microcontroller  protected microcontroller the microprocessor and extended microcontroller modes allow up to 64k-words of external program memory. the device also has brown-out reset circuitry. this allows a device reset to occur if the device v dd falls below the brown-out voltage trip point (bv dd ). the chip will remain in brown-out reset until v dd rises above bv dd . a uv erasable, cerquad packaged version (compat- ible with plcc), is ideal for code development, while the cost-effective one-time-programmable (otp) ver- sion is suitable for production in any volume. the pic17c7xx fits perfectly in applications that require extremely fast execution of complex software programs. these include applications ranging from precise motor control and industrial process control to automotive, instrumentation, and telecom applications. the eprom technology makes customization of appli- cation programs (with unique security codes, combina- tions, model numbers, parameter storage, etc.) fast and convenient. small footprint package options (including die sales) make the pic17c7xx ideal for applications with space limitations that require high performance. high speed execution, powerful peripheral features, flexible i/o, and low power consumption all at low cost make the pic17c7xx ideal for a wide range of embed- ded control applications. 1.1 family and upward compatibility the pic17cxxx family of microcontrollers have archi- tectural enhancements over the pic16c5x and pic16cxx families. these enhancements allow the device to be more efficient in software and hardware requirements. refer to appendix a for a detailed list of enhancements and modifications. code written for pic16c5x or pic16cxx can be easily ported to pic17cxxx devices (appendix b). 1.2 development support the pic17cxxx family is supported by a full featured macro assembler, a software simulator, an in-circuit emulator, a universal programmer, a ? c ? compiler and fuzzy logic support tools. for additional information, see section 19.0.
pic17c7xx ds30289b-page 8 ? 2000 microchip technology inc. table 1-1: pic17cxxx family of devices features pic17c42a pic17c43 pic17c44 pic17c752 pic17c756a pic17c762 pic17c766 maximum frequency of operation 33 mhz 33 mhz 33 mhz 33 mhz 33 mhz 33 mhz 33 mhz operating voltage range 2.5 - 6.0v 2.5 - 6.0v 2.5 - 6.0v 3.0 - 5.5v 3.0 - 5.5v 3.0 - 5.5v 3.0 - 5.5v program memory ( x16) (eprom) 2 k 4 k 8 k 8 k 16 k 8 k 16 k (rom) ? ? ? ? ? ? ? data memory (bytes) 232 454 454 678 902 678 902 hardware multiplier (8 x 8) yes yes yes yes ye s yes yes timer0 (16-bit + 8-bit postscaler) yes yes yes yes ye s yes yes timer1 (8-bit) yes yes yes yes ye s yes yes timer2 (8-bit) yes yes yes yes ye s yes yes timer3 (16-bit) yes yes yes yes ye s yes yes capture inputs (16-bit) 2 2 24 444 pwm outputs (up to 10-bit) 2 2 23 333 usart/sci 1 1 12 222 a/d channels (10-bit) ? ? ? 12 12 16 16 ssp (spi/i 2 c w/master mode) ? ? ? yes ye s yes yes power-on reset yes yes yes yes ye s yes yes watchdog timer yes yes yes yes ye s yes yes external interrupts yes yes yes yes ye s yes yes interrupt sources 11 11 11 18 18 18 18 code protect yes yes yes yes ye s yes yes brown-out reset ? ? ? yes ye s yes yes in-circuit serial programming ? ? ? yes ye s yes yes i/o pins 33 33 33 50 50 66 66 i/o high current capability source 25 ma 25 ma 25 ma 25 ma 25 ma 25 ma 25 ma sink 25 ma (1) 25 ma (1) 25 ma (1) 25 ma (1) 25 ma (1) 25 ma (1) 25 ma (1) package types 40-pin dip 44-pin plcc 44-pin mqfp 44-pin tqfp 40-pin dip 44-pin plcc 44-pin mqfp 44-pin tqfp 40-pin dip 44-pin plcc 44-pin mqfp 44-pin tqfp 64-pin tqfp 68-pin plcc 64-pin tqfp 68-pin plcc 80-pin tqfp 84-pin plcc 80-pin tqfp 84-pin plcc note 1: pins ra2 and ra3 can sink up to 60 ma.
? 2000 microchip technology inc. ds30289b-page 9 pic17c7xx 2.0 device varieties each device has a variety of frequency ranges and packaging options. depending on application and pro- duction requirements, the proper device option can be selected using the information in the pic17c7xx prod- uct selection system section at the end of this data sheet. when placing orders, please use the ? pic17c7xx product identification system ? at the back of this data sheet to specify the correct part num- ber. when discussing the functionality of the device, memory technology and voltage range does not matter. there are two memory type options. these are speci- fied in the middle characters of the part number. 1. c , as in pic17 c 756a. these devices have eprom type memory. 2. cr , as in pic17 cr 756a. these devices have rom type memory. all these devices operate over the standard voltage range. devices are also offered which operate over an extended voltage range (and reduced frequency range). table 2-1 shows all possible memory types and voltage range designators for a particular device. these designators are in bold typeface. table 2-1: device memory varieties 2.1 uv erasable devices the uv erasable version, offered in cerquad pack- age, is optimal for prototype development and pilot programs. the uv erasable version can be erased and repro- grammed to any of the configuration modes. third party programmers also are available; refer to the third party guide for a list of sources. 2.2 one-time-programmable (otp) devices the availability of otp devices is especially useful for customers expecting frequent code changes and updates. the otp devices, packaged in plastic packages, permit the user to program them once. in addition to the program memory, the configuration bits must be programmed. 2.3 quick-turnaround-production (qtp) devices microchip offers a qtp programming service for fac- tory production orders. this service is made available for users who choose not to program a medium to high quantity of units and whose code patterns have stabi- lized. the devices are identical to the otp devices but with all eprom locations and configuration options already programmed by the factory. certain code and prototype verification procedures apply before produc- tion shipments are available. please contact your local microchip technology sales office for more details. 2.4 serialized quick-turnaround production (sqtp sm ) devices microchip offers a unique programming service, where a few user defined locations in each device are pro- grammed with different serial numbers. the serial num- bers may be random, pseudo-random or sequential. serial programming allows each device to have a unique number which can serve as an entry code, password or id number. 2.5 read only memory (rom) devices microchip offers masked rom versions of several of the highest volume parts, thus giving customers a low cost option for high volume, mature products. rom devices do not allow serialization information in the program memory space. for information on submitting rom code, please con- tact your regional sales office. memory type voltage range standard extended eprom pic17 c xxx pic17 lc xxx rom pic17 cr xxx pic17 lcr xxx note: not all memory technologies are available for a particular device. note: presently, no rom versions of the pic17c7xx devices are available.
pic17c7xx ds30289b-page 10 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 11 pic17c7xx 3.0 architectural overview the high performance of the pic17cxxx can be attrib- uted to a number of architectural features, commonly found in risc microprocessors. to begin with, the pic17cxxx uses a modified harvard architecture. this architecture has the program and data accessed from separate memories. so, the device has a program memory bus and a data memory bus. this improves bandwidth over traditional von neumann architecture, where program and data are fetched from the same memory (accesses over the same bus). separating program and data memory further allows instructions to be sized differently than the 8-bit wide data word. pic17cxxx opcodes are 16-bits wide, enabling single word instructions. the full 16-bit wide program memory bus fetches a 16-bit instruction in a single cycle. a two- stage pipeline overlaps fetch and execution of instruc- tions. consequently, all instructions execute in a single cycle (121 ns @ 33 mhz), except for program branches and two special instructions that transfer data between program and data memory. the pic17cxxx can address up to 64k x 16 of pro- gram memory space. the pic17c752 and pic17c762 integrate 8k x 16 of eprom program memory on-chip. the pic17c756a and pic17c766 integrate 16k x 16 eprom program memory on-chip. a simplified block diagram is shown in figure 3-1. the descriptions of the device pins are listed in table 3-1. program execution can be internal only (microcontrol- ler or protected microcontroller mode), external only (microprocessor mode), or both (extended microcon- troller mode). extended microcontroller mode does not allow code protection. the pic17cxxx can directly or indirectly address its register files or data memory. all special function regis- ters, including the program counter (pc) and working register (wreg), are mapped in data memory. the pic17cxxx has an orthogonal (symmetrical) instruction set that makes it possible to carry out any operation on any register using any addressing mode. this symmetri- cal nature and lack of ? special optimal situations ? make programming with the pic17cxxx simple, yet efficient. in addition, the learning curve is reduced significantly. one of the pic17cxxx family architectural enhance- ments from the pic16cxx family, allows two file regis- ters to be used in some two operand instructions. this allows data to be moved directly between two registers without going through the wreg register, thus increas- ing performance and decreasing program memory usage. the pic17cxxx devices contain an 8-bit alu and working register. the alu is a general purpose arith- metic unit. it performs arithmetic and boolean functions between data in the working register and any register file. the wreg register is an 8-bit working register used for alu operations. all pic17cxxx devices have an 8 x 8 hardware multi- plier. this multiplier generates a 16-bit result in a single cycle. the alu is 8-bits wide and capable of addition, sub- traction, shift and logical operations. unless otherwise mentioned, arithmetic operations are two's comple- ment in nature. depending on the instruction executed, the alu may affect the values of the carry (c), digit carry (dc), zero (z) and overflow (ov) bits in the alusta register. the c and dc bits operate as a borrow and digit borrow out bit, respectively, in subtraction. see the sublw and subwf instructions for examples. signed arithmetic is comprised of a magnitude and a sign bit. the overflow bit indicates if the magnitude overflows and causes the sign bit to change state. that is, if the result of 8-bit signed operations is greater than 127 (7fh), or less than -128 (80h). signed math can have greater than 7-bit values (mag- nitude), if more than one byte is used. the overflow bit only operates on bit6 (msb of magnitude) and bit7 (sign bit) of each byte value in the alu. that is, the overflow bit is not useful if trying to implement signed math where the magnitude, for example, is 11-bits. if the signed math values are greater than 7-bits (such as 15-, 24-, or 31-bit), the algorithm must ensure that the low order bytes of the signed value ignore the over- flow status bit. example 3-1 shows two cases of doing signed arith- metic. the carry (c) bit and the overflow (ov) bit are the most important status bits for signed math operations. example 3-1: 8-bit math addition hex value signed values unsigned values ffh + 01h = 00h c bit = 1 ov bit = 0 dc bit = 1 z bit = 1 -1 + 1 = 0 (feh) c bit = 1 ov bit = 0 dc bit = 1 z bit = 1 255 + 1 = 256 00h c bit = 1 ov bit = 0 dc bit = 1 z bit = 1 hex value signed values unsigned values 7fh + 01h = 80h c bit = 0 ov bit = 1 dc bit = 1 z bit = 0 127 + 1 = 128 00h c bit = 0 ov bit = 1 dc bit = 1 z bit = 0 127 + 1 = 128 c bit = 0 ov bit = 1 dc bit = 1 z bit = 0
pic17c7xx ds30289b-page 12 ? 2000 microchip technology inc. figure 3-1: pic17c752/756a block diagram rb0/cap1 rb1/cap2 rb2/pwm1 rb3/pwm2 rb4/tclk12 rb5/tclk3 rb6/sck rb7/sdo ra0/int ra1/t0cki ra2/ss /scl ra3/sdi/sda ra4/rx1/dt1 ra5/tx1/ck1 porta rc0/ad0 rc1/ad1 rc2/ad2 rc3/ad3 rc4/ad4 rc5/ad5 rc6/ad6 rc7/ad7 rd0/ad8 rd1/ad9 rd2/ad10 rd3/ad11 rd4/ad12 rd5/ad13 rd6/ad14 rd7/ad15 re0/ale re1/oe re2/wr re3/cap4 rf0/an4 rf1/an5 rf2/an6 rf3/an7 rf4/an8 rf5/an9 rf6/an10 rf7/an11 rg0/an3 rg1/an2 rg2/an1/v ref - rg3/an0/v ref + rg4/cap3 rg5/pwm3 rg6/rx2/dt2 rg7/tx2/ck2 timer0 clock generator power-on reset watchdog timer test mode select v dd , v ss osc1, mclr , v pp test q1, q2, chip_reset & other control system bus interface decode data latch address program memory (eprom) table pointer<16> stack 16 x 16 ta b l e rom latch <16> instruction decode control outputs ir latch <16> f1 f9 16k x 16 pch pclath<8> literal ram data latch bsr data ram 902 x 8 latch pcl read/write decode for mapped in data space wreg<8> bitop alu shifter 8 x 8 mult prodh prodl registers latch <16> address buffer usart1 timer1 timer3 timer2 pwm1 pwm2 pwm3 capture1 capture3 capture2 interrupt module 10-bit a/d portb portc portd porte portf portg ad<15:0> signals q3, q4 osc2 data bus<8> 16 16 16 16 8 8 8 8 12 16 ir<16> ssp portc, portd ale, wr , oe , porte ir <7:0> bsr <7:4> usart2 capture4 brown-out reset 17c756a 17c752 8k x 16 17c756a 17c752 678 x 8
? 2000 microchip technology inc. ds30289b-page 13 pic17c7xx figure 3-2: pic17c762/766 block diagram rb0/cap1 rb1/cap2 rb2/pwm1 rb3/pwm2 rb4/tclk12 rb5/tclk3 rb6/sck rb7/sdo ra0/int ra1/t0cki ra2/ss /scl ra3/sdi/sda ra4/rx1/dt1 ra5/tx1/ck1 porta rc0/ad0 rc1/ad1 rc2/ad2 rc3/ad3 rc4/ad4 rc5/ad5 rc6/ad6 rc7/ad7 rd0/ad8 rd1/ad9 rd2/ad10 rd3/ad11 rd4/ad12 rd5/ad13 rd6/ad14 rd7/ad15 re0/ale re1/oe re2/wr re3/cap4 rf0/an4 rf1/an5 rf2/an6 rf3/an7 rf4/an8 rf5/an9 rf6/an10 rf7/an11 rg0/an3 rg1/an2 rg2/an1/v ref - rg3/an0/v ref + rg4/cap3 rg5/pwm3 rg6/rx2/dt2 rg7/tx2/ck2 timer0 clock generator power-on reset watchdog timer te s t m o d e select v dd , v ss osc1, mclr , v pp test q1, q2, chip_reset & other control system bus interface decode data latch address program memory (eprom) table pointer<16> stack 16 x 16 ta b l e rom latch <16> instruction decode control outputs ir latch <16> fsr0 fsr1 16k x 16, pch pclath<8> literal ram data latch bsr data ram 902 x 8 latch pcl read/write decode for mapped in data space wreg<8> bitop alu shifter 8 x 8 mult prodh prodl registers latch <16> address buffer usart1 timer1 timer3 timer2 pwm1 pwm2 pwm3 capture1 capture3 capture2 interrupt module 10-bit a/d portb portc portd porte portf portg ad<15:0> signals q3, q4 osc2 data bus<8> 16 16 16 16 8 8 8 8 12 16 ir<16> ssp portc, portd ale, wr , oe , porte ir <7:0> bsr <7:4> usart2 capture4 rh0 rh1 rh2 rh3 rh4/an12 rh5/an13 rh6/an14 rh7/an15 porth rj0 rj1 rj2 rj3 rj4 rj5 rj6 rj7 portj brown-out reset a vdd , a vss 17c766 17c762 678 x 8 and 17c766 and 17c762 8k x 16
pic17c7xx ds30289b-page 14 ? 2000 microchip technology inc. table 3-1: pinout descriptions name pic17c75x pic17c76x description dip no. plcc no. tqfp no. plcc no. qfp no. i/o/p type buffer type osc1/clkin 47 50 39 62 49 i st oscillator input in crystal/resonator or rc oscillator mode. external clock input in external clock mode. osc2/clkout4851406350o ? oscillator output. connects to crystal or resonator in crystal oscillator mode. in rc oscillator or external clock modes, osc2 pin outputs clkout which has one fourth the frequency (f osc /4) of osc1 and denotes the instruction cycle rate. mclr /v pp 15 16 7 20 9 i/p st master clear (reset) input or programming voltage (v pp ) input. this is the active low reset input to the device. porta pins have individual differentiations that are listed in the following descriptions: ra0/int 56 60 48 72 58 i st ra0 can also be selected as an external inter- rupt input. interrupt can be configured to be on positive or negative edge. input only pin. ra1/t0cki 41 44 33 56 43 i st ra1 can also be selected as an external inter- rupt input and the interrupt can be configured to be on positive or negative edge. ra1 can also be selected to be the clock input to the timer0 timer/counter. input only pin. ra2/ss /scl 42 45 34 57 44 i/o (2) st ra2 can also be used as the slave select input for the spi or the clock input for the i 2 c bus. high voltage, high current, open drain port pin. ra3/sdi/sda 4346355845i/o (2) st ra3 can also be used as the data input for the spi or the data for the i 2 c bus. high voltage, high current, open drain port pin. ra4/rx1/dt1 40 43 32 51 38 i/o (1) st ra4 can also be selected as the usart1 (sci) asynchronous receive or usart1 (sci) synchronous data. output available from usart only. ra5/tx1/ck1 3942315037i/o (1) st ra5 can also be selected as the usart1 (sci) asynchronous transmit or usart1 (sci) synchronous clock. output available from usart only. portb is a bi-directional i/o port with software configurable weak pull-ups. rb0/cap1 55 59 47 71 57 i/o st rb0 can also be the capture1 input pin. rb1/cap2 54 58 46 70 56 i/o st rb1 can also be the capture2 input pin. rb2/pwm1 50 54 42 66 52 i/o st rb2 can also be the pwm1 output pin. rb3/pwm2 53 57 45 69 55 i/o st rb3 can also be the pwm2 output pin. rb4/tclk12 52 56 44 68 54 i/o st rb4 can also be the external clock input to timer1 and timer2. rb5/tclk3 51 55 43 67 53 i/o st rb5 can also be the external clock input to timer3. rb6/sck 44 47 36 59 46 i/o st rb6 can also be used as the master/slave clock for the spi. rb7/sdo 45 48 37 60 47 i/o st rb7 can also be used as the data output for the spi. legend: i = input only; o = output only; i/o = input/output; p = power; ? = not used; ttl = ttl input; st = schmitt trigger input note 1: the output is only available by the peripheral operation. 2: open drain input/output pin. pin forced to input upon any device reset.
? 2000 microchip technology inc. ds30289b-page 15 pic17c7xx portc is a bi-directional i/o port. rc0/ad0 2 3 58 3 72 i/o ttl this is also the least significant byte (lsb) of the 16-bit wide system bus in microprocessor mode or extended microcontroller mode. in multiplexed system bus configuration, these pins are address output as well as data input or output. rc1/ad1 63 67 55 83 69 i/o ttl rc2/ad2 62 66 54 82 68 i/o ttl rc3/ad3 61 65 53 81 67 i/o ttl rc4/ad4 60 64 52 80 66 i/o ttl rc5/ad5 58 63 51 79 65 i/o ttl rc6/ad6 58 62 50 78 64 i/o ttl rc7/ad7 57 61 49 77 63 i/o ttl portd is a bi-directional i/o port. rd0/ad8 10 11 2 15 4 i/o ttl this is also the most significant byte (msb) of the 16-bit system bus in microprocessor mode or extended microcontroller mode. in multi- plexed system bus configuration, these pins are address output as well as data input or output. rd1/ad9 9 10 1 14 3 i/o ttl rd2/ad10 8 9 64 9 78 i/o ttl rd3/ad11 7 8 63 8 77 i/o ttl rd4/ad12 6 7 62 7 76 i/o ttl rd5/ad13 5 6 61 6 75 i/o ttl rd6/ad14 4 5 60 5 74 i/o ttl rd7/ad15 3 4 59 4 73 i/o ttl porte is a bi-directional i/o port. re0/ale 11 12 3 16 5 i/o ttl in microprocessor mode or extended microcon- troller mode, re0 is the address latch enable (ale) output. address should be latched on the falling edge of ale output. re1/oe 12 13 4 17 6 i/o ttl in microprocessor or extended microcontroller mode, re1 is the output enable (oe ) control output (active low). re2/wr 13 14 5 18 7 i/o ttl in microprocessor or extended microcontroller mode, re2 is the write enable (wr ) control output (active low). re3/cap4 14 15 6 19 8 i/o st re3 can also be the capture4 input pin. portf is a bi-directional i/o port. rf0/an4 26 28 18 36 24 i/o st rf0 can also be analog input 4. rf1/an5 25 27 17 35 23 i/o st rf1 can also be analog input 5. rf2/an6 24 26 16 30 18 i/o st rf2 can also be analog input 6. rf3/an7 23 25 15 29 17 i/o st rf3 can also be analog input 7. rf4/an8 22 24 14 28 16 i/o st rf4 can also be analog input 8. rf5/an9 21 23 13 27 15 i/o st rf5 can also be analog input 9. rf6/an10 20 22 12 26 14 i/o st rf6 can also be analog input 10. rf7/an11 19 21 11 25 13 i/o st rf7 can also be analog input 11. table 3-1: pinout descriptions (continued) name pic17c75x pic17c76x description dip no. plcc no. tqfp no. plcc no. qfp no. i/o/p type buffer type legend: i = input only; o = output only; i/o = input/output; p = power; ? = not used; ttl = ttl input; st = schmitt trigger input note 1: the output is only available by the peripheral operation. 2: open drain input/output pin. pin forced to input upon any device reset.
pic17c7xx ds30289b-page 16 ? 2000 microchip technology inc. portg is a bi-directional i/o port. rg0/an3 32 34 24 42 30 i/o st rg0 can also be analog input 3. rg1/an2 31 33 23 41 29 i/o st rg1 can also be analog input 2. rg2/an1/v ref - 30 32 22 40 28 i/o st rg2 can also be analog input 1, or the ground reference voltage. rg3/an0/v ref + 29 31 21 39 27 i/o st rg3 can also be analog input 0, or the positive reference voltage. rg4/cap3 35 38 27 46 33 i/o st rg4 can also be the capture3 input pin. rg5/pwm3 36 39 28 47 34 i/o st rg5 can also be the pwm3 output pin. rg6/rx2/dt2 38 41 30 49 36 i/o st rg6 can also be selected as the usart2 (sci) asynchronous receive or usart2 (sci) synchronous data. rg7/tx2/ck2 37 40 29 48 35 i/o st rg7 can also be selected as the usart2 (sci) asynchronous transmit or usart2 (sci) synchronous clock. porth is a bi-directional i/o port. porth is only available on the pic17c76x devices. rh0 ??? 10 79 i/o st rh1 ??? 11 80 i/o st rh2 ??? 12 1 i/o st rh3 ??? 13 2 i/o st rh4/an12 ??? 31 19 i/o st rh4 can also be analog input 12. rh5/an13 ??? 32 20 i/o st rh5 can also be analog input 13. rh6/an14 ??? 33 21 i/o st rh6 can also be analog input 14. rh7/an15 ??? 34 22 i/o st rh7 can also be analog input 15. portj is a bi-directional i/o port. portj is only available on the pic17c76x devices. rj0 ??? 52 39 i/o st rj1 ??? 53 40 i/o st rj2 ??? 54 41 i/o st rj3 ??? 55 42 i/o st rj4 ??? 73 59 i/o st rj5 ??? 74 60 i/o st rj6 ??? 75 61 i/o st rj7 ??? 76 62 i/o st test 16 17 8 21 10 i st test mode selection control input. always tie to v ss for normal operation. v ss 17, 33, 49, 64 19, 36, 53, 68 9, 25, 41, 56 23, 44, 65, 84 11, 31, 51, 70 p ground reference for logic and i/o pins. v dd 1, 18, 34, 46 2, 20, 37, 49, 10, 26, 38, 57 24, 45, 61, 2 12, 32, 48, 71 p positive supply for logic and i/o pins. av ss 28 30 20 38 26 p ground reference for a/d converter. this pin must be at the same potential as v ss . av dd 27 29 19 37 25 p positive supply for a/d converter. this pin must be at the same potential as v dd . nc ? 1, 18, 35, 52 ? 1, 22, 43, 64 ? no connect. leave these pins unconnected. table 3-1: pinout descriptions (continued) name pic17c75x pic17c76x description dip no. plcc no. tqfp no. plcc no. qfp no. i/o/p type buffer type legend: i = input only; o = output only; i/o = input/output; p = power; ? = not used; ttl = ttl input; st = schmitt trigger input note 1: the output is only available by the peripheral operation. 2: open drain input/output pin. pin forced to input upon any device reset.
? 2000 microchip technology inc. ds30289b-page 17 pic17c7xx 4.0 on-chip oscillator circuit the internal oscillator circuit is used to generate the device clock. four device clock periods generate an internal instruction clock (t cy ). there are four modes that the oscillator can operate in. they are selected by the device configuration bits dur- ing device programming. these modes are:  lf low frequency (f osc 2 mhz)  xt standard crystal/resonator frequency (2 mhz f osc 33 mhz)  ec external clock input (default oscillator configuration)  rc external resistor/capacitor (f osc 4 mhz) there are two timers that offer necessary delays on power-up. one is the oscillator start-up timer (ost), intended to keep the chip in reset until the crystal oscillator is stable. the other is the power-up timer (pwrt), which provides a fixed delay of 96 ms (nomi- nal) on por and bor. the pwrt is designed to keep the part in reset while the power supply stabilizes. with these two timers on-chip, most applications need no external reset circuitry. sleep mode is designed to offer a very low current power-down mode. the user can wake from sleep through external reset, watchdog timer reset, or through an interrupt. several oscillator options are made available to allow the part to better fit the application. the rc oscillator option saves system cost while the lf crystal option saves power. configuration bits are used to select var- ious options. 4.1 oscillator configurations 4.1.1 oscillator types the pic17cxxx can be operated in four different oscil- lator modes. the user can program two configuration bits (fosc1:fosc0) to select one of these four modes:  lf low power crystal  xt crystal/resonator  ec external clock input  rc resistor/capacitor the main difference between the lf and xt modes is the gain of the internal inverter of the oscillator circuit, which allows the different frequency ranges. for more details on the device configuration bits, see section 17.0. 4.1.2 crystal oscillator/ceramic resonators in xt or lf modes, a crystal or ceramic resonator is con- nected to the osc1/clkin and osc2/clkout pins to establish oscillation (figure 4-2). the pic17cxxx oscil- lator design requires the use of a parallel cut crystal. use of a series cut crystal may give a frequency out of the crystal manufacturers specifications. for frequencies above 24 mhz, it is common for the crystal to be an overtone mode crystal. use of overtone mode crystals require a tank circuit to attenuate the gain at the fundamental frequency. figure 4-3 shows an example circuit. 4.1.3 oscillator/resonator start-up as the device voltage increases from vss, the oscillator will start its oscillations. the time required for the oscil- lator to start oscillating depends on many factors. these include:  crystal/resonator frequency  capacitor values used (c1 and c2)  device v dd rise time  system temperature  series resistor value (and type) if used  oscillator mode selection of device (which selects the gain of the internal oscillator inverter) figure 4-1 shows an example of a typical oscillator/ resonator start-up. the peak-to-peak voltage of the oscillator waveform can be quite low (less than 50% of device v dd ) when the waveform is centered at v dd /2 (refer to parameter #d033 and parameter #d043 in the electrical specification section). figure 4-1: oscillator/ resonator start-up characteristics v dd crystal start-up time time
pic17c7xx ds30289b-page 18 ? 2000 microchip technology inc. figure 4-2: crystal or ceramic resonator operation (xt or lf osc configuration) table 4-1: capacitor selection for ceramic resonators figure 4-3: crystal operation, overtone crystals (xt osc configuration) table 4-2: capacitor selection for crystal oscillator oscillator type resonator frequency capacitor range c1 = c2 (1) lf 455 khz 2.0 mhz 15 - 68 pf 10 - 33 pf xt 4.0 mhz 8.0 mhz 16.0 mhz 22 - 68 pf 33 - 100 pf 33 - 100 pf higher capacitance increases the stability of the oscillator, but also increases the start-up time. these values are for design guidance only. since each resonator has its own characteristics, the user should consult the resonator manu- facturer for appropriate values of external components. note 1: these values include all board capacitances on this pin. actual capacitor value depends on board capacitance. resonators used: 455 khz panasonic efo-a455k04b 0.3% 2.0 mhz murata erie csa2.00mg 0.5% 4.0 mhz murata erie csa4.00mg 0.5% 8.0 mhz murata erie csa8.00mt 0.5% 16.0 mhz murata erie csa16.00mx 0.5% resonators used did not have built-in capacitors. see table 4-1 and table 4-2 for recommended values of c1 and c2. note 1: a series resistor (rs) may be required for at strip cut crystals. c1 c2 xtal osc2 (note 1) osc1 rf sleep pic17cxxx to in t e r n a l logic osc type freq c1 (2) c2 (2) lf 32 khz 1 mhz 2 mhz 100-150 pf 10-68 pf 10-68 pf 100-150 pf 10-68 pf 10-68 pf xt 2 mhz 4 mhz 8 mhz 16 mhz 24 mhz (1) 32 mhz (1) 47-100 pf 15-68 pf 15-47 pf 15-47 pf 15-47 pf 10-47 pf 47-100 pf 15-68 pf 15-47 pf 15-47 pf 15-47 pf 10-47 pf higher capacitance increases the stability of the oscillator, but also increases the start-up time and the oscillator cur- rent. these values are for design guidance only. r s may be required in xt mode to avoid overdriving the crystals with low drive level specification. since each crystal has its own characteristics, the user should consult the crystal manufac- turer for appropriate values for external components. note 1: overtone crystals are used at 24 mhz and higher. the circuit in figure 4-3 should be used to select the desired harmonic frequency. 2: these values include all board capacitances on this pin. actual capacitor value depends on board capacitance. crystals used: 32.768 khz epson c-001r32.768k-a 20 ppm 1.0 mhz ecs-10-13-1 50 ppm 2.0 mhz ecs-20-20-1 50 ppm 4.0 mhz ecs-40-20-1 50 ppm 8.0 mhz ecs ecs-80-s-4 ecs-80-18-1 50 ppm 16.0 mhz ecs-160-20-1 50 ppm 25 mhz cts cts25m 50 ppm 32 mhz crystek hf-2 50 ppm c1 c2 0.1 f sleep osc2 osc1 pic17cxxx to filter the fundamental frequency: 1 l1*c2 = (2 f) 2 where f = tank circuit resonant frequency. this should be midway between the fundamental and the 3rd overtone frequencies of the crystal. c3 c3 blocks dc current to ground. l1
? 2000 microchip technology inc. ds30289b-page 19 pic17c7xx 4.1.4 external clock oscillator in the ec oscillator mode, the osc1 input can be driven by cmos drivers. in this mode, the osc1/ clkin pin is hi-impedance and the osc2/clkout pin is the clkout output (4 t osc ). figure 4-4: external clock input operation (ec osc configuration) 4.1.5 external crystal oscillator circuit either a prepackaged oscillator can be used, or a sim- ple oscillator circuit with ttl gates can be built. pre- packaged oscillators provide a wide operating range and better stability. a well designed crystal oscillator will provide good performance with ttl gates. two types of crystal oscillator circuits can be used: one with series resonance, or one with parallel resonance. figure 4-5 shows implementation of a parallel resonant oscillator circuit. the circuit is designed to use the fun- damental frequency of the crystal. the 74as04 inverter performs the 180-degree phase shift that a parallel oscillator requires. the 4.7 k ? resistor provides the negative feedback for stability. the 10 k ? potentiome- ter biases the 74as04 in the linear region. this could be used for external oscillator designs. figure 4-5: external parallel resonant crystal oscillator circuit figure 4-6 shows a series resonant oscillator circuit. this circuit is also designed to use the fundamental fre- quency of the crystal. the inverter performs a 180- degree phase shift in a series resonant oscillator cir- cuit. the 330 ? resistors provide the negative feedback to bias the inverters in their linear region. figure 4-6: external series resonant crystal oscillator circuit clock from ext. system osc1 osc2 pic17cxxx clkout (f osc /4) 20 pf +5v 20 pf 10 k ? 4.7 k ? 10 k ? 74as04 xtal 10k ? 74as04 pic17cxxx osc1 to o t h e r devices 330 ? 74as04 74as04 pic17cxxx osc1 to other devices xtal 330 ? 74as04 0.1 f
pic17c7xx ds30289b-page 20 ? 2000 microchip technology inc. 4.1.6 rc oscillator for timing insensitive applications, the rc device option offers additional cost savings. rc oscillator fre- quency is a function of the supply voltage, the resistor (r ext ) and capacitor (c ext ) values, and the operating temperature. in addition to this, oscillator frequency will vary from unit to unit due to normal process parameter variation. furthermore, the difference in lead frame capacitance between package types will also affect oscillation frequency, especially for low c ext values. the user also needs to take into account variation due to tolerance of external r and c components used. figure 4-7 shows how the r/c combination is con- nected to the pic17cxxx. for r ext values below 2.2 k ? , the oscillator operation may become unstable, or stop completely. for very high r ext values (e.g. 1m ? ), the oscillator becomes sensitive to noise, humidity and leakage. thus, we recommend to keep r ext between 3 k ? and 100 k ? . although the oscillator will operate with no external capacitor (c ext = 0 pf), we recommend using values above 20 pf for noise and stability reasons. with little or no external capacitance, oscillation frequency can vary dramatically due to changes in external capaci- tances, such as pcb trace capacitance or package lead frame capacitance. see section 21.0 for rc frequency variation from part to part due to normal process variation. the variation is larger for larger r (since leakage current variation will affect rc frequency more for large r) and for smaller c (since variation of input capacitance will affect rc frequency more). see section 21.0 for variation of oscillator frequency due to v dd for given r ext /c ext values, as well as fre- quency variation due to operating temperature for given r, c, and v dd values. the oscillator frequency, divided by 4, is available on the osc2/clkout pin and can be used for test pur- poses or to synchronize other logic (see figure 4-8 for waveform). figure 4-7: rc oscillator mode 4.1.6.1 rc start-up as the device voltage increases, the rc will immedi- ately start its oscillations once the pin voltage levels meet the input threshold specifications (parameter #d032 and parameter #d042 in the electrical specifica- tion section). the time required for the rc to start oscil- lating depends on many factors. these include:  resistor value used  capacitor value used  device v dd rise time  system temperature v dd r ext c ext v ss osc1 internal clock osc2/clkout f osc /4 pic17cxxx
? 2000 microchip technology inc. ds30289b-page 21 pic17c7xx 4.2 clocking scheme/instruction cycle the clock input (from osc1) is internally divided by four to generate four non-overlapping quadrature clocks, namely q1, q2, q3 and q4. internally, the pro- gram counter (pc) is incremented every q1 and the instruction is fetched from the program memory and latched into the instruction register in q4. the instruc- tion is decoded and executed during the following q1 through q4. the clocks and instruction execution flow are shown in figure 4-8. 4.3 instruction flow/pipelining an ? instruction cycle ? consists of four q cycles (q1, q2, q3 and q4). the instruction fetch and execute are pipelined such that fetch takes one instruction cycle, while decode and execute takes another instruction cycle. however, due to the pipelining, each instruction effectively executes in one cycle. if an instruction causes the program counter to change (e.g. goto ), then two cycles are required to complete the instruction (example 4-1). a fetch cycle begins with the program counter incre- menting in q1. in the execution cycle, the fetched instruction is latched into the ? instruction register (ir) ? in cycle q1. this instruction is then decoded and executed during the q2, q3 and q4 cycles. data memory is read during q2 (operand read) and written during q4 (destination write). figure 4-8: clock/instruction cycle example 4-1: instruction pipeline flow q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 osc1 q1 q2 q3 q4 pc osc2/clkout (rc mode) pc pc+1 pc+2 fetch inst (pc) execute inst (pc-1) fetch inst (pc+1) execute inst (pc) fetch inst (pc+2) execute inst (pc+1) internal phase clock all instructions are single cycle, except for any program branches. these take two cycles since the fetched instruc- tion is ? flushed ? from the pipeline, while the new instruction is being fetched and then executed. t cy 0t cy 1t cy 2t cy 3t cy 4t cy 5 1. movlw 55h fetch 1 execute 1 2. movwf portb fetch 2 execute 2 3. call sub_1 fetch 3 execute 3 4. bsf porta, bit3 (forced nop) fetch 4 flush 5. instruction @ address sub_1 fetch sub_1 execute sub_1
pic17c7xx ds30289b-page 22 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 23 pic17c7xx 5.0 reset the pic17cxxx differentiates between various kinds of reset:  power-on reset (por)  brown-out reset  mclr reset  wdt reset some registers are not affected in any reset condi- tion, their status is unknown on por and unchanged in any other reset. most other registers are forced to a ? reset state ? . the to and pd bits are set or cleared differently in different reset situations, as indicated in table 5-3. these bits, in conjunction with the por and bor bits, are used in software to determine the nature of the reset. see table 5-4 for a full description of the reset states of all registers. when the device enters the ? reset state ? , the data direction registers (ddr) are forced set, which will make the i/o hi-impedance inputs. the reset state of some peripheral modules may force the i/o to other operations, such as analog inputs or the system bus. a simplified block diagram of the on-chip reset circuit is shown in figure 5-1. figure 5-1: simplified block diagram of on-chip reset circuit note: while the device is in a reset state, the internal phase clock is held in the q1 state. any processor mode that allows external execution will force the re0/ale pin as a low output and the re1/oe and re2/wr pins as high outputs. s r q external reset mclr v dd osc1 wdt module v dd rise detect ost/pwrt on-chip rc osc ? wdt time_out power_on_reset ost 10-bit ripple counter pwrt chip_reset 10-bit ripple counter (enable the pwrt timer only during por or bor) (if pwrt is invoked, or a wake-up from sleep and osc type is xt or lf) reset enable ost enable pwrt ? this rc oscillator is shared with the wdt when not in a power-up sequence. bor module brown-out reset
pic17c7xx ds30289b-page 24 ? 2000 microchip technology inc. 5.1 power-on reset (por), power-up timer (pwrt), oscillator start-up timer (ost) and brown-out reset (bor) 5.1.1 power-on reset (por) the power-on reset circuit holds the device in reset until v dd is above the trip point (in the range of 1.4v - 2.3v). the devices produce an internal reset for both rising and falling v dd . to take advantage of the por, just tie the mclr /v pp pin directly (or through a resistor) to v dd . this will eliminate external rc components usually needed to create power-on reset. a minimum rise time for v dd is required. see electrical specifica- tions for details. figure 5-2 and figure 5-3 show two possible por circuits. figure 5-2: using on-chip por figure 5-3: external power-on reset circuit (for slow v dd power-up) 5.1.2 power-up timer (pwrt) the power-up timer provides a fixed 96 ms time-out (nominal) on power-up. this occurs from the rising edge of the internal por signal if v dd and mclr are tied, or after the first rising edge of mclr (detected high). the power-up timer operates on an internal rc oscillator. the chip is kept in reset as long as the pwrt is active. in most cases, the pwrt delay allows v dd to rise to an acceptable level. the power-up time delay will vary from chip to chip and with v dd and temperature. see dc parameters for details. 5.1.3 oscillator start-up timer (ost) the oscillator start-up timer (ost) provides a 1024 oscillator cycle (1024t osc ) delay whenever the pwrt is invoked, or a wake-up from sleep event occurs in xt or lf mode. the pwrt and ost operate in parallel. the ost counts the oscillator pulses on the osc1/ clkin pin. the counter only starts incrementing after the amplitude of the signal reaches the oscillator input thresholds. this delay allows the crystal oscillator or resonator to stabilize before the device exits reset. the length of the time-out is a function of the crystal/ resonator frequency. figure 5-4 shows the operation of the ost circuit. in this figure, the oscillator is of such a low frequency that although enabled simultaneously, the ost does not time-out until after the power-up timer time-out. figure 5-4: oscillator start-up t i m e ( l o w f r e q u e n c y ) v dd mclr pic17cxxx v dd note 1: an external power-on reset circuit is required only if v dd power-up time is too slow. the diode d helps discharge the capac- itor quickly when v dd powers down. 2: r < 40 k ? is recommended to ensure that the voltage drop across r does not exceed 0.2v (max. leakage current spec. on the mclr / v pp pin is 5 a). a larger voltage drop will degrade v ih level on the mclr /v pp pin. 3: r1 = 100 ? to 1 k ? will limit any current flow- ing into mclr from external capacitor c in the event of mclr /v pp pin breakdown due to electrostatic discharge (esd) or electrical overstress (eos). c r1 r d v dd mclr pic17cxxx v dd v dd mclr osc2 ost time_out pwrt time_out internal reset t osc 1 t ost t pwrt por or bor trip point this figure shows in greater detail the timings involved with the oscillator start-up timer. in this example, the low frequency crystal start-up time is larger than power-up time (t pwrt ). t osc 1 = time for the crystal oscillator to react to an oscil- lation level detectable by the oscillator start-up timer (ost). t ost = 1024t osc .
? 2000 microchip technology inc. ds30289b-page 25 pic17c7xx 5.1.4 time-out sequence on power-up, the time-out sequence is as follows: first, the internal por signal goes high when the por trip point is reached. if mclr is high, then both the ost and pwrt timers start. in general, the pwrt time-out is longer, except with low frequency crystals/resonators. the total time-out also varies based on oscillator config- uration. table 5-1 shows the times that are associated with the oscillator configuration. figure 5-5 and figure 5- 6 display these time-out sequences. if the device voltage is not within electrical specification at the end of a time-out, the mclr/ v pp pin must be held low until the voltage is within the device specifica- tion. the use of an external rc delay is sufficient for many of these applications. the time-out sequence begins from the first rising edge of mclr . table 5-3 shows the reset conditions for some spe- cial registers, while table 5-4 shows the initialization conditions for all the registers. table 5-1: time-out in various situations table 5-2: status bits and their significance table 5-3: reset condition for the program counter and the cpusta register oscillator configuration por, bor wake-up from sleep mclr reset xt, lf greater of: 96 ms or 1024t osc 1024t osc ? ec, rc greater of: 96 ms or 1024t osc ?? por bor (1) to pd event 0011 power-on reset 1110 mclr reset during sleep or interrupt wake-up from sleep 1101 wdt reset during normal operation 1100 wdt wake-up during sleep 1111 mclr reset during normal operation 1011 brown-out reset 000x illegal, to is set on por 00x0 illegal, pd is set on por xx11 clrwdt instruction executed note 1: when boden is enabled, else the bor status bit is unknown. event pch:pcl cpusta (4) ost active power-on reset 0000h --11 1100 yes brown-out reset 0000h --11 1110 yes mclr reset during normal operation 0000h --11 1111 no mclr reset during sleep 0000h --11 1011 yes (2) wdt reset during normal operation 0000h --11 0111 no wdt reset during sleep (3) 0000h --11 0011 yes (2) interrupt wake-up from sleep glintd is set pc + 1 --11 1011 yes (2) glintd is clear pc + 1 (1) --10 1011 yes (2) legend: u = unchanged, x = unknown, - = unimplemented, read as '0' note 1: on wake-up, this instruction is executed. the instruction at the appropriate interrupt vector is fetched and then executed. 2: the ost is only active (on wake-up) when the oscillator is configured for xt or lf modes. 3: the program counter = 0; that is, the device branches to the reset vector and places sfrs in wdt reset states. this is different from the mid-range devices. 4: when boden is enabled, else the bor status bit is unknown.
pic17c7xx ds30289b-page 26 ? 2000 microchip technology inc. in figure 5-5, figure 5-6 and figure 5-7, the t pwrt timer time-out is greater then the t ost timer time-out, as would be the case in higher frequency crystals. for lower frequency crystals (i.e., 32 khz), t ost may be greater. figure 5-5: time-out sequence on power-up (mclr tied to v dd ) figure 5-6: time-out sequence on power-up (mclr not tied to v dd ) figure 5-7: slow rise time (mclr tied to v dd ) t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset t pwrt t ost v dd mclr internal por pwrt time-out ost time-out internal reset v dd mclr internal por pwrt time-out ost time-out internal reset 0v 1v 5v t pwrt t ost minimum v dd operating voltage
? 2000 microchip technology inc. ds30289b-page 27 pic17c7xx table 5-4: initialization conditions for special function registers register address power-on reset brown-out reset mclr reset wdt reset wake-up from sleep through interrupt unbanked indf0 00h n/a n/a n/a fsr0 01h xxxx xxxx uuuu uuuu uuuu uuuu pcl 02h 0000h 0000h pc + 1 (2) pclath 03h 0000 0000 uuuu uuuu uuuu uuuu alusta 04h 1111 xxxx 1111 uuuu 1111 uuuu t0sta 05h 0000 000- 0000 000- 0000 000- cpusta (3) 06h --11 11qq --11 qquu --uu qquu intsta 07h 0000 0000 0000 0000 uuuu uuuu (1) indf1 08h n/a n/a n/a fsr1 09h xxxx xxxx uuuu uuuu uuuu uuuu wreg 0ah xxxx xxxx uuuu uuuu uuuu uuuu tmr0l 0bh xxxx xxxx uuuu uuuu uuuu uuuu tmr0h 0ch xxxx xxxx uuuu uuuu uuuu uuuu tblptrl 0dh 0000 0000 0000 0000 uuuu uuuu tblptrh 0eh 0000 0000 0000 0000 uuuu uuuu bsr 0fh 0000 0000 0000 0000 uuuu uuuu bank 0 porta (4,6) 10h 0-xx 11xx 0-uu 11uu u-uu uuuu ddrb 11h 1111 1111 1111 1111 uuuu uuuu portb (4) 12h xxxx xxxx uuuu uuuu uuuu uuuu rcsta1 13h 0000 -00x 0000 -00u uuuu -uuu rcreg1 14h xxxx xxxx uuuu uuuu uuuu uuuu txsta1 15h 0000 --1x 0000 --1u uuuu --uu txreg1 16h xxxx xxxx uuuu uuuu uuuu uuuu spbrg1 17h 0000 0000 0000 0000 uuuu uuuu legend: u = unchanged, x = unknown, - = unimplemented, read as ? 0 ? , q = value depends on condition note 1: one or more bits in intsta, pir1, pir2 will be affected (to cause wake-up). 2: when the wake-up is due to an interrupt and the glintd bit is cleared, the pc is loaded with the interrupt vector. 3: see table 5-3 for reset value of specific condition. 4: this is the value that will be in the port output latch. 5: when the device is configured for microprocessor or extended microcontroller mode, the operation of this port does not rely on these registers. 6: on any device reset, these pins are configured as inputs.
pic17c7xx ds30289b-page 28 ? 2000 microchip technology inc. bank 1 ddrc (5) 10h 1111 1111 1111 1111 uuuu uuuu portc (4,5) 11h xxxx xxxx uuuu uuuu uuuu uuuu ddrd (5) 12h 1111 1111 1111 1111 uuuu uuuu portd (4,5) 13h xxxx xxxx uuuu uuuu uuuu uuuu ddre (5) 14h ---- 1111 ---- 1111 ---- uuuu porte (4,5) 15h ---- xxxx ---- uuuu ---- uuuu pir1 16h x000 0010 u000 0010 uuuu uuuu (1) pie1 17h 0000 0000 0000 0000 uuuu uuuu bank 2 tmr1 10h xxxx xxxx uuuu uuuu uuuu uuuu tmr2 11h xxxx xxxx uuuu uuuu uuuu uuuu tmr3l 12h xxxx xxxx uuuu uuuu uuuu uuuu tmr3h 13h xxxx xxxx uuuu uuuu uuuu uuuu pr1 14h xxxx xxxx uuuu uuuu uuuu uuuu pr2 15h xxxx xxxx uuuu uuuu uuuu uuuu pr3/ca1l 16h xxxx xxxx uuuu uuuu uuuu uuuu pr3/ca1h 17h xxxx xxxx uuuu uuuu uuuu uuuu bank 3 pw1dcl 10h xx-- ---- uu-- ---- uu-- ---- pw2dcl 11h xx0- ---- uu0- ---- uuu- ---- pw1dch 12h xxxx xxxx uuuu uuuu uuuu uuuu pw2dch 13h xxxx xxxx uuuu uuuu uuuu uuuu ca2l 14h xxxx xxxx uuuu uuuu uuuu uuuu ca2h 15h xxxx xxxx uuuu uuuu uuuu uuuu tcon1 16h 0000 0000 0000 0000 uuuu uuuu tcon2 17h 0000 0000 0000 0000 uuuu uuuu table 5-4: initialization conditions for special function registers (continued) register address power-on reset brown-out reset mclr reset wdt reset wake-up from sleep through interrupt legend: u = unchanged, x = unknown, - = unimplemented, read as ? 0 ? , q = value depends on condition note 1: one or more bits in intsta, pir1, pir2 will be affected (to cause wake-up). 2: when the wake-up is due to an interrupt and the glintd bit is cleared, the pc is loaded with the interrupt vector. 3: see table 5-3 for reset value of specific condition. 4: this is the value that will be in the port output latch. 5: when the device is configured for microprocessor or extended microcontroller mode, the operation of this port does not rely on these registers. 6: on any device reset, these pins are configured as inputs.
? 2000 microchip technology inc. ds30289b-page 29 pic17c7xx bank 4 pir2 10h 000- 0010 000- 0010 uuu- uuuu (1) pie2 11h 000- 0000 000- 0000 uuu- uuuu unimplemented 12h ---- ---- ---- ---- ---- ---- rcsta2 13h 0000 -00x 0000 -00u uuuu -uuu rcreg2 14h xxxx xxxx uuuu uuuu uuuu uuuu txsta2 15h 0000 --1x 0000 --1u uuuu --uu txreg2 16h xxxx xxxx uuuu uuuu uuuu uuuu spbrg2 17h 0000 0000 0000 0000 uuuu uuuu bank 5 ddrf 10h 1111 1111 1111 1111 uuuu uuuu portf (4) 11h 0000 0000 0000 0000 uuuu uuuu ddrg 12h 1111 1111 1111 1111 uuuu uuuu portg (4) 13h xxxx 0000 uuuu 0000 uuuu uuuu adcon0 14h 0000 -0-0 0000 -0-0 uuuu uuuu adcon1 15h 000- 0000 000- 0000 uuuu uuuu adresl 16h xxxx xxxx uuuu uuuu uuuu uuuu adresh 17h xxxx xxxx uuuu uuuu uuuu uuuu bank 6 sspadd 10h 0000 0000 0000 0000 uuuu uuuu sspcon1 11h 0000 0000 0000 0000 uuuu uuuu sspcon2 12h 0000 0000 0000 0000 uuuu uuuu sspstat 13h 0000 0000 0000 0000 uuuu uuuu sspbuf 14h xxxx xxxx uuuu uuuu uuuu uuuu unimplemented 15h ---- ---- ---- ---- ---- ---- unimplemented 16h ---- ---- ---- ---- ---- ---- unimplemented 17h ---- ---- ---- ---- ---- ---- table 5-4: initialization conditions for special function registers (continued) register address power-on reset brown-out reset mclr reset wdt reset wake-up from sleep through interrupt legend: u = unchanged, x = unknown, - = unimplemented, read as ? 0 ? , q = value depends on condition note 1: one or more bits in intsta, pir1, pir2 will be affected (to cause wake-up). 2: when the wake-up is due to an interrupt and the glintd bit is cleared, the pc is loaded with the interrupt vector. 3: see table 5-3 for reset value of specific condition. 4: this is the value that will be in the port output latch. 5: when the device is configured for microprocessor or extended microcontroller mode, the operation of this port does not rely on these registers. 6: on any device reset, these pins are configured as inputs.
pic17c7xx ds30289b-page 30 ? 2000 microchip technology inc. bank 7 pw3dcl 10h xx0- ---- uu0- ---- uuu- ---- pw3dch 11h xxxx xxxx uuuu uuuu uuuu uuuu ca3l 12h xxxx xxxx uuuu uuuu uuuu uuuu ca3h 13h xxxx xxxx uuuu uuuu uuuu uuuu ca4l 14h xxxx xxxx uuuu uuuu uuuu uuuu ca4h 15h xxxx xxxx uuuu uuuu uuuu uuuu tcon3 16h -000 0000 -000 0000 -uuu uuuu unimplemented 17h ---- ---- ---- ---- ---- ---- bank 8 ddrh 10h 1111 1111 1111 1111 uuuu uuuu porth (4) 11h xxxx xxxx uuuu uuuu uuuu uuuu ddrj 12h 1111 1111 1111 1111 uuuu uuuu portj (4) 13h xxxx xxxx uuuu uuuu uuuu uuuu unbanked prodl 18h xxxx xxxx uuuu uuuu uuuu uuuu prodh 19h xxxx xxxx uuuu uuuu uuuu uuuu table 5-4: initialization conditions for special function registers (continued) register address power-on reset brown-out reset mclr reset wdt reset wake-up from sleep through interrupt legend: u = unchanged, x = unknown, - = unimplemented, read as ? 0 ? , q = value depends on condition note 1: one or more bits in intsta, pir1, pir2 will be affected (to cause wake-up). 2: when the wake-up is due to an interrupt and the glintd bit is cleared, the pc is loaded with the interrupt vector. 3: see table 5-3 for reset value of specific condition. 4: this is the value that will be in the port output latch. 5: when the device is configured for microprocessor or extended microcontroller mode, the operation of this port does not rely on these registers. 6: on any device reset, these pins are configured as inputs.
? 2000 microchip technology inc. ds30289b-page 31 pic17c7xx 5.1.5 brown-out reset (bor) pic17c7xx devices have on-chip brown-out reset circuitry. this circuitry places the device into a reset when the device voltage falls below a trip point (bv dd ). this ensures that the device does not continue pro- gram execution outside the valid operation range of the device. brown-out resets are typically used in ac line applications, or large battery applications, where large loads may be switched in (such as automotive). the boden configuration bit can disable (if clear/ programmed), or enable (if set) the brown-out reset circuitry. if v dd falls below bv dd (typically 4.0 v, paramter #d005 in electrical specification section), for greater than parameter #35, the brown-out situation will reset the chip. a reset is not guaranteed to occur if v dd falls below bv dd for less than paramter #35. the chip will remain in brown-out reset until v dd rises above bv dd . the power-up timer and oscillator start- up timer will then be invoked. this will keep the chip in reset the greater of 96 ms and 1024 t osc . if v dd drops below bv dd while the power-up timer/oscillator start-up timer is running, the chip will go back into a brown-out reset. the power-up timer/oscillator start- up timer will be initialized. once v dd rises above bv dd , the power-up timer/oscillator start-up timer will start their time delays. figure 5-10 shows typical brown-out situations. in some applications, the brown-out reset trip point of the device may not be at the desired level. figure 5-8 and figure 5-9 are two examples of external circuitry that may be implemented. each needs to be evaluated to determine if they match the requirements of the application. figure 5-8: external brown-out protection circuit 1 figure 5-9: external brown-out protection circuit 2 figure 5-10: brown-out situations note: before using the on-chip brown-out for a voltage supervisory function, please review the electrical specifications to ensure that they meet your requirements. v dd 33k 10k ? 40 k ? v dd mclr pic17cxxx this circuit will activate reset when v dd goes below (vz + 0.7v) where vz = zener voltage. this brown-out circuit is less expensive, albeit less accurate. transistor q1 turns off when v dd is below a certain level such that: v dd  r1 r1 + r2 = 0.7v r2 40 k ? v dd mclr pic17cxxx r1 q1 v dd greater of 96 ms bv dd max. bv dd min. v dd internal reset bv dd max. bv dd min. v dd internal reset < 96 ms bv dd max. bv dd min. v dd internal reset and 1024 t osc greater of 96 ms and 1024 t osc greater of 96 ms and 1024 t osc
pic17c7xx ds30289b-page 32 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 33 pic17c7xx 6.0 interrupts pic17c7xx devices have 18 sources of interrupt:  external interrupt from the ra0/int pin  change on rb7:rb0 pins  tmr0 overflow  tmr1 overflow  tmr2 overflow  tmr3 overflow  usart1 transmit buffer empty  usart1 receive buffer full  usart2 transmit buffer empty  usart2 receive buffer full  ssp interrupt  ssp i 2 c bus collision interrupt  a/d conversion complete  capture1  capture2  capture3  capture4  t0cki edge occurred there are six registers used in the control and status of interrupts. these are:  cpusta  intsta  pie1  pir1  pie2  pir2 the cpusta register contains the glintd bit. this is the global interrupt disable bit. when this bit is set, all interrupts are disabled. this bit is part of the controller core functionality and is described in the section 6.4. when an interrupt is responded to, the glintd bit is automatically set to disable any further interrupts, the return address is pushed onto the stack and the pc is loaded with the interrupt vector address. there are four interrupt vectors. each vector address is for a specific interrupt source (except the peripheral interrupts, which all vector to the same address). these sources are:  external interrupt from the ra0/int pin  tmr0 overflow  t0cki edge occurred  any peripheral interrupt when program execution vectors to one of these inter- rupt vector addresses (except for the peripheral inter- rupts), the interrupt flag bit is automatically cleared. vectoring to the peripheral interrupt vector address does not automatically clear the source of the interrupt. in the peripheral interrupt service routine, the source(s) of the interrupt can be determined by testing the interrupt flag bits. the interrupt flag bit(s) must be cleared in software before re-enabling interrupts to avoid infinite interrupt requests. when an interrupt condition is met, that individual inter- rupt flag bit will be set, regardless of the status of its corresponding mask bit or the glintd bit. for external interrupt events, there will be an interrupt latency. for two-cycle instructions, the latency could be one instruction cycle longer. the ? return from interrupt ? instruction, retfie , can be used to mark the end of the interrupt service routine. when this instruction is executed, the stack is ? poped ? and the glintd bit is cleared (to re-enable interrupts). figure 6-1: interrupt logic rbif rbie tmr3if tmr3ie tmr2if tmr2ie tmr1if tmr1ie ca2if ca2ie ca1if ca1ie tx1if tx1ie rc1if rc1ie t0if t0ie intf inte t0ckif t0ckie glintd (cpusta<4>) peie wake-up (if in sleep mode) or terminate long write interrupt to cpu peif sspif sspie bclif bclie adif adie ca4if ca4ie ca3if ca3ie tx2if tx2ie rc2if rc2ie pir1/pie1 pir2/pie2 intsta
pic17c7xx ds30289b-page 34 ? 2000 microchip technology inc. 6.1 interrupt status register (intsta) the interrupt status/control register (intsta) contains the flag and enable bits for non-peripheral interrupts. the peif bit is a read only, bit wise or of all the periph- eral flag bits in the pir registers (figure 6-4 and figure 6-5). care should be taken when clearing any of the intsta register enable bits when interrupts are enabled (glintd is clear). if any of the intsta flag bits (t0if, intf, t0ckif, or peif) are set in the same instruction cycle as the corresponding interrupt enable bit is cleared, the device will vector to the reset address (0x00). prior to disabling any of the intsta enable bits, the glintd bit should be set (disabled). register 6-1: intsta register (address: 07h, unbanked) note: all interrupt flag bits get set by their speci- fied condition, even if the corresponding interrupt enable bit is clear (interrupt dis- abled), or the glintd bit is set (all inter- rupts disabled). r-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 peif t0ckif t0if intf peie t0ckie t0ie inte bit 7 bit 0 bit 7 peif : peripheral interrupt flag bit this bit is the or of all peripheral interrupt flag bits and ? ed with their corresponding enable bits. the interrupt logic forces program execution to address (20h) when a peripheral interrupt is pending. 1 = a peripheral interrupt is pending 0 = no peripheral interrupt is pending bit 6 t0ckif : external interrupt on t0cki pin flag bit this bit is cleared by hardware, when the interrupt logic forces program execution to address (18h). 1 = the software specified edge occurred on the ra1/t0cki pin 0 = the software specified edge did not occur on the ra1/t0cki pin bit 5 t0if : tmr0 overflow interrupt flag bit this bit is cleared by hardware, when the interrupt logic forces program execution to address (10h). 1 = tmr0 overflowed 0 = tmr0 did not overflow bit 4 intf : external interrupt on int pin flag bit this bit is cleared by hardware, when the interrupt logic forces program execution to address (08h). 1 = the software specified edge occurred on the ra0/int pin 0 = the software specified edge did not occur on the ra0/int pin bit 3 peie : peripheral interrupt enable bit this bit acts as a global enable bit for the peripheral interrupts that have their corresponding enable bits set. 1 = enable peripheral interrupts 0 = disable peripheral interrupts bit 2 t0ckie : external interrupt on t0cki pin enable bit 1 = enable software specified edge interrupt on the ra1/t0cki pin 0 = disable interrupt on the ra1/t0cki pin bit 1 t0ie : tmr0 overflow interrupt enable bit 1 = enable tmr0 overflow interrupt 0 = disable tmr0 overflow interrupt bit 0 inte : external interrupt on ra0/int pin enable bit 1 = enable software specified edge interrupt on the ra0/int pin 0 = disable software specified edge interrupt on the ra0/int pin legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
? 2000 microchip technology inc. ds30289b-page 35 pic17c7xx 6.2 peripheral interrupt enable register1 (pie1) and register2 (pie2) these registers contains the individual enable bits for the peripheral interrupts. register 6-2: pie1 register (address: 17h, bank 1) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie bit 7 bit 0 bit 7 rbie : portb interrupt-on-change enable bit 1 = enable portb interrupt-on-change 0 = disable portb interrupt-on-change bit 6 tmr3ie : tmr3 interrupt enable bit 1 = enable tmr3 interrupt 0 = disable tmr3 interrupt bit 5 tmr2ie : tmr2 interrupt enable bit 1 = enable tmr2 interrupt 0 = disable tmr2 interrupt bit 4 tmr1ie : tmr1 interrupt enable bit 1 = enable tmr1 interrupt 0 = disable tmr1 interrupt bit 3 ca2ie : capture2 interrupt enable bit 1 = enable capture2 interrupt 0 = disable capture2 interrupt bit 2 ca1ie : capture1 interrupt enable bit 1 = enable capture1 interrupt 0 = disable capture1 interrupt bit 1 tx1ie : usart1 transmit interrupt enable bit 1 = enable usart1 transmit buffer empty interrupt 0 = disable usart1 transmit buffer empty interrupt bit 0 rc1ie : usart1 receive interrupt enable bit 1 = enable usart1 receive buffer full interrupt 0 = disable usart1 receive buffer full interrupt legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
pic17c7xx ds30289b-page 36 ? 2000 microchip technology inc. register 6-3: pie2 register (address: 11h, bank 4) r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie bit 7 bit 0 bit 7 sspie : synchronous serial port interrupt enable bit 1 = enable ssp interrupt 0 = disable ssp interrupt bit 6 bclie : bus collision interrupt enable bit 1 = enable bus collision interrupt 0 = disable bus collision interrupt bit 5 adie : a/d module interrupt enable bit 1 = enable a/d module interrupt 0 = disable a/d module interrupt bit 4 unimplemented : read as ? 0 ? bit 3 ca4ie : capture4 interrupt enable bit 1 = enable capture4 interrupt 0 = disable capture4 interrupt bit 2 ca3ie : capture3 interrupt enable bit 1 = enable capture3 interrupt 0 = disable capture3 interrupt bit 1 tx2ie : usart2 transmit interrupt enable bit 1 = enable usart2 transmit buffer empty interrupt 0 = disable usart2 transmit buffer empty interrupt bit 0 rc2ie : usart2 receive interrupt enable bit 1 = enable usart2 receive buffer full interrupt 0 = disable usart2 receive buffer full interrupt legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
? 2000 microchip technology inc. ds30289b-page 37 pic17c7xx 6.3 peripheral interrupt request register1 (pir1) and register2 (pir2) these registers contains the individual flag bits for the peripheral interrupts. register 6-4: pir1 register (address: 16h, bank 1) note: these bits will be set by the specified condi- tion, even if the corresponding interrupt enable bit is cleared (interrupt disabled), or the glintd bit is set (all interrupts disabled). before enabling an interrupt, the user may wish to clear the interrupt flag to ensure that the program does not immediately branch to the peripheral interrupt service routine. r/w-x r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r-1 r-0 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if bit 7 bit 0 bit 7 rbif : portb interrupt-on-change flag bit 1 = one of the portb inputs changed (software must end the mismatch condition) 0 = none of the portb inputs have changed bit 6 tmr3if : tmr3 interrupt flag bit if capture1 is enabled (ca1/ pr 3 = 1): 1 = tmr3 overflowed 0 = tmr3 did not overflow if capture1 is disabled (ca1/ pr 3 = 0): 1 = tmr3 value has rolled over to 0000h from equalling the period register (pr3h:pr3l) value 0 = tmr3 value has not rolled over to 0000h from equalling the period register (pr3h:pr3l) value bit 5 tmr2if : tmr2 interrupt flag bit 1 = tmr2 value has rolled over to 0000h from equalling the period register (pr2) value 0 = tmr2 value has not rolled over to 0000h from equalling the period register (pr2) value bit 4 tmr1if : tmr1 interrupt flag bit if tmr1 is in 8-bit mode (t16 = 0): 1 = tmr1 value has rolled over to 0000h from equalling the period register (pr1) value 0 = tmr1 value has not rolled over to 0000h from equalling the period register (pr1) value if timer1 is in 16-bit mode (t16 = 1): 1 = tmr2:tmr1 value has rolled over to 0000h from equalling the period register (pr2:pr1) value 0 = tmr2:tmr1 value has not rolled over to 0000h from equalling the period register (pr2:pr1) value bit 3 ca2if : capture2 interrupt flag bit 1 = capture event occurred on rb1/cap2 pin 0 = capture event did not occur on rb1/cap2 pin bit 2 ca1if : capture1 interrupt flag bit 1 = capture event occurred on rb0/cap1 pin 0 = capture event did not occur on rb0/cap1 pin bit 1 tx1if : usart1 transmit interrupt flag bit (state controlled by hardware) 1 = usart1 transmit buffer is empty 0 = usart1 transmit buffer is full bit 0 rc1if : usart1 receive interrupt flag bit (state controlled by hardware) 1 = usart1 receive buffer is full 0 = usart1 receive buffer is empty legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
pic17c7xx ds30289b-page 38 ? 2000 microchip technology inc. register 6-5: pir2 register (address: 10h, bank 4) r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r-1 r-0 sspif bclif adif ? ca4if ca3if tx2if rc2if bit 7 bit 0 bit 7 sspif : synchronous serial port (ssp) interrupt flag bit 1 = the ssp interrupt condition has occurred and must be cleared in software before returning from the interrupt service routine. the conditions that will set this bit are: spi: a transmission/reception has taken place. i 2 c slave/master: a transmission/reception has taken place. i 2 c master: the initiated start condition was completed by the ssp module. the initiated stop condition was completed by the ssp module. the initiated restart condition was completed by the ssp module. the initiated acknowledge condition was completed by the ssp module. a start condition occurred while the ssp module was idle (multi-master system). a stop condition occurred while the ssp module was idle (multi-master system). 0 = an ssp interrupt condition has not occurred bit 6 bclif : bus collision interrupt flag bit 1 = a bus collision has occurred in the ssp, when configured for i 2 c master mode 0 = no bus collision has occurred bit 5 adif : a/d module interrupt flag bit 1 = an a/d conversion is complete 0 = an a/d conversion is not complete bit 4 unimplemented : read as ? 0 ? bit 3 ca4if : capture4 interrupt flag bit 1 = capture event occurred on re3/cap4 pin 0 = capture event did not occur on re3/cap4 pin bit 2 ca3if : capture3 interrupt flag bit 1 = capture event occurred on rg4/cap3 pin 0 = capture event did not occur on rg4/cap3 pin bit 1 tx2if :usart2 transmit interrupt flag bit (state controlled by hardware) 1 = usart2 transmit buffer is empty 0 = usart2 transmit buffer is full bit 0 rc2if : usart2 receive interrupt flag bit (state controlled by hardware) 1 = usart2 receive buffer is full 0 = usart2 receive buffer is empty legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
? 2000 microchip technology inc. ds30289b-page 39 pic17c7xx 6.4 interrupt operation global interrupt disable bit, glintd (cpusta<4>), enables all unmasked interrupts (if clear), or disables all interrupts (if set). individual interrupts can be dis- abled through their corresponding enable bits in the intsta register. peripheral interrupts need either the global peripheral enable peie bit disabled, or the spe- cific peripheral enable bit disabled. disabling the peripherals via the global peripheral enable bit, dis- ables all peripheral interrupts. glintd is set on reset (interrupts disabled). the retfie instruction clears the glintd bit while forcing the program counter (pc) to the value loaded at the top-of-stack. when an interrupt is responded to, the glintd bit is automatically set to disable any further interrupt, the return address is pushed onto the stack and the pc is loaded with the interrupt vector. there are four interrupt vectors which help reduce interrupt latency. the peripheral interrupt vector has multiple interrupt sources. once in the peripheral interrupt service rou- tine, the source(s) of the interrupt can be determined by polling the interrupt flag bits. the peripheral interrupt flag bit(s) must be cleared in software before re- enabling interrupts to avoid continuous interrupts. the pic17c7xx devices have four interrupt vectors. these vectors and their hardware priority are shown in table 6-1. if two enabled interrupts occur ? at the same time ? , the interrupt of the highest priority will be ser- viced first. this means that the vector address of that interrupt will be loaded into the program counter (pc). table 6-1: interrupt vectors/ priorities 6.5 ra0/int interrupt the external interrupt on the ra0/int pin is edge trig- gered. either the rising edge if the intedg bit (t0sta<7>) is set, or the falling edge if the intedg bit is clear. when a valid edge appears on the ra0/int pin, the intf bit (intsta<4>) is set. this interrupt can be disabled by clearing the inte control bit (intsta<0>). the int interrupt can wake the proces- sor from sleep. see section 17.4 for details on sleep operation. 6.6 t0cki interrupt the external interrupt on the ra1/t0cki pin is edge triggered. either the rising edge if the t0se bit (t0sta<6>) is set, or the falling edge if the t0se bit is clear. when a valid edge appears on the ra1/t0cki pin, the t0ckif bit (intsta<6>) is set. this interrupt can be disabled by clearing the t0ckie control bit (intsta<2>). the t0cki interrupt can wake up the processor from sleep. see section 17.4 for details on sleep operation. 6.7 peripheral interrupt the peripheral interrupt flag indicates that at least one of the peripheral interrupts occurred (peif is set). the peif bit is a read only bit and is a bit wise or of all the flag bits in the pir registers and ? d with the correspond- ing enable bits in the pie registers. some of the periph- eral interrupts can wake the processor from sleep. see section 17.4 for details on sleep operation. 6.8 context saving during interrupts during an interrupt, only the returned pc value is saved on the stack. typically, users may wish to save key reg- isters during an interrupt; e.g. wreg, alusta and the bsr registers. this requires implementation in software. example 6-2 shows the saving and restoring of infor- mation for an interrupt service routine. this is for a simple interrupt scheme, where only one interrupt may occur at a time (no interrupt nesting). the sfrs are stored in the non-banked gpr area. example 6-2 shows the saving and restoring of infor- mation for a more complex interrupt service routine. this is useful where nesting of interrupts is required. a maximum of 6 levels can be done by this example. the bsr is stored in the non-banked gpr area, while the other registers would be stored in a particular bank. therefore, 6 saves may be done with this routine (since there are 6 non-banked gpr registers). these routines require a dedicated indirect addressing register, fsr0, to be selected for this. the push and pop code segments could either be in each interrupt service routine, or could be subroutines that were called. depending on the application, other registers may also need to be saved. address vector priority 0008h external interrupt on ra0/ int pin (intf) 1 (highest) 0010h tmr0 overflow interrupt (t0if) 2 0018h external interrupt on t0cki (t0ckif) 3 0020h peripherals (peif) 4 (lowest) note 1: individual interrupt flag bits are set, regard- less of the status of their corresponding mask bit or the glintd bit. 2: before disabling any of the intsta enable bits, the glintd bit should be set (disabled).
pic17c7xx ds30289b-page 40 ? 2000 microchip technology inc. figure 6-2: int pin/t0cki pin interrupt timing q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 osc1 osc2 ra0/int or ra1/t0cki intf or t0ckif glintd pc instruction executed system bus instruction fetched pc pc + 1 addr (vector) pc inst (pc) inst (pc+1) inst (pc) dummy dummy yy yy + 1 retfie retfie inst (pc+1) inst (vector) addr addr addr addr addr inst (yy + 1) dummy pc + 1
? 2000 microchip technology inc. ds30289b-page 41 pic17c7xx example 6-1: saving status and wreg in ram (simple) ; the addresses that are used to store the cpusta and wreg values must be in the data memory ; address range of 1ah - 1fh. up to 6 locations can be saved and restored using the movfp ; instruction. this instruction neither affects the status bits, nor corrupts the wreg register. ; unbank1 equ 0x01a ; address for 1st location to save unbank2 equ 0x01b ; address for 2nd location to save unbank3 equ 0x01c ; address for 3rd location to save unbank4 equ 0x01d ; address for 4th location to save unbank5 equ 0x01e ; address for 5th location to save ; (label not used in program) unbank6 equ 0x01f ; address for 6th location to save ; (label not used in program) ; : ; at interrupt vector address push movfp alusta, unbank1 ; push alusta value movfp bsr, unbank2 ; push bsr value movfp wreg, unbank3 ; push wreg value movfp pclath, unbank4 ; push pclath value ; : ; interrupt service routine (isr) code ; pop movfp unbank4, pclath ; restore pclath value movfp unbank3, wreg ; restore wreg value movfp unbank2, bsr ; restore bsr value movfp unbank1, alusta ; restore alusta value ; retfie ; return from interrupt (enable interrupts)
pic17c7xx ds30289b-page 42 ? 2000 microchip technology inc. example 6-2: saving status and wreg in ram (nested) ; the addresses that are used to store the cpusta and wreg values must be in the data memory ; address range of 1ah - 1fh. up to 6 locations can be saved and restored using the movfp ; instruction. this instruction neither affects the status bits, nor corrupts the wreg register. ; this routine uses the frs0, so it controls the fs1 and fs0 bits in the alusta register. ; nobank_fsr equ 0x40 bank_fsr equ 0x41 alu_temp equ 0x42 wreg_temp equ 0x43 bsr_s1 equ 0x01a ; 1st location to save bsr bsr_s2 equ 0x01b ; 2nd location to save bsr (label not used in program) bsr_s3 equ 0x01c ; 3rd location to save bsr (label not used in program) bsr_s4 equ 0x01d ; 4th location to save bsr (label not used in program) bsr_s5 equ 0x01e ; 5th location to save bsr (label not used in program) bsr_s6 equ 0x01f ; 6th location to save bsr (label not used in program) ; initialization ; call clear_ram ; must clear all data ram ; init_pointers ; must initialize the pointers for pop and push clrf bsr, f ; set all banks to 0 clrf alusta, f ; fsr0 post increment bsf alusta, fs1 clrf wreg, f ; clear wreg movlw bsr_s1 ; load fsr0 with 1st address to save bsr movwf fsr0 movwf nobank_fsr movlw 0x20 movwf bank_fsr : : ; your code : : ; at interrupt vector address push bsf alusta, fs0 ; fsr0 has auto-increment, does not affect status bits bcf alusta, fs1 ; does not affect status bits movfp bsr, indf0 ; no status bits are affected clrf bsr, f ; peripheral and data ram bank 0 no status bits are affected movpf alusta, alu_temp ; movpf fsr0, nobank_fsr ; save the fsr for bsr values movpf wreg, wreg_temp ; movfp bank_fsr, fsr0 ; restore fsr value for other values movfp alu_temp, indf0 ; push alusta value movfp wreg_temp, indf0 ; push wreg value movfp pclath, indf0 ; push pclath value movpf fsr0, bank_fsr ; restore fsr value for other values movfp nobank_fsr, fsr0 ; ; : ; interrupt service routine (isr) code ; pop clrf alusta, f ; fsr0 has auto-decrement, does not affect status bits movfp bank_fsr, fsr0 ; restore fsr value for other values decf fsr0, f ; movfp indf0, pclath ; pop pclath value movfp indf0, wreg ; pop wreg value bsf alusta, fs1 ; fsr0 does not change movpf indf0, alu_temp ; pop alusta value movpf fsr0, bank_fsr ; restore fsr value for other values decf nobank_fsr, f ; movfp nobank_fsr, fsr0 ; save the fsr for bsr values movfp alu_temp, alusta ; movfp indf0, bsr ; no status bits are affected ; retfie ; return from interrupt (enable interrupts)
? 2000 microchip technology inc. ds30289b-page 43 pic17c7xx 7.0 memory organization there are two memory blocks in the pic17c7xx; pro- gram memory and data memory. each block has its own bus, so that access to each block can occur during the same oscillator cycle. the data memory can further be broken down into general purpose ram and the special function reg- isters (sfrs). the operation of the sfrs that control the ? core ? are described here. the sfrs used to con- trol the peripheral modules are described in the section discussing each individual peripheral module. 7.1 program memory organization pic17c7xx devices have a 16-bit program counter capable of addressing a 64k x 16 program memory space. the reset vector is at 0000h and the interrupt vectors are at 0008h, 0010h, 0018h, and 0020h (figure 7-1). 7.1.1 program memory operation the pic17c7xx can operate in one of four possible program memory configurations. the configuration is selected by configuration bits. the possible modes are:  microprocessor  microcontroller  extended microcontroller  protected microcontroller the microcontroller and protected microcontroller modes only allow internal execution. any access beyond the program memory reads unknown data. the protected microcontroller mode also enables the code protection feature. the extended microcontroller mode accesses both the internal program memory, as well as external pro- gram memory. execution automatically switches between internal and external memory. the 16-bits of address allow a program memory range of 64k-words. the microprocessor mode only accesses the external program memory. the on-chip program memory is ignored. the 16-bits of address allow a program mem- ory range of 64k-words. microprocessor mode is the default mode of an unprogrammed device. the different modes allow different access to the con- figuration bits, test memory and boot rom. table 7-1 lists which modes can access which areas in memory. test memory and boot memory are not required for normal operation of the device. care should be taken to ensure that no unintended branches occur to these areas. figure 7-1: program memory map and stack pc<15:0> stack level 1 ? stack level 16 reset vector int pin interrupt vector timer0 interrupt vector t0cki pin interrupt vector peripheral interrupt vector fosc0 fosc1 wdtps0 wdtps1 pm0 reserved pm1 reserved ? ? configuration memory space user memory space (1) call, return retfie, retlw 16 0000h 0008h 0010h 0020h 0021h 0018h fdffh fe00h fe01h fe02h fe03h fe04h fe05h fe06h fe07h fe0fh te s t e p r o m boot rom fe10h ff5fh ff60h ffffh 1fffh 3fffh (pic17c752 (pic17c756a reserved pm2 fe08h note 1: user memory space may be internal, external, or both. the memory configuration depends on the processor mode. fe0eh boden fe0dh pic17c762) pic17c766)
pic17c7xx ds30289b-page 44 ? 2000 microchip technology inc. table 7-1: mode memory access the pic17c7xx can operate in modes where the pro- gram memory is off-chip. they are the microprocessor and extended microcontroller modes. the micropro- cessor mode is the default for an unprogrammed device. regardless of the processor mode, data memory is always on-chip. figure 7-2: memory map in different modes operating mode internal program memory configuration bits, test memory, boot rom microprocessor no access no access microcontroller access access extended microcontroller access no access protected microcontroller access access microprocessor mode 0000h ffffh external program memory external program memory 2000h ffffh 0000h 01fffh on-chip program memory extended microcontroller mode microcontroller modes 0000h 01fffh 2000h fe00h ffffh on-chip on-chip on-chip off-chip on-chip off-chip on-chip off-chip on-chip program space data space config. bits test memory boot rom pic17c752/762 0000h ffffh external program memory external program memory ffffh 0000h 0000h 3fffh 4000h fe00h ffffh off-chip on-chip off-chip on-chip off-chip on-chip config. bits test memory boot rom program space data space on-chip on-chip 00h ffh 1ffh 120h on-chip 3fffh 4000h pic17c756a/766 on-chip program memory on-chip program memory on-chip program memory 2ffh 220h 3ffh 320h 00h ffh 1ffh 120h 2ffh 220h 3ffh 320h 00h ffh 1ffh 120h 2ffh 220h 3ffh 320h 00h ffh 1ffh 120h 00h ffh 1ffh 120h 00h ffh 1ffh 120h
? 2000 microchip technology inc. ds30289b-page 45 pic17c7xx 7.1.2 external memory interface when either microprocessor or extended microcontrol- ler mode is selected, portc, portd and porte are configured as the system bus. portc and portd are the multiplexed address/data bus and porte<2:0> is for the control signals. external components are needed to demultiplex the address and data. this can be done as shown in figure 7-4. the waveforms of address and data are shown in figure 7-3. for com- plete timings, please refer to the electrical specification section. figure 7-3: external program memory access waveforms the system bus requires that there is no bus conflict (minimal leakage), so the output value (address) will be capacitively held at the desired value. as the speed of the processor increases, external eprom memory with faster access time must be used. table 7-2 lists external memory speed requirements for a given pic17c7xx device frequency. in extended microcontroller mode, when the device is executing out of internal memory, the control signals will continue to be active. that is, they indicate the action that is occurring in the internal memory. the external memory access is ignored. the following selection is for use with microchip eproms. for interfacing to other manufacturers mem- ory, please refer to the electrical specifications of the desired pic17c7xx device, as well as the desired memory device to ensure compatibility. table 7-2: eprom memory access time ordering suffix the electrical specifications now include timing specifi- cations for the memory interface with pic17 lc xxx devices. these specifications reflect the capability of the device by characterization. please validate your design with these timings. figure 7-4: typical external program memory connection diagram q3 q1 q2 q4 q3 q1 q2 q4 ad <15:0> ale oe wr ? 1 ? read cycle write cycle address out data in address out data out q1 pic17c7xx oscillator frequency instruction cycle time (t cy ) eprom suffix 8 mhz 500 ns -25 16 mhz 250 ns -15 20 mhz 200 ns -10 25 mhz 160 ns -70 note: the access times for this requires the use of fast srams. ad7-ad0 pic17cxxx ad15-ad8 ale i/o (1) ad15-ad0 memory (3) (msb) ax-a0 d7-d0 a15-a0 memory (3) (lsb) ax-a0 d7-d0 138 (1) oe wr oe oe wr (2) wr (2) ce ce note 1: use of i/o pins is only required for paged memory. 2: this signal is unused for rom and eprom devices. 3: 16-bit wide devices are now common and could be used instead of 8-bit wide devices. 373 (3) 373 (3)
pic17c7xx ds30289b-page 46 ? 2000 microchip technology inc. 7.2 data memory organization data memory is partitioned into two areas. the first is the general purpose registers (gpr) area, and the second is the special function registers (sfr) area. the sfrs control and provide status of device opera- tion. portions of data memory are banked, this occurs in both areas. the gpr area is banked to allow greater than 232 bytes of general purpose ram. banking requires the use of control bits for bank selec- tion. these control bits are located in the bank select register (bsr). if an access is made to the unbanked region, the bsr bits are ignored. figure 7-5 shows the data memory map organization. instructions movpf and movfp provide the means to move values from the peripheral area ( ? p ? ) to any loca- tion in the register file ( ? f ? ), and vice-versa. the defini- tion of the ? p ? range is from 0h to 1fh, while the ? f ? range is 0h to ffh. the ? p ? range has six more loca- tions than peripheral registers, which can be used as general purpose registers. this can be useful in some applications where variables need to be copied to other locations in the general purpose ram (such as saving status information during an interrupt). the entire data memory can be accessed either directly, or indirectly (through file select registers fsr0 and fsr1) (see section 7.4). indirect addressing uses the appropriate control bits of the bsr for access into the banked areas of data memory. the bsr is explained in greater detail in section 7.8. 7.2.1 general purpose register (gpr) all devices have some amount of gpr area. the gprs are 8-bits wide. when the gpr area is greater than 232, it must be banked to allow access to the additional memory space. all the pic17c7xx devices have banked memory in the gpr area. to facilitate switching between these banks, the movlr bank instruction has been added to the instruction set. gprs are not initialized by a power- on reset and are unchanged on all other resets. 7.2.2 special function registers (sfr) the sfrs are used by the cpu and peripheral func- tions to control the operation of the device (figure 7-5). these registers are static ram. the sfrs can be classified into two sets, those asso- ciated with the ? core ? function and those related to the peripheral functions. those registers related to the ? core ? are described here, while those related to a peripheral feature are described in the section for each peripheral feature. the peripheral registers are in the banked portion of memory, while the core registers are in the unbanked region. to facilitate switching between the peripheral banks, the movlb bank instruction has been provided.
? 2000 microchip technology inc. ds30289b-page 47 pic17c7xx figure 7-5: pic17c7xx register file map addr unbanked 00h indf0 01h fsr0 02h pcl 03h pclath 04h alusta 05h t0sta 06h cpusta 07h intsta 08h indf1 09h fsr1 0ah wreg 0bh tmr0l 0ch tmr0h 0dh tblptrl 0eh tblptrh 0fh bsr bank 0 bank 1 (1) bank 2 (1) bank 3 (1) bank 4 (1) bank 5 (1) bank 6 (1) bank 7 (1) bank 8 (1,4) 10h porta ddrc tmr1 pw1dcl pir2 ddrf sspadd pw3dcl ddrh 11h ddrb portc tmr2 pw2dcl pie2 portf sspcon1 pw3dch porth 12h portb ddrd tmr3l pw1dch ? ddrg sspcon2 ca3l ddrj 13h rcsta1 portd tmr3h pw2dch rcsta2 portg sspstat ca3h portj 14h rcreg1 ddre pr1 ca2l rcreg2 adcon0 sspbuf ca4l ? 15h txsta1 porte pr2 ca2h txsta2 adcon1 ? ca4h ? 16h txreg1 pir1 pr3l/ca1l tcon1 txreg2 adresl ? tcon3 ? 17h spbrg1 pie1 pr3h/ca1h tcon2 spbrg2 adresh ? ? ? unbanked 18h prodl 19h prodh 1ah 1fh general purpose ram bank 0 (2) bank 1 (2) bank 2 (2) bank 3 (2,3) 20h ffh general purpose ram general purpose ram general purpose ram general purpose ram note 1: sfr file locations 10h - 17h are banked. the lower nibble of the bsr specifies the bank. all unbanked sfrs ignore the bank select register (bsr) bits. 2: general purpose registers (gpr) locations 20h - ffh, 120h - 1ffh, 220h - 2ffh, and 320h - 3ffh are banked. the upper nibble of the bsr specifies this bank. all other gprs ignore the bank select register (bsr) bits. 3: ram bank 3 is not implemented on the pic17c752 and the pic17c762. reading any unimplemented reg- ister reads ? 0 ? s. 4: bank 8 is only implemented on the pic17c76x devices.
pic17c7xx ds30289b-page 48 ? 2000 microchip technology inc. table 7-3: special function registers address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt unbanked 00h indf0 uses contents of fsr0 to address data memory (not a physical register) ---- ---- ---- ---- 01h fsr0 indirect data memory address pointer 0 xxxx xxxx uuuu uuuu 02h pcl low order 8-bits of pc 0000 0000 0000 0000 03h (1) pclath holding register for upper 8-bits of pc 0000 0000 uuuu uuuu 04h alusta fs3 fs2 fs1 fs0 ov z dc c 1111 xxxx 1111 uuuu 05h t0sta intedg t0se t0cs t0ps3 t0ps2 t0ps1 t0ps0 ? 0000 000- 0000 000- 06h (2) cpusta ? ? stkav glintd to pd por bor --11 11qq --11 qquu 07h intsta peif t0ckif t0if intf peie t0ckie t0ie inte 0000 0000 0000 0000 08h indf1 uses contents of fsr1 to address data memory (not a physical register) ---- ---- ---- ---- 09h fsr1 indirect data memory address pointer 1 xxxx xxxx uuuu uuuu 0ah wreg working register xxxx xxxx uuuu uuuu 0bh tmr0l tmr0 register; low byte xxxx xxxx uuuu uuuu 0ch tmr0h tmr0 register; high byte xxxx xxxx uuuu uuuu 0dh tblptrl low byte of program memory table pointer 0000 0000 0000 0000 0eh tblptrh high byte of program memory table pointer 0000 0000 0000 0000 0fh bsr bank select register 0000 0000 0000 0000 bank 0 10h porta (4,6) rbpu ? ra5/tx1/ ck1 ra4/rx1/ dt1 ra3/sdi/ sda ra2/ss / scl ra1/t0cki ra0/int 0-xx 11xx 0-uu 11uu 11h ddrb data direction register for portb 1111 1111 1111 1111 12h portb (4) rb7/ sdo rb6/ sck rb5/ tclk3 rb4/ tclk12 rb3/ pwm2 rb2/ pwm1 rb1/ cap2 rb0/ cap1 xxxx xxxx uuuu uuuu 13h rcsta1 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 14h rcreg1 serial port receive register xxxx xxxx uuuu uuuu 15h txsta1 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 16h txreg1 serial port transmit register (for usart1) xxxx xxxx uuuu uuuu 17h spbrg1 baud rate generator register (for usart1) 0000 0000 0000 0000 bank 1 10h ddrc (5) data direction register for portc 1111 1111 1111 1111 11h portc (4,5) rc7/ad7 rc6/ad6 rc5/ad5 rc4/ad4 rc3/ad3 rc2/ad2 rc1/ad1 rc0/ad0 xxxx xxxx uuuu uuuu 12h ddrd (5) data direction register for portd 1111 1111 1111 1111 13h portd (4,5) rd7/ ad15 rd6/ ad14 rd5/ ad13 rd4/ ad12 rd3/ ad11 rd2/ ad10 rd1/ad9 rd0/ad8 xxxx xxxx uuuu uuuu 14h ddre (5) data direction register for porte ---- 1111 ---- 1111 15h porte (4,5) ? ? ? ? re3/ cap4 re2/wr re1/oe re0/ale ---- xxxx ---- uuuu 16h pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as '0', q = value depends on condition. shaded cells are unimplemented, read as '0'. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for pc<15:8> whose contents are updated from, or transferred to, the upper byte of the program counter. 2: the to and pd status bits in cpusta are not affected by a mclr reset. 3: bank 8 and associated registers are only implemented on the pic17c76x devices. 4: this is the value that will be in the port output latch. 5: when the device is configured for microprocessor or extended microcontroller mode, the operation of this port does not rely on these registers. 6: on any device reset, these pins are configured as inputs.
? 2000 microchip technology inc. ds30289b-page 49 pic17c7xx bank 2 10h tmr1 timer1 ? s register xxxx xxxx uuuu uuuu 11h tmr2 timer2 ? s register xxxx xxxx uuuu uuuu 12h tmr3l timer3 ? s register; low byte xxxx xxxx uuuu uuuu 13h tmr3h timer3 ? s register; high byte xxxx xxxx uuuu uuuu 14h pr1 timer1 ? s period register xxxx xxxx uuuu uuuu 15h pr2 timer2 ? s period register xxxx xxxx uuuu uuuu 16h pr3l/ca1l timer3 ? s period register - low byte/capture1 register; low byte xxxx xxxx uuuu uuuu 17h pr3h/ca1h timer3 ? s period register - high byte/capture1 register; high byte xxxx xxxx uuuu uuuu bank 3 10h pw1dcl dc1 dc0 ? ? ? ? ? ? xx-- ---- uu-- ---- 11h pw2dcl dc1 dc0 tm2pw2 ? ? ? ? ? xx0- ---- uu0- ---- 12h pw1dch dc9 dc8 dc7 dc6 dc5 dc4 dc3 dc2 xxxx xxxx uuuu uuuu 13h pw2dch dc9 dc8 dc7 dc6 dc5 dc4 dc3 dc2 xxxx xxxx uuuu uuuu 14h ca2l capture2 low byte xxxx xxxx uuuu uuuu 15h ca2h capture2 high byte xxxx xxxx uuuu uuuu 16h tcon1 ca2ed1 ca2ed0 ca1ed1 ca1ed0 t16 tmr3cs tmr2cs tmr1cs 0000 0000 0000 0000 17h tcon2 ca2ovf ca1ovf pwm2on pwm1on ca1/pr3 tmr3on tmr2on tmr1on 0000 0000 0000 0000 bank 4 10h pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0010 000- 0010 11h pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 12h unimplemented ? ? ? ? ? ? ? ? ---- ---- ---- ---- 13h rcsta2 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 14h rcreg2 serial port receive register for usart2 xxxx xxxx uuuu uuuu 15h txsta2 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 16h txreg2 serial port transmit register for usart2 xxxx xxxx uuuu uuuu 17h spbrg2 baud rate generator for usart2 0000 0000 0000 0000 bank 5: 10h ddrf data direction register for portf 1111 1111 1111 1111 11h portf (4) rf7/ an11 rf6/ an10 rf5/ an9 rf4/ an8 rf3/ an7 rf2/ an6 rf1/ an5 rf0/ an4 0000 0000 0000 0000 12h ddrg data direction register for portg 1111 1111 1111 1111 13h portg (4) rg7/ tx2/ck2 rg6/ rx2/dt2 rg5/ pwm3 rg4/ cap3 rg3/ an0 rg2/ an1 rg1/ an2 rg0/ an3 xxxx 0000 uuuu 0000 14h adcon0 chs3 chs2 chs1 chs0 ? go/done ? adon 0000 -0-0 0000 -0-0 15h adcon1 adcs1 adcs0 adfm ? pcfg3 pcfg2 pcfg1 pcfg0 000- 0000 000- 0000 16h adresl a/d result register low byte xxxx xxxx uuuu uuuu 17h adresh a/d result register high byte xxxx xxxx uuuu uuuu table 7-3: special function registers (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt legend: x = unknown, u = unchanged, - = unimplemented, read as '0', q = value depends on condition. shaded cells are unimplemented, read as '0'. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for pc<15:8> whose contents are updated from, or transferred to, the upper byte of the program counter. 2: the to and pd status bits in cpusta are not affected by a mclr reset. 3: bank 8 and associated registers are only implemented on the pic17c76x devices. 4: this is the value that will be in the port output latch. 5: when the device is configured for microprocessor or extended microcontroller mode, the operation of this port does not rely on these registers. 6: on any device reset, these pins are configured as inputs.
pic17c7xx ds30289b-page 50 ? 2000 microchip technology inc. bank 6 10h sspadd ssp address register in i 2 c slave mode. ssp baud rate reload register in i 2 c master mode 0000 0000 0000 0000 11h sspcon1 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 12h sspcon2 gcen akstat akdt aken rcen pen rsen sen 0000 0000 0000 0000 13h sspstat smp cke d/a psr/w ua bf 0000 0000 0000 0000 14h sspbuf synchronous serial port receive buffer/transmit register xxxx xxxx uuuu uuuu 15h unimplemented ? ? ? ? ? ? ? ? ---- ---- ---- ---- 16h unimplemented ? ? ? ? ? ? ? ? ---- ---- ---- ---- 17h unimplemented ? ? ? ? ? ? ? ? ---- ---- ---- ---- bank 7 10h pw3dcl dc1 dc0 tm2pw3 ? ? ? ? ? xx0- ---- uu0- ---- 11h pw3dch dc9 dc8 dc7 dc6 dc5 dc4 dc3 dc2 xxxx xxxx uuuu uuuu 12h ca3l capture3 low byte xxxx xxxx uuuu uuuu 13h ca3h capture3 high byte xxxx xxxx uuuu uuuu 14h ca4l capture4 low byte xxxx xxxx uuuu uuuu 15h ca4h capture4 high byte xxxx xxxx uuuu uuuu 16h tcon3 ? ca4ovf ca3ovf ca4ed1 ca4ed0 ca3ed1 ca3ed0 pwm3on -000 0000 -000 0000 17h unimplemented ? ? ? ? ? ? ? ? ---- ---- ---- ---- bank 8 (3) 10h (3) ddrh data direction register for porth 1111 1111 1111 1111 11h (3) porth (4) rh7/ an15 rh6/ an14 rh5/ an13 rh4/ an12 rh3 rh2 rh1 rh0 xxxx xxxx uuuu uuuu 12h (3) ddrj data direction register for portj 1111 1111 1111 1111 13h (3) portj (4) rj7 rj6 rj5 rj4 rj3 rj2 rj1 rj0 xxxx xxxx uuuu uuuu 14h (3) unimplemented ? ? ? ? ? ? ? ? ---- ---- ---- ---- 15h (3) unimplemented ? ? ? ? ? ? ? ? ---- ---- ---- ---- 16h (3) unimplemented ? ? ? ? ? ? ? ? ---- ---- ---- ---- 17h (3) unimplemented ? ? ? ? ? ? ? ? ---- ---- ---- ---- unbanked 18h prodl low byte of 16-bit product (8 x 8 hardware multiply) xxxx xxxx uuuu uuuu 19h prodh high byte of 16-bit product (8 x 8 hardware multiply) xxxx xxxx uuuu uuuu table 7-3: special function registers (continued) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt legend: x = unknown, u = unchanged, - = unimplemented, read as '0', q = value depends on condition. shaded cells are unimplemented, read as '0'. note 1: the upper byte of the program counter is not directly accessible. pclath is a holding register for pc<15:8> whose contents are updated from, or transferred to, the upper byte of the program counter. 2: the to and pd status bits in cpusta are not affected by a mclr reset. 3: bank 8 and associated registers are only implemented on the pic17c76x devices. 4: this is the value that will be in the port output latch. 5: when the device is configured for microprocessor or extended microcontroller mode, the operation of this port does not rely on these registers. 6: on any device reset, these pins are configured as inputs.
? 2000 microchip technology inc. ds30289b-page 51 pic17c7xx 7.2.2.1 alu status register (alusta) the alusta register contains the status bits of the arithmetic and logic unit and the mode control bits for the indirect addressing register. as with all the other registers, the alusta register can be the destination for any instruction. if the alusta register is the destination for an instruction that affects the z, dc, c, or ov bits, then the write to these three bits is disabled. these bits are set or cleared according to the device logic. therefore, the result of an instruc- tion with the alusta register as destination may be different than intended. for example, the clrf alusta, f instruction will clear the upper four bits and set the z bit. this leaves the alusta register as 0000u1uu (where u = unchanged). it is recommended, therefore, that only bcf , bsf , swapf and movwf instructions be used to alter the alusta register, because these instructions do not affect any status bits. to see how other instructions affect the sta- tus bits, see the ? instruction set summary. ? the arithmetic and logic unit (alu) is capable of car- rying out arithmetic or logical operations on two oper- ands, or a single operand. all single operand instructions operate either on the wreg register, or the given file register. for two operand instructions, one of the operands is the wreg register and the other is either a file register, or an 8-bit immediate constant. register 7-1: alusta register (address: 04h, unbanked) note 1: the c and dc bits operate as a borrow and digit borrow bit, respectively, in subtraction. see the sublw and subwf instructions for examples. 2: the overflow bit will be set if the 2 ? s comple- ment result exceeds +127, or is less than -128. r/w-1 r/w-1 r/w-1 r/w-1 r/w-x r/w-x r/w-x r/w-x fs3 fs2 fs1 fs0 ov z dc c bit 7 bit 0 bit 7-6 fs3:fs2 : fsr1 mode select bits 00 = post auto-decrement fsr1 value 01 = post auto-increment fsr1 value 1x = fsr1 value does not change bit 5-4 fs1:fs0 : fsr0 mode select bits 00 = post auto-decrement fsr0 value 01 = post auto-increment fsr0 value 1x = fsr0 value does not change bit 3 ov : overflow bit this bit is used for signed arithmetic (2 ? s complement). it indicates an overflow of the 7-bit magnitude, which causes the sign bit (bit7) to change state. 1 = overflow occurred for signed arithmetic (in this arithmetic operation) 0 = no overflow occurred 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/borrow bit for addwf and addlw instructions. 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 note: for borrow, the polarity is reversed. bit 0 c : carry/borrow bit for addwf and addlw instructions. note that a subtraction is executed by adding the two ? s complement of the second operand. for rotate ( rrcf , rlcf ) instructions, this bit is loaded with either the high or low order bit of the source register. 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 note: for borrow, the polarity is reversed. legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
pic17c7xx ds30289b-page 52 ? 2000 microchip technology inc. 7.2.2.2 cpu status register (cpusta) the cpusta register contains the status and control bits for the cpu. this register has a bit that is used to globally enable/disable interrupts. if only a specific interrupt is desired to be enabled/disabled, please refer to the interrupt status (intsta) register and the peripheral interrupt enable (pie) registers. the cpusta register also indicates if the stack is available and contains the power-down (pd ) and time-out (to ) bits. the to , pd , and stkav bits are not writable. these bits are set and cleared according to device logic. therefore, the result of an instruction with the cpusta register as destination may be different than intended. the por bit allows the differentiation between a power-on reset, external mclr reset, or a wdt reset. the bor bit indicates if a brown-out reset occurred. register 7-2: cpusta register (address: 06h, unbanked) note 1: the bor status bit is a don ? t care and is not necessarily predictable if the brown-out circuit is disabled (when the boden bit in the configuration word is programmed). u-0 u-0 r-1 r/w-1 r-1 r-1 r/w-0 r/w-1 ? ? stkav glintd to pd por bor bit 7 bit 0 bit 7-6 unimplemented : read as '0' bit 5 stkav : stack available bit this bit indicates that the 4-bit stack pointer value is fh, or has rolled over from fh 0h (stack overflow). 1 = stack is available 0 = stack is full, or a stack overflow may have occurred (once this bit has been cleared by a stack overflow, only a device reset will set this bit) bit 4 glintd : global interrupt disable bit this bit disables all interrupts. when enabling interrupts, only the sources with their enable bits set can cause an interrupt. 1 = disable all interrupts 0 = enables all unmasked interrupts bit 3 to : wdt time-out status bit 1 = after power-up, by a clrwdt instruction, or by a sleep instruction 0 = a watchdog timer time-out occurred bit 2 pd : power-down status bit 1 = after power-up or by the clrwdt instruction 0 = by execution of the sleep instruction bit 1 por : power-on reset status bit 1 = no power-on reset occurred 0 = a power-on reset occurred (must be set by software) bit 0 bor : brown-out reset status bit when boden configuration bit is set (enabled): 1 = no brown-out reset occurred 0 = a brown-out reset occurred (must be set by software) when boden configuration bit is clear (disabled): don ? t care legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
? 2000 microchip technology inc. ds30289b-page 53 pic17c7xx 7.2.2.3 tmr0 status/control register (t0sta) this register contains various control bits. bit7 (intedg) is used to control the edge upon which a sig- nal on the ra0/int pin will set the ra0/int interrupt flag. the other bits configure timer0, it ? s prescaler and clock source. register 7-3: t0sta register (address: 05h, unbanked) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 intedg t0se t0cs t0ps3 t0ps2 t0ps1 t0ps0 ? bit 7 bit 0 bit 7 intedg : ra0/int pin interrupt edge select bit this bit selects the edge upon which the interrupt is detected. 1 = rising edge of ra0/int pin generates interrupt 0 = falling edge of ra0/int pin generates interrupt bit 6 t0se : timer0 external clock input edge select bit this bit selects the edge upon which tmr0 will increment. when t0cs = 0 (external clock): 1 = rising edge of ra1/t0cki pin increments tmr0 and/or sets the t0ckif bit 0 = falling edge of ra1/t0cki pin increments tmr0 and/or sets a t0ckif bit when t0cs = 1 (internal clock): don ? t care bit 5 t0cs : timer0 clock source select bit this bit selects the clock source for timer0. 1 = internal instruction clock cycle (t cy ) 0 = external clock input on the t0cki pin bit 4-1 t0ps3:t0ps0 : timer0 prescale selection bits these bits select the prescale value for timer0. bit 0 unimplemented : read as ? 0 ? legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown t0ps3:t0ps0 prescale value 0000 0001 0010 0011 0100 0101 0110 0111 1xxx 1:1 1:2 1:4 1:8 1:16 1:32 1:64 1:128 1:256
pic17c7xx ds30289b-page 54 ? 2000 microchip technology inc. 7.3 stack operation pic17c7xx devices have a 16 x 16-bit hardware stack (figure 7-1). the stack is not part of either the program or data memory space, and the stack pointer is neither readable nor writable. the pc (program counter) is ? push ? d ? onto the stack when a call or lcall instruction is executed, or an interrupt is acknowl- edged. the stack is ? pop ? d ? in the event of a return , retlw , or a retfie instruction execution. pclath is not affected by a ? push ? or a ? pop ? operation. the stack operates as a circular buffer, with the stack pointer initialized to '0' after all resets. there is a stack available bit (stkav) to allow software to ensure that the stack will not overflow. the stkav bit is set after a device reset. when the stack pointer equals fh, stkav is cleared. when the stack pointer rolls over from fh to 0h, the stkav bit will be held clear until a device reset. after the device is ? push ? d ? sixteen times (without a ? pop ? ), the seventeenth push overwrites the value from the first push. the eighteenth push overwrites the second push (and so on). 7.4 indirect addressing indirect addressing is a mode of addressing data mem- ory where the data memory address in the instruction is not fixed. that is, the register that is to be read or written can be modified by the program. this can be useful for data tables in the data memory. figure 7-6 shows the operation of indirect addressing. this depicts the moving of the value to the data memory address specified by the value of the fsr register. example 7-1 shows the use of indirect addressing to clear ram in a minimum number of instructions. a sim- ilar concept could be used to move a defined number of bytes (block) of data to the usart transmit register (txreg). the starting address of the block of data to be transmitted could easily be modified by the program. figure 7-6: indirect addressing 7.4.1 indirect addressing registers the pic17c7xx has four registers for indirect address- ing. these registers are:  indf0 and fsr0  indf1 and fsr1 registers indf0 and indf1 are not physically imple- mented. reading or writing to these registers activates indirect addressing, with the value in the corresponding fsr register being the address of the data. the fsr is an 8-bit register and allows addressing anywhere in the 256-byte data memory address range. for banked memory, the bank of memory accessed is specified by the value in the bsr. if file indf0 (or indf1) itself is read indirectly via an fsr, all '0's are read (zero bit is set). similarly, if indf0 (or indf1) is written to indirectly, the operation will be equivalent to a nop , and the status bits are not affected. note 1: there is not a status bit for stack under- flow. the stkav bit can be used to detect the underflow which results in the stack pointer being at the top-of-stack. 2: there are no instruction mnemonics called push or pop. these are actions that occur from the execution of the call , return , retlw and retfie instruc- tions, or the vectoring to an interrupt vector. 3: after a reset, if a ? pop ? operation occurs before a ? push ? operation, the stkav bit will be cleared. this will appear as if the stack is full (underflow has occurred). if a ? push ? operation occurs next (before another ? pop ? ), the stkav bit will be locked clear. only a device reset will cause this bit to set. opcode address file = indfx fsr instruction executed instruction fetched ram opcode file 8 8 8
? 2000 microchip technology inc. ds30289b-page 55 pic17c7xx 7.4.2 indirect addressing operation the indirect addressing capability has been enhanced over that of the pic16cxx family. there are two control bits associated with each fsr register. these two bits configure the fsr register to:  auto-decrement the value (address) in the fsr after an indirect access  auto-increment the value (address) in the fsr after an indirect access  no change to the value (address) in the fsr after an indirect access these control bits are located in the alusta register. the fsr1 register is controlled by the fs3:fs2 bits and fsr0 is controlled by the fs1:fs0 bits. when using the auto-increment or auto-decrement fea- tures, the effect on the fsr is not reflected in the alusta register. for example, if the indirect address causes the fsr to equal '0', the z bit will not be set. if the fsr register contains a value of 0h, an indirect read will read 0h (zero bit is set) while an indirect write will be equivalent to a nop (status bits are not affected). indirect addressing allows single cycle data transfers within the entire data space. this is possible with the use of the movpf and movfp instructions, where either ' p ' or ' f ' is specified as indf0 (or indf1 ). if the source or destination of the indirect address is in banked memory, the location accessed will be deter- mined by the value in the bsr. a simple program to clear ram from 20h - ffh is shown in example 7-1. example 7-1: indirect addressing 7.5 table pointer (tblptrl and tblptrh) file registers tblptrl and tblptrh form a 16-bit pointer to address the 64k program memory space. the table pointer is used by instructions tablwt and tablrd . the tablrd and the tablwt instructions allow trans- fer of data between program and data space. the table pointer serves as the 16-bit address of the data word within the program memory. for a more complete description of these registers and the operation of table reads and table writes, see section 8.0. 7.6 table latch (tblath, tblatl) the table latch (tblat) is a 16-bit register, with tblath and tblatl referring to the high and low bytes of the register. it is not mapped into data or pro- gram memory. the table latch is used as a temporary holding latch during data transfer between program and data memory (see tablrd , tablwt , tlrd and tlwt instruction descriptions). for a more complete description of these registers and the operation of table reads and table writes, see section 8.0. movlw 0x20 ; movwf fsr0 ; fsr0 = 20h bcf alusta, fs1 ; increment fsr bsf alusta, fs0 ; after access bcf alusta, c ; c = 0 movlw end_ram + 1 ; lp clrf indf0, f ; addr(fsr) = 0 cpfseq fsr0 ; fsr0 = end_ram+1? goto lp ; no, clear next : ; yes, all ram is : ; cleared
pic17c7xx ds30289b-page 56 ? 2000 microchip technology inc. 7.7 program counter module the program counter (pc) is a 16-bit register. pcl, the low byte of the pc, is mapped in the data memory. pcl is readable and writable just as is any other register. pch is the high byte of the pc and is not directly addressable. since pch is not mapped in data or pro- gram memory, an 8-bit register pclath (pc high latch) is used as a holding latch for the high byte of the pc. pclath is mapped into data memory. the user can read or write pch through pclath. the 16-bit wide pc is incremented after each instruc- tion fetch during q1 unless:  modified by a goto , call , lcall , return , retlw , or retfie instruction  modified by an interrupt response  due to destination write to pcl by an instruction ? skips ? are equivalent to a forced nop cycle at the skipped address. figure 7-7 and figure 7-8 show the operation of the program counter for various situations. figure 7-7: program counter operation figure 7-8: program counter using the call and goto instructions using figure 7-7, the operations of the pc and pclath for different instructions are as follows: a) lcall instructions : an 8-bit destination address is provided in the instruction (opcode). pclath is unchanged. pclath pch opcode<7:0> pcl b) read instructions on pcl : any instruction that reads pcl. pcl data bus alu or destination pch pclath c) write instructions on pcl : any instruction that writes to pcl. 8-bit data data bus pcl pclath pch d) read-modify-write instructions on pcl: any instruction that does a read-write-modify operation on pcl, such as addwf pcl . read: pcl data bus alu write: 8-bit result data bus pcl pclath pch e) return instruction: stack pc<15:0> using figure 7-8, the operation of the pc and pclath for goto and call instructions is as follows: call , goto instructions : a 13-bit destination address is provided in the instruction (opcode). opcode<12:0> pc<12:0> pc<15:13> pclath<7:5> opcode<12:8> pclath<4:0> the read-modify-write only affects the pcl with the result. pch is loaded with the value in the pclath. for example, addwf pcl will result in a jump within the current page. if pc = 03f0h, wreg = 30h and pclath = 03h before instruction, pc = 0320h after the instruction. to accomplish a true 16-bit computed jump, the user needs to compute the 16-bit destination address, write the high byte to pclath and then write the low value to pcl. the following pc related operations do not change pclath: a) lcall , retlw , and retfie instructions. b) interrupt vector is forced onto the pc. c) read-modify-write instructions on pcl (e.g. bsf pcl ). internal data bus <8> pclath 8 8 8 pch pcl 8 15 0 7 5 4 0 12 8 7 0 87 pc<15:13> pclath from instruction 5 3 8 pch pcl 13 15
? 2000 microchip technology inc. ds30289b-page 57 pic17c7xx 7.8 bank select register (bsr) the bsr is used to switch between banks in the data memory area (figure 7-9). in the pic17c7xx devices, the entire byte is implemented. the lower nibble is used to select the peripheral register bank. the upper nibble is used to select the general purpose memory bank. all the special function registers (sfrs) are mapped into the data memory space. in order to accommodate the large number of registers, a banking scheme has been used. a segment of the sfrs, from address 10h to address 17h, is banked. the lower nibble of the bank select register (bsr) selects the currently active ? peripheral bank. ? effort has been made to group the peripheral registers of related functionality in one bank. however, it will still be necessary to switch from bank to bank in order to address all peripherals related to a sin- gle task. to assist this, a movlb bank instruction has been included in the instruction set. the need for a large general purpose memory space dictated a general purpose ram banking scheme. the upper nibble of the bsr selects the currently active general purpose ram bank. to assist this, a movlr bank instruction has been provided in the instruction set. if the currently selected bank is not implemented (such as bank 13), any read will read all '0's. any write is completed to the bit bucket and the alu status bits will be set/cleared as appropriate. figure 7-9: bsr operation note: registers in bank 15 in the special func- tion register area, are reserved for microchip use. reading of registers in this bank may cause random values to be read. 7430 10h 17h bsr 0 123 8 15 ? ? ? 20h ffh ? ? ? (1) (2) bank 15 bank 8 bank 3 bank 2 bank 1 bank 0 01 2 bank 2 bank 1 bank 0 15 bank 15 sfr banks gpr banks address range note 1: for the sfrs only banks 0 through 8 are implemented. selection of an unimplemented bank is not recommended. bank 15 is reserved for microchip use, reading of registers in this bank may cause random values to be read. 2: for the gprs, bank 3 is unimplemented on the pic17c752 and the pic17c762. selection of an unimplemented bank is not recommended. 3: sfr bank 8 is only implemented on the pic17c76x. 3 bank 3 4 bank 4 4 5 6 7 bank 7 bank 6 bank 5 bank 4 (peripheral) (ram)
pic17c7xx ds30289b-page 58 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 59 pic17c7xx 8.0 table reads and table writes the pic17c7xx has four instructions that allow the processor to move data from the data memory space to the program memory space, and vice versa. since the program memory space is 16-bits wide and the data memory space is 8-bits wide, two operations are required to move 16-bit values to/from the data memory. the tlwt t,f and tablwt t,i,f instructions are used to write data from the data memory space to the program memory space. the tlrd t,f and tablrd t,i,f instructions are used to write data from the pro- gram memory space to the data memory space. the program memory can be internal or external. for the program memory access to be external, the device needs to be operating in microprocessor or extended microcontroller mode. figure 8-1 through figure 8-4 show the operation of these four instructions. the steps show the sequence of operation. figure 8-1: tlwt instruction operation figure 8-2: tablwt instruction operation table pointer table latch (16-bit) program memory data memory tblptrh tblptrl tablath tablatl f tlwt 1,f tlwt 0,f 1 step 1: 8-bit value from register ? f ? , loaded into the high or low byte in tablat (16-bit). table pointer table latch (16-bit) program memory data memory tblptrh tblptrl tablath tablatl f tablwt 1,i,f tablwt 0,i,f 1 prog-mem (tblptr) 2 step 1: 8-bit value from register ? f ? , loaded into the high or low byte in tablat (16-bit). 2: 16-bit tablat value written to address program memory (tblptr). 3: if ? i ? = 1, then tblptr = tblptr + 1, if ? i ? = 0, then tblptr is unchanged. 3 3
pic17c7xx ds30289b-page 60 ? 2000 microchip technology inc. figure 8-3: tlrd instruction operation figure 8-4: tablrd instruction operation table pointer table latch (16-bit) program memory data memory tblptrh tblptrl tablath tablatl f tlrd 1,f tlrd 0,f 1 step 1: 8-bit value from tablat (16-bit) high or low byte, loaded into register ? f ? . table pointer table latch (16-bit) program memory data memory tblptrh tblptrl tablath tablatl f tablrd 1,i,f tablrd 0,i,f 1 prog-mem (tblptr) 2 step 1: 8-bit value from tablat (16-bit) high or low byte, loaded into register ? f ? . 2: 16-bit value at program memory (tblptr), loaded into tablat register. 3: if ? i ? = 1, then tblptr = tblptr + 1, if ? i ? = 0, then tblptr is unchanged. 3 3
? 2000 microchip technology inc. ds30289b-page 61 pic17c7xx 8.1 table writes to internal memory a table write operation to internal memory causes a long write operation. the long write is necessary for programming the internal eprom. instruction execu- tion is halted while in a long write cycle. the long write will be terminated by any enabled interrupt. to ensure that the eprom location has been well programmed, a minimum programming time is required (see specifi- cation #d114). having only one interrupt enabled to ter- minate the long write ensures that no unintentional interrupts will prematurely terminate the long write. the sequence of events for programming an internal program memory location should be: 1. disable all interrupt sources, except the source to terminate eprom program write. 2. raise mclr /v pp pin to the programming voltage. 3. clear the wdt. 4. do the table write. the interrupt will terminate the long write. 5. verify the memory location (table read). 8.1.1 terminating long writes an interrupt source or reset are the only events that terminate a long write operation. terminating the long write from an interrupt source requires that the interrupt enable and flag bits are set. the glintd bit only enables the vectoring to the interrupt address. if the t0cki, ra0/int, or tmr0 interrupt source is used to terminate the long write, the interrupt flag of the highest priority enabled interrupt, will terminate the long write and automatically be cleared. if a peripheral interrupt source is used to terminate the long write, the interrupt enable and flag bits must be set. the interrupt flag will not be automatically cleared upon the vectoring to the interrupt vector address. the glintd bit determines whether the program will branch to the interrupt vector when the long write is ter- minated. if glintd is clear, the program will vector, if glintd is set, the program will not vector to the interrupt address. table 8-1: interrupt - table write interaction note 1: programming requirements must be met. see timing specification in electrical specifications for the desired device. violating these specifications (including temperature) may result in eprom locations that are not fully programmed and may lose their state over time. 2: if the v pp requirement is not met, the table write is a 2-cycle write and the pro- gram memory is unchanged. note 1: if an interrupt is pending, the tablwt is aborted (a nop is executed). the highest priority pending interrupt, from the t0cki, ra0/int, or tmr0 sources that is enabled, has its flag cleared. 2: if the interrupt is not being used for the program write timing, the interrupt should be disabled. this will ensure that the interrupt is not lost, nor will it termi- nate the long write prematurely. interrupt source glintd enable bit flag bit action ra0/int, tmr0, t0cki 0 0 1 1 1 1 0 1 1 0 x 1 terminate long table write (to internal program memory), branch to interrupt vector (branch clears flag bit). none. none. terminate long table write, do not branch to interrupt vector (flag is automatically cleared). peripheral 0 0 1 1 1 1 0 1 1 0 x 1 terminate long table write, branch to interrupt vector. none. none. terminate long table write, do not branch to interrupt vector (flag remains set).
pic17c7xx ds30289b-page 62 ? 2000 microchip technology inc. 8.2 table writes to external memory table writes to external memory are always two-cycle instructions. the second cycle writes the data to the external memory location. the sequence of events for an external memory write are the same for an internal write. 8.2.1 table write code the ? i ? operand of the tablwt instruction can specify that the value in the 16-bit tblptr register is automat- ically incremented (for the next write). in example 8-1, the tblptr register is not automatically incremented. example 8-1: table write figure 8-5: tablwt write timing (external memory) clrwdt ; clear wdt movlw high (tbl_addr) ; load the table movwf tblptrh ; address movlw low (tbl_addr) ; movwf tblptrl ; movlw high (data) ; load hi byte tlwt 1, wreg ; in tablath movlw low (data) ; load lo byte tablwt 0,0,wreg ; in tablatl ; and write to ; program memory ; (ext. sram) q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 ad15:ad0 instruction fetched instruction executed ale oe wr tablwt inst (pc+1) inst (pc-1) tablwt cycle1 tablwt cycle2 inst (pc+2) data write cycle ? 1 ? pc pc+1 tbl pc+2 data out inst (pc+1) note: if external write and glintd = ? 1 ? and enable bit = ? 1 ? , then when ? 1 ? flag bit, do table write. the highest pending interrupt is cleared. oe
? 2000 microchip technology inc. ds30289b-page 63 pic17c7xx figure 8-6: consecutive tablwt write timing (external memory) q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 ad15:ad0 instruction fetched instruction executed ale oe wr pc tablwt1 tablwt2 inst (pc+2) inst (pc-1) tablwt1 cycle1 tablwt1 cycle2 tablwt2 cycle1 tablwt2 cycle2 data write cycle data write cycle inst (pc+3) pc+1 tbl1 pc+2 tbl2 pc+3 data out 1 data out 2 inst (pc+2)
pic17c7xx ds30289b-page 64 ? 2000 microchip technology inc. 8.3 table reads the table read allows the program memory to be read. this allows constants to be stored in the program mem- ory space and retrieved into data memory when needed. example 8-2 reads the 16-bit value at program memory address tblptr. after the dummy byte has been read from the tablath, the tablath is loaded with the 16-bit data from program memory address tblptr and then increments the tblptr value. the first read loads the data into the latch and can be con- sidered a dummy read (unknown data loaded into ? f ? ). indf0 should be configured for either auto-increment or auto-decrement. example 8-2: table read figure 8-7: tablrd timing figure 8-8: tablrd timing (consecutive tablrd instructions) movlw high (tbl_addr) ; load the table movwf tblptrh ; address movlw low (tbl_addr) ; movwf tblptrl ; tablrd 0, 1, dummy ; dummy read, ; updates tablath ; increments tblptr tlrd 1, indf0 ; read hi byte ; of tablath tablrd 0, 1, indf0 ; read lo byte ; of tablatl and ; update tablath ; increment tblptr q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 ad15:ad0 instruction fetched instruction executed ale oe wr tablrd inst (pc+1) inst (pc+2) inst (pc-1) tablrd cycle1 tablrd cycle2 inst (pc+1) data read cycle pc pc+1 tbl data in pc+2 ? 1 ? q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 ad15:ad0 instruction fetched instruction executed tablrd1 tablrd2 inst (pc+2) inst (pc+3) inst (pc+2) ale oe wr inst (pc-1) tablrd1 cycle1 tablrd1 cycle2 tablrd2 cycle1 tablrd2 cycle2 data read cycle data read cycle ? 1 ? pc pc+1 pc+2 pc+3 tbl1 data in 1 tbl2 data in 2
? 2000 microchip technology inc. ds30289b-page 65 pic17c7xx 8.4 operation with external memory interface when the table reads/writes are accessing external memory (via the external system interface bus), the table latch for the table reads is different from the table latch for the table writes (see figure 8-9). this means that you cannot do a tablrd instruction, and use the values that were loaded into the table latches for a tablwt instruction. any table write sequence should use both the tlwt and then the tablwt instructions. figure 8-9: accessing external memory with tablrd and tablwt instructions tablptr tablath (for table reads) tablath (for table writes) program memory tablrd tablwt (in external memory space)
pic17c7xx ds30289b-page 66 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 67 pic17c7xx 9.0 hardware multiplier all pic17c7xx devices have an 8 x 8 hardware multi- plier included in the alu of the device. by making the multiply a hardware operation, it completes in a single instruction cycle. this is an unsigned multiply that gives a 16-bit result. the result is stored into the 16-bit product register (prodh:prodl). the multiplier does not affect any flags in the alusta register. making the 8 x 8 multiplier execute in a single cycle gives the following advantages:  higher computational throughput  reduces code size requirements for multiply algo- rithms the performance increase allows the device to be used in applications previously reserved for digital signal processors. table 9-1 shows a performance comparison between pic17cxxx devices using the single cycle hardware multiply and performing the same function without the hardware multiply. example 9-1 shows the sequence to do an 8 x 8 unsigned multiply. only one instruction is required when one argument of the multiply is already loaded in the wreg register. example 9-2 shows the sequence to do an 8 x 8 signed multiply. to account for the sign bits of the arguments, each argument ? s most significant bit (msb) is tested and the appropriate subtractions are done. example 9-1: 8 x 8 unsigned multiply routine example 9-2: 8 x 8 signed multiply routine table 9-1: performance comparison movfp arg1, wreg ; mulwf arg2 ; arg1 * arg2 -> ; prodh:prodl movfp arg1, wreg mulwf arg2 ; arg1 * arg2 -> ; prodh:prodl btfsc arg2, sb ; test sign bit subwf prodh, f ; prodh = prodh ; - arg1 movfp arg2, wreg btfsc arg1, sb ; test sign bit subwf prodh, f ; prodh = prodh ; - arg2 routine multiply method program memory (words) cycles (max) time @ 33 mhz @ 16 mhz @ 8 mhz 8 x 8 unsigned without hardware multiply 13 69 8.364 s17.25 s 34.50 s hardware multiply 1 1 0.121 s0.25 s0.50 s 8 x 8 signed without hardware multiply ????? hardware multiply 6 6 0.727 s1.50 s3.0 s 16 x 16 unsigned without hardware multiply 21 242 29.333 s60.50 s 121.0 s hardware multiply 24 24 2.91 s6.0 s 12.0 s 16 x 16 signed without hardware multiply 52 254 30.788 s63.50 s 127.0 s hardware multiply 36 36 4.36 s9.0 s 18.0 s
pic17c7xx ds30289b-page 68 ? 2000 microchip technology inc. example 9-3 shows the sequence to do a 16 x 16 unsigned multiply. equation 9-1 shows the algorithm that is used. the 32-bit result is stored in 4 registers, res3:res0. equation 9-1: 16 x 16 unsigned multiplication algorithm example 9-3: 16 x 16 unsigned multiply routine res3:res0 = arg1h:arg1l ? arg2h:arg2l = (arg1h ? arg2h ? 2 16 )+ (arg1h ? arg2l ? 2 8 )+ (arg1l ? arg2h ? 2 8 )+ (arg1l ? arg2l) movfp arg1l, wreg mulwf arg2l ; arg1l * arg2l -> ; prodh:prodl movpf prodh, res1 ; movpf prodl, res0 ; ; movfp arg1h, wreg mulwf arg2h ; arg1h * arg2h -> ; prodh:prodl movpf prodh, res3 ; movpf prodl, res2 ; ; movfp arg1l, wreg mulwf arg2h ; arg1l * arg2h -> ; prodh:prodl movfp prodl, wreg ; addwf res1, f ; add cross movfp prodh, wreg ; products addwfc res2, f ; clrf wreg, f ; addwfc res3, f ; ; movfp arg1h, wreg ; mulwf arg2l ; arg1h * arg2l -> ; prodh:prodl movfp prodl, wreg ; addwf res1, f ; add cross movfp prodh, wreg ; products addwfc res2, f ; clrf wreg, f ; addwfc res3, f ;
? 2000 microchip technology inc. ds30289b-page 69 pic17c7xx example 9-4 shows the sequence to do a 16 x 16 signed multiply. equation 9-2 shows the algorithm used. the 32-bit result is stored in four registers, res3:res0. to account for the sign bits of the argu- ments, each argument pairs most significant bit (msb) is tested and the appropriate subtractions are done. equation 9-2: 16 x 16 signed multiplication algorithm example 9-4: 16 x 16 signed multiply routine res3:res0 = arg1h:arg1l ? arg2h:arg2l = (arg1h ? arg2h ? 2 16 )+ (arg1h ? arg2l ? 2 8 )+ (arg1l ? arg2h ? 2 8 )+ (arg1l ? arg2l) + (-1 ? arg2h<7> ? arg1h:arg1l ? 2 16 )+ (-1 ? arg1h<7> ? arg2h:arg2l ? 2 16 ) movfp arg1l, wreg mulwf arg2l ; arg1l * arg2l -> ; prodh:prodl movpf prodh, res1 ; movpf prodl, res0 ; ; movfp arg1h, wreg mulwf arg2h ; arg1h * arg2h -> ; prodh:prodl movpf prodh, res3 ; movpf prodl, res2 ; ; movfp arg1l, wreg mulwf arg2h ; arg1l * arg2h -> ; prodh:prodl movfp prodl, wreg ; addwf res1, f ; add cross movfp prodh, wreg ; products addwfc res2, f ; clrf wreg, f ; addwfc res3, f ; ; movfp arg1h, wreg ; mulwf arg2l ; arg1h * arg2l -> ; prodh:prodl movfp prodl, wreg ; addwf res1, f ; add cross movfp prodh, wreg ; products addwfc res2, f ; clrf wreg, f ; addwfc res3, f ; ; btfss arg2h, 7 ; arg2h:arg2l neg? goto sign_arg1 ; no, check arg1 movfp arg1l, wreg ; subwf res2 ; movfp arg1h, wreg ; subwfb res3 ; sign_arg1 btfss arg1h, 7 ; arg1h:arg1l neg? goto cont_code ; no, done movfp arg2l, wreg ; subwf res2 ; movfp arg2h, wreg ; subwfb res3 ; cont_code :
pic17c7xx ds30289b-page 70 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 71 pic17c7xx 10.0 i/o ports pic17c75x devices have seven i/o ports, porta through portg. pic17c76x devices have nine i/o ports, porta through portj. portb through portj have a corresponding data direction register (ddr), which is used to configure the port pins as inputs or outputs. some of these ports pins are multi- plexed with alternate functions. portc, portd, and porte are multiplexed with the system bus. these pins are configured as the system bus when the device ? s configuration bits are selected to microprocessor or extended microcontroller modes. in the two other microcontroller modes, these pins are general purpose i/o. porta, portb, porte<3>, portf, portg and the upper four bits of porth are multiplexed with the peripheral features of the device. these peripheral fea- tures are:  timer modules  capture modules  pwm modules  usart/sci modules  ssp module  a/d module  external interrupt pin when some of these peripheral modules are turned on, the port pin will automatically configure to the alternate function. the modules that do this are:  pwm module  ssp module  usart/sci module when a pin is automatically configured as an output by a peripheral module, the pins data direction (ddr) bit is unknown. after disabling the peripheral module, the user should re-initialize the ddr bit to the desired con- figuration. the other peripheral modules (which require an input) must have their data direction bits configured appropri- ately. when the device enters the ? reset state ? , the data direction registers (ddr) are forced set, which will make the i/o hi-impedance inputs. the reset state of some peripheral modules may force the i/o to other operations, such as analog inputs or the system bus. note: a pin that is a peripheral input, can be con- figured as an output (ddrx is cleared). the peripheral events will be determined by the action output on the port pin.
pic17c7xx ds30289b-page 72 ? 2000 microchip technology inc. 10.1 porta register porta is a 6-bit wide latch. porta does not have a corresponding data direction register (ddr). upon a device reset, the porta pins are forced to be hi- impedance inputs. for the ra4 and ra5 pins, the peripheral module controls the output. when a device reset occurs, the peripheral module is disabled, so these pins are forced to be hi-impedance inputs. reading porta reads the status of the pins. the ra0 pin is multiplexed with the external interrupt, int. the ra1 pin is multiplexed with tmr0 clock input, ra2 and ra3 are multiplexed with the ssp functions, and ra4 and ra5 are multiplexed with the usart1 functions. the control of ra2, ra3, ra4 and ra5 as outputs, is automatically configured by their multi- plexed peripheral module when the module is enabled. 10.1.1 using ra2, ra3 as outputs the ra2 and ra3 pins are open drain outputs. to use the ra2 and/or the ra3 pin(s) as output(s), simply write to the porta register the desired value. a ? 0 ? will cause the pin to drive low, while a ? 1 ? will cause the pin to float (hi-impedance). an external pull-up resistor should be used to pull the pin high. writes to the ra2 and ra3 pins will not affect the other porta pins. example 10-1 shows an instruction sequence to initial- ize porta. the bank select register (bsr) must be selected to bank 0 for the port to be initialized. the fol- lowing example uses the movlb instruction to load the bsr register for bank selection. example 10-1: initializing porta figure 10-1: ra0 and ra1 block diagram figure 10-2: ra2 block diagram note: when using the ra2 or ra3 pin(s) as out- put(s), read-modify-write instructions (such as bcf , bsf , btg ) on porta are not recommended. such operations read the port pins, do the desired operation, and then write this value to the data latch. this may inadvertently cause the ra2 or ra3 pins to switch from input to output (or vice-versa). to avoid this possibility, use a shadow reg- ister for porta. do the bit operations on this shadow register and then move it to porta. movlb 0 ; select bank 0 movlw 0xf3 ; movwf porta ; initialize porta ; ra<3:2> are output low ; ra<5:4> and ra<1:0> ; are inputs ; (outputs floating) note: input pins have protection diodes to v dd and v ss . data bus rd_porta (q2) note: i/o pin has protection diodes to v ss . data bus wr_porta (q4) qd q ck rd_porta (q2) q d en peripheral data in 1 0 i 2 c mode enable scl out
? 2000 microchip technology inc. ds30289b-page 73 pic17c7xx figure 10-3: ra3 block diagram figure 10-4: ra4 and ra5 block diagram table 10-1: porta functions table 10-2: registers/bits associated with porta note: i/o pin has protection diodes to v ss . data bus wr_porta (q4) qd q ck rd_porta (q2) q d en peripheral data in sda out ssp mode ? 1 ? note: i/o pins have protection diodes to v dd and v ss . data bus rd_porta (q2) serial port output signals serial port input signal oe = spen,sync,txen, cren , sren for ra4 oe = spen (sync +sync, csrc ) for ra5 name bit0 buffer type function ra0/int bit0 st input or external interrupt input. ra1/t0cki bit1 st input or clock input to the tmr0 timer/counter and/or an external interrupt input. ra2/ss /scl bit2 st input/output or slave select input for the spi, or clock input for the i 2 c bus. output is open drain type. ra3/sdi/sda bit3 st input/output or data input for the spi, or data for the i 2 c bus. output is open drain type. ra4/rx1/dt1 bit4 st input or usart1 asynchronous receive input, or usart1 synchronous data input/output. ra5/tx1/ck1 bit5 st input or usart1 asynchronous transmit output, or usart1 synchronous clock input/output. rbpu bit7 ? control bit for portb weak pull-ups. legend: st = schmitt trigger input address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 10h, bank 0 porta (1) rbpu ? ra5/ tx1/ck1 ra4/ rx1/dt1 ra3/ sdi/sda ra2/ ss /scl ra1/t0cki ra0/int 0-xx 11xx 0-uu 11uu 05h, unbanked t0sta intedg t0se t0cs t0ps3 t0ps2 t0ps1 t0ps0 ? 0000 000- 0000 000- 13h, bank 0 rcsta1 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 15h, bank 0 txsta1 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u legend: x = unknown, u = unchanged, - = unimplemented, reads as '0'. shaded cells are not used by porta. note 1: on any device reset, these pins are configured as inputs.
pic17c7xx ds30289b-page 74 ? 2000 microchip technology inc. 10.2 portb and ddrb registers portb is an 8-bit wide, bi-directional port. the corre- sponding data direction register is ddrb. a ? 1 ? in ddrb configures the corresponding port pin as an input. a ? 0 ? in the ddrb register configures the corresponding port pin as an output. reading portb reads the status of the pins, whereas writing to portb will write to the port latch. each of the portb pins has a weak internal pull-up. a single control bit can turn on all the pull-ups. this is done by clearing the rbpu (porta<7>) bit. the weak pull-up is automatically turned off when the port pin is configured as an output. the pull-ups are enabled on any reset. portb also has an interrupt-on-change feature. only pins configured as inputs can cause this interrupt to occur (i.e., any rb7:rb0 pin configured as an output is excluded from the interrupt-on-change comparison). the input pins (of rb7:rb0) are compared with the value in the portb data latch. the ? mismatch ? outputs of rb7:rb0 are or ? d together to set the portb inter- rupt flag bit, rbif (pir1<7>). this interrupt can wake the device from sleep. the user, in the interrupt service routine, can clear the interrupt by: a) read-write portb (such as: movpf portb, portb ). this will end the mismatch condition. b) then, clear the rbif bit. a mismatch condition will continue to set the rbif bit. reading, then writing portb, will end the mismatch condition and allow the rbif bit to be cleared. this interrupt-on-mismatch feature, together with soft- ware configurable pull-ups on this port, allows easy interface to a keypad and makes it possible for wake- up on key depression. for an example, refer to appli- cation note an552, ? implementing wake-up on keystroke. ? the interrupt-on-change feature is recommended for wake-up on operations, where portb is only used for the interrupt-on-change feature and key depression operations. figure 10-5: block diagram of rb5:rb4 and rb1:rb0 port pins note: on a device reset, the rbif bit is inde- terminate, since the value in the latch may be different than the pin. note: i/o pins have protection diodes to v dd and v ss . data bus q d ck q d ck weak pull-up port input latch port data oe wr_portb (q4) wr_ddrb (q4) rd_portb (q2) rd_ddrb (q2) rbif rbpu match signal from other port pins (porta<7>) peripheral data in
? 2000 microchip technology inc. ds30289b-page 75 pic17c7xx example 10-2 shows an instruction sequence to initial- ize portb. the bank select register (bsr) must be selected to bank 0 for the port to be initialized. the fol- lowing example uses the movlb instruction to load the bsr register for bank selection. example 10-2: initializing portb figure 10-6: block diagram of rb3:rb2 port pins movlb 0 ; select bank 0 clrf portb, f ; init portb by clearing ; output data latches movlw 0xcf ; value used to initialize ; data direction movwf ddrb ; set rb<3:0> as inputs ; rb<5:4> as outputs ; rb<7:6> as inputs note: i/o pins have protection diodes to v dd and v ss . data bus q d ck q d ck r weak pull-up port input latch port data oe peripheral_enable peripheral_output wr_portb (q4) wr_ddrb (q4) rd_portb (q2) rd_ddrb (q2) rbif rbpu match signal from other port pins (porta<7>) peripheral data in
pic17c7xx ds30289b-page 76 ? 2000 microchip technology inc. figure 10-7: block diagram of rb6 port pin figure 10-8: block diagram of rb7 port pin note: i/o pin has protection diodes to vdd and vss. data bus q d ck q d ck weak pull-up port data oe spi output enable spi output wr_portb (q4) wr_ddrb (q4) rd_portb (q2) rd_ddrb (q2) rbif rbpu match signal from other port pins (porta<7>) peripheral data in q d en p n q 0 1 note: i/o pin has protection diodes to v dd and v ss . data bus q d ck q d ck weak pull-up port data oe spi output enable spi output wr_portb (q4) wr_ddrb (q4) rd_portb (q2) rd_ddrb (q2) rbif rbpu match signal from other port pins (porta<7>) peripheral data in q d en p n q 0 1 ss output disable
? 2000 microchip technology inc. ds30289b-page 77 pic17c7xx table 10-3: portb functions table 10-4: registers/bits associated with portb name bit buffer type function rb0/cap1 bit0 st input/output or the capture1 input pin. software programmable weak pull-up and interrupt-on-change features. rb1/cap2 bit1 st input/output or the capture2 input pin. software programmable weak pull-up and interrupt-on-change features. rb2/pwm1 bit2 st input/output or the pwm1 output pin. software programmable weak pull-up and interrupt-on-change features. rb3/pwm2 bit3 st input/output or the pwm2 output pin. software programmable weak pull-up and interrupt-on-change features. rb4/tclk12 bit4 st input/output or the external clock input to timer1 and timer2. software programmable weak pull-up and interrupt-on-change features. rb5/tclk3 bit5 st input/output or the external clock input to timer3. software programmable weak pull-up and interrupt-on-change features. rb6/sck bit6 st input/output or the master/slave clock for the spi. software programmable weak pull-up and interrupt-on-change features. rb7/sdo bit7 st input/output or data output for the spi. software programmable weak pull-up and interrupt-on-change features. legend: st = schmitt trigger input address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 12h, bank 0 portb rb7/ sdo rb6/ sck rb5/ tclk3 rb4/ tclk12 rb3/ pwm2 rb2/ pwm1 rb1/ cap2 rb0/ cap1 xxxx xxxx uuuu uuuu 11h, bank 0 ddrb data direction register for portb 1111 1111 1111 1111 10h, bank 0 porta rbpu ? ra5/ tx1/ck1 ra4/ rx1/dt1 ra3/ sdi/sda ra2/ ss /scl ra1/t0cki ra0/int 0-xx 11xx 0-uu 11uu 06h, unbanked cpusta ? ? stkav glintd to pd por bor --11 11qq --11 qquu 07h, unbanked intsta peif t0ckif t0if intf peie t0ckie t0ie inte 0000 0000 0000 0000 16h, bank 1 pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h, bank 1 pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 16h, bank 3 tcon1 ca2ed1 ca2ed0 ca1ed1 ca1ed0 t16 tmr3cs tmr2cs tmr1cs 0000 0000 0000 0000 17h, bank 3 tcon2 ca2ovf ca1ovf pwm2on pwm1on ca1/pr3 tmr3on tmr2on tmr1on 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as ? 0 ? , q = value depends on condition. shaded cells are not used by portb.
pic17c7xx ds30289b-page 78 ? 2000 microchip technology inc. 10.3 portc and ddrc registers portc is an 8-bit bi-directional port. the correspond- ing data direction register is ddrc. a ? 1 ? in ddrc con- figures the corresponding port pin as an input. a ? 0 ? in the ddrc register configures the corresponding port pin as an output. reading portc reads the status of the pins, whereas writing to portc will write to the port latch. portc is multiplexed with the system bus. when operating as the system bus, portc is the low order byte of the address/data bus (ad7:ad0). the tim- ing for the system bus is shown in the electrical speci- fications section. example 10-3 shows an instruction sequence to initial- ize portc. the bank select register (bsr) must be selected to bank 1 for the port to be initialized. the fol- lowing example uses the movlb instruction to load the bsr register for bank selection. example 10-3: initializing portc figure 10-9: block diagram of rc7:rc0 port pins note: this port is configured as the system bus when the device ? s configuration bits are selected to microprocessor or extended microcontroller modes. in the two other microcontroller modes, this port is a general purpose i/o. movlb 1 ; select bank 1 clrf portc, f ; initialize portc data ; latches before setting ; the data direction reg movlw 0xcf ; value used to initialize ; data direction movwf ddrc ; set rc<3:0> as inputs ; rc<5:4> as outputs ; rc<7:6> as inputs note: i/o pins have protection diodes to v dd and v ss . q d ck ttl 0 1 q d ck r s input buffer port data to d _ b u s ir instruction read data bus rd_portc wr_portc rd_ddrc wr_ddrc ex_en data/addr_out drv_sys system bus control
? 2000 microchip technology inc. ds30289b-page 79 pic17c7xx table 10-5: portc functions table 10-6: registers/bits associated with portc name bit buffer type function rc0/ad0 bit0 ttl input/output or system bus address/data pin. rc1/ad1 bit1 ttl input/output or system bus address/data pin. rc2/ad2 bit2 ttl input/output or system bus address/data pin. rc3/ad3 bit3 ttl input/output or system bus address/data pin. rc4/ad4 bit4 ttl input/output or system bus address/data pin. rc5/ad5 bit5 ttl input/output or system bus address/data pin. rc6/ad6 bit6 ttl input/output or system bus address/data pin. rc7/ad7 bit7 ttl input/output or system bus address/data pin. legend: ttl = ttl input address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 11h, bank 1 portc rc7/ ad7 rc6/ ad6 rc5/ ad5 rc4/ ad4 rc3/ ad3 rc2/ ad2 rc1/ ad1 rc0/ ad0 xxxx xxxx uuuu uuuu 10h, bank 1 ddrc data direction register for portc 1111 1111 1111 1111 legend: x = unknown, u = unchanged
pic17c7xx ds30289b-page 80 ? 2000 microchip technology inc. 10.4 portd and ddrd registers portd is an 8-bit bi-directional port. the correspond- ing data direction register is ddrd. a ? 1 ? in ddrd con- figures the corresponding port pin as an input. a ? 0 ? in the ddrd register configures the corresponding port pin as an output. reading portd reads the status of the pins, whereas writing to portd will write to the port latch. portd is multiplexed with the system bus. when operating as the system bus, portd is the high order byte of the address/data bus (ad15:ad8). the timing for the system bus is shown in the electrical specifications section. example 10-4 shows an instruction sequence to initial- ize portd. the bank select register (bsr) must be selected to bank 1 for the port to be initialized. the fol- lowing example uses the movlb instruction to load the bsr register for bank selection. example 10-4: initializing portd figure 10-10: block diagram of rd7:rd0 port pins (in i/o port mode) note: this port is configured as the system bus when the device ? s configuration bits are selected to microprocessor or extended microcontroller modes. in the two other microcontroller modes, this port is a gen- eral purpose i/o. movlb 1 ; select bank 1 clrf portd, f ; initialize portd data ; latches before setting ; the data direction reg movlw 0xcf ; value used to initialize ; data direction movwf ddrd ; set rd<3:0> as inputs ; rd<5:4> as outputs ; rd<7:6> as inputs note: i/o pins have protection diodes to v dd and v ss . q d ck ttl 0 1 q d ck r s input buffer port data to d_ bu s ir instruction read data bus rd_portd wr_portd rd_ddrd wr_ddrd ex_en data/addr_out drv_sys system bus control
? 2000 microchip technology inc. ds30289b-page 81 pic17c7xx table 10-7: portd functions table 10-8: registers/bits associated with portd name bit buffer type function rd0/ad8 bit0 ttl input/output or system bus address/data pin. rd1/ad9 bit1 ttl input/output or system bus address/data pin. rd2/ad10 bit2 ttl input/output or system bus address/data pin. rd3/ad11 bit3 ttl input/output or system bus address/data pin. rd4/ad12 bit4 ttl input/output or system bus address/data pin. rd5/ad13 bit5 ttl input/output or system bus address/data pin. rd6/ad14 bit6 ttl input/output or system bus address/data pin. rd7/ad15 bit7 ttl input/output or system bus address/data pin. legend: ttl = ttl input address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 13h, bank 1 portd rd7/ ad15 rd6/ ad14 rd5/ ad13 rd4/ ad12 rd3/ ad11 rd2/ ad10 rd1/ ad9 rd0/ ad8 xxxx xxxx uuuu uuuu 12h, bank 1 ddrd data direction register for portd 1111 1111 1111 1111 legend: x = unknown, u = unchanged
pic17c7xx ds30289b-page 82 ? 2000 microchip technology inc. 10.5 porte and ddre register porte is a 4-bit bi-directional port. the corresponding data direction register is ddre. a ? 1 ? in ddre config- ures the corresponding port pin as an input. a ? 0 ? in the ddre register configures the corresponding port pin as an output. reading porte reads the status of the pins, whereas writing to porte will write to the port latch. porte is multiplexed with the system bus. when operating as the system bus, porte contains the control signals for the address/data bus (ad15:ad0). these control signals are address latch enable (ale), output enable (oe ) and write (wr ). the control signals oe and wr are active low signals. the timing for the system bus is shown in the electrical specifications section. example 10-5 shows an instruction sequence to initial- ize porte. the bank select register (bsr) must be selected to bank 1 for the port to be initialized. the fol- lowing example uses the movlb instruction to load the bsr register for bank selection. example 10-5: initializing porte figure 10-11: block diagram of re2:re0 (in i/o port mode) note: three pins of this port are configured as the system bus when the device ? s configu- ration bits are selected to microprocessor or extended microcontroller modes. the other pin is a general purpose i/o or capture4 pin. in the two other micro- controller modes, re2:re0 are general purpose i/o pins. movlb 1 ; select bank 1 clrf porte, f ; initialize porte data ; latches before setting ; the data direction ; register movlw 0x03 ; value used to initialize ; data direction movwf ddre ; set re<1:0> as inputs ; re<3:2> as outputs ; re<7:4> are always ; read as ?0? note: i/o pins have protection diodes to v dd and v ss . q d ck ttl 0 1 q d ck r s input buffer port data data bus rd_porte wr_porte rd_ddre wr_ddre ex_en cntl drv_sys system bus control
? 2000 microchip technology inc. ds30289b-page 83 pic17c7xx figure 10-12: block diagram of re3/cap4 port pin table 10-9: porte functions table 10-10: registers/bits associated with porte note: i/o pin has protection diodes to v dd and v ss . d ck q d ck q s port data data bus rd_porte wr_porte rd_ddre wr_ddre en q d en p n q q peripheral in v dd name bit buffer type function re0/ale bit0 ttl input/output or system bus address latch enable (ale ) control pin. re1/oe bit1 ttl input/output or system bus output enable (oe ) control pin. re2/wr bit2 ttl input/output or system bus write (wr ) control pin. re3/cap4 bit3 st input/output or capture4 input pin. legend: ttl = ttl input, st = schmitt trigger input address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 15h, bank 1 porte ? ? ? ? re3/cap4 re2/wr re1/oe re0/ale ---- xxxx ---- uuuu 14h, bank 1 ddre data direction register for porte ---- 1111 ---- 1111 14h, bank 7 ca4l capture4 low byte xxxx xxxx uuuu uuuu 15h, bank 7 ca4h capture4 high byte xxxx xxxx uuuu uuuu 16h, bank 7 tcon3 ?ca4ovf ca3ovf ca4ed1 ca4ed0 ca3ed1 ca3ed0 pwm3on -000 0000 -000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. shaded cells are not used by porte.
pic17c7xx ds30289b-page 84 ? 2000 microchip technology inc. 10.6 portf and ddrf registers portf is an 8-bit wide bi-directional port. the corre- sponding data direction register is ddrf. a ? 1 ? in ddrf configures the corresponding port pin as an input. a ? 0 ? in the ddrf register configures the corresponding port pin as an output. reading portf reads the status of the pins, whereas writing to portf will write to the respective port latch. all eight bits of portf are multiplexed with 8 channels of the 10-bit a/d converter. upon reset, the entire port is automatically config- ured as analog inputs and must be configured in soft- ware to be a digital i/o. example 10-6 shows an instruction sequence to initial- ize portf. the bank select register (bsr) must be selected to bank 5 for the port to be initialized. the fol- lowing example uses the movlb instruction to load the bsr register for bank selection. example 10-6: initializing portf figure 10-13: block diagram of rf7:rf0 movlb 5 ; select bank 5 movwf 0x0e ; configure portf as movwf adcon1 ; digital clrf portf, f ; initialize portf data ; latches before ; the data direction ; register movlw 0x03 ; value used to init ; data direction movwf ddrf ; set rf<1:0> as inputs ; rf<7:2> as outputs data bus wr portf wr ddrf rd portf data latch ddrf latch p v ss i/o pin pcfg3:pcfg0 q d q ck q d q ck en qd en n st input buffer v dd rd ddrf to other pads v ain chs3:chs0 to other pads note: i/o pins have protection diodes to v dd and v ss .
? 2000 microchip technology inc. ds30289b-page 85 pic17c7xx table 10-11: portf functions table 10-12: registers/bits associated with portf name bit buffer type function rf0/an4 bit0 st input/output or analog input 4. rf1/an5 bit1 st input/output or analog input 5. rf2/an6 bit2 st input/output or analog input 6. rf3/an7 bit3 st input/output or analog input 7. rf4/an8 bit4 st input/output or analog input 8. rf5/an9 bit5 st input/output or analog input 9. rf6/an10 bit6 st input/output or analog input 10. rf7/an11 bit7 st input/output or analog input 11. legend: st = schmitt trigger input address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 10h, bank 5 ddrf data direction register for portf 1111 1111 1111 1111 11h, bank 5 portf rf7/ an11 rf6/ an10 rf5/ an9 rf4/ an8 rf3/ an7 rf2/ an6 rf1/ an5 rf0/ an4 0000 0000 0000 0000 15h, bank 5 adcon1 adcs1 adcs0 adfm ? pcfg3 pcfg2 pcfg1 pcfg0 000- 0000 000- 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. shaded cells are not used by portf.
pic17c7xx ds30289b-page 86 ? 2000 microchip technology inc. 10.7 portg and ddrg registers portg is an 8-bit wide, bi-directional port. the corre- sponding data direction register is ddrg. a ? 1 ? in ddrg configures the corresponding port pin as an input. a ? 0 ? in the ddrg register configures the corre- sponding port pin as an output. reading portg reads the status of the pins, whereas writing to portg will write to the port latch. the lower four bits of portg are multiplexed with four channels of the 10-bit a/d converter. the remaining bits of portg are multiplexed with peripheral output and inputs. rg4 is multiplexed with the cap3 input, rg5 is multiplexed with the pwm3 output, rg6 and rg7 are multiplexed with the usart2 functions. upon reset, rg3:rg0 is automatically configured as analog inputs and must be configured in software to be a digital i/o. example 10-7 shows the instruction sequence to initial- ize portg. the bank select register (bsr) must be selected to bank 5 for the port to be initialized. the fol- lowing example uses the movlb instruction to load the bsr register for bank selection. example 10-7: initializing portg figure 10-14: block diagram of rg3:rg0 movlb 5 ; select bank 5 movlw 0x0e ; configure portg as movpf wreg, adcon1 ; digital clrf portg, f ; initialize portg data ; latches before ; the data direction ; register movlw 0x03 ; value used to init ; data direction movwf ddrg ; set rg<1:0> as inputs ; rg<7:2> as outputs data bus wr portg wr ddrg rd portg data latch ddrg latch p v ss i/o pin pcfg3:pcfg0 q d q ck q d q ck en qd en n st input buffer v dd rd ddrg to other pads v ain chs3:chs0 to other pads note: i/o pins have protection diodes to v dd and v ss .
? 2000 microchip technology inc. ds30289b-page 87 pic17c7xx figure 10-15: rg4 block diagram figure 10-16: rg7:rg5 block diagram note: i/o pins have protection diodes to v dd and v ss . d ck q d ck q data bus rd_portg wr_portg rd_ddrg wr_ddrg en q d en p n q peripheral data in v dd note: i/o pins have protection diodes to v dd and v ss . q d ck 1 0 q d ck r port data data bus rd_portg wr_portg rd_ddrg wr_ddrg n q d en p n q q output output enable peripheral data in v dd
pic17c7xx ds30289b-page 88 ? 2000 microchip technology inc. table 10-13: portg functions table 10-14: registers/bits associated with portg name bit buffer type function rg0/an3 bit0 st input/output or analog input 3. rg1/an2 bit1 st input/output or analog input 2. rg2/an1/v ref - bit2 st input/output or analog input 1 or the ground reference voltage. rg3/an0/v ref + bit3 st input/output or analog input 0 or the positive reference voltage. rg4/cap3 bit4 st input/output or the capture3 input pin. rg5/pwm3 bit5 st input/output or the pwm3 output pin. rg6/rx2/dt2 bit6 st input/output or the usart2 (sci) asynchronous receive or usart2 (sci) synchronous data. rg7/tx2/ck2 bit7 st input/output or the usart2 (sci) asynchronous transmit or usart2 (sci) synchronous clock. legend: st = schmitt trigger input address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 12h, bank 5 ddrg data direction register for portg 1111 1111 1111 1111 13h, bank 5 portg rg7/ tx2/ck2 rg6/ rx2/dt2 rg5/ pwm3 rg4/ cap3 rg3/ an0 rg2/ an1 rg1/ an2 rg0/ an3 xxxx 0000 uuuu 0000 15h, bank 5 adcon1 adcs1 adcs0 adfm ? pcfg3 pcfg2 pcfg1 pcfg0 000- 0000 000- 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. shaded cells are not used by portg.
? 2000 microchip technology inc. ds30289b-page 89 pic17c7xx 10.8 porth and ddrh registers (pic17c76x only) porth is an 8-bit wide, bi-directional port. the corre- sponding data direction register is ddrh. a ? 1 ? in ddrh configures the corresponding port pin as an input. a ? 0 ? in the ddrh register configures the corre- sponding port pin as an output. reading porth reads the status of the pins, whereas writing to porth will write to the respective port latch. the upper four bits of porth are multiplexed with 4 channels of the 10-bit a/d converter. the remaining bits of porth are general purpose i/o. upon reset, rh7:rh4 are automatically configured as analog inputs and must be configured in software to be a digital i/o. example 10-8: initializing porth figure 10-17: block diagram of rh7:rh4 movlb 8 ; select bank 8 movlw 0x0e ; configure porth as movpf adcon1 ; digital clrf porth, f ; initialize porth data ; latches before ; the data direction ; register movlw 0x03 ; value used to init ; data direction movwf ddrh ; set rh<1:0> as inputs ; rh<7:2> as outputs data bus wr porth wr ddrh rd port data latch ddrh latch p v ss i/o pin pcfg3:pcfg0 to other pads q d q ck en qd en n st input buffer v dd rd ddrh to other pads v ain chs3:chs0 q d q ck note: i/o pins have protection diodes to v dd and v ss .
pic17c7xx ds30289b-page 90 ? 2000 microchip technology inc. figure 10-18: rh3:rh0 block diagram table 10-15: porth functions table 10-16: registers/bits associated with porth note: i/o pins have protection diodes to v dd and v ss . d ck q d ck q data bus rd_porth wr_porth rd_ddrh wr_ddrh en q d en p n q v dd name bit buffer type function rh0 bit0 st input/output. rh1 bit1 st input/output. rh2 bit2 st input/output. rh3 bit3 st input/output. rh4/an12 bit4 st input/output or analog input 12. rh5/an13 bit5 st input/output or analog input 13. rh6/an14 bit6 st input/output or analog input 14. rh7/an15 bit7 st input/output or analog input 15. legend: st = schmitt trigger input address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 10h, bank 8 ddrh data direction register for porth 1111 1111 1111 1111 11h, bank 8 porth rh7/ an15 rh6/ an14 rh5/ an13 rh4/ an12 rh3 rh2 rh1 rh0 0000 xxxx 0000 uuuu 15h, bank 5 adcon1 adcs1 adcs0 adfm ? pcfg3 pcfg2 pcfg1 pcfg0 000- 0000 000- 0000 legend: x = unknown, u = unchanged
? 2000 microchip technology inc. ds30289b-page 91 pic17c7xx 10.9 portj and ddrj registers (pic17c76x only) portj is an 8-bit wide, bi-directional port. the corre- sponding data direction register is ddrj. a ? 1 ? in ddrj configures the corresponding port pin as an input. a ? 0 ? in the ddrj register configures the corresponding port pin as an output. reading portj reads the status of the pins, whereas writing to portj will write to the respective port latch. portj is a general purpose i/o port. example 10-9: initializing portj figure 10-19: portj block diagram movlb 8 ; select bank 8 clrf portj, f ; initialize portj data ; latches before setting ; the data direction ; register movlw 0xcf ; value used to initialize ; data direction movwf ddrj ; set rj<3:0> as inputs ; rj<5:4> as outputs ; rj<7:6> as inputs note: i/o pins have protection diodes to v dd and v ss . d ck q d ck q data bus rd_portj wr_portj rd_ddrj wr_ddrj en q d en p n q v dd
pic17c7xx ds30289b-page 92 ? 2000 microchip technology inc. table 10-17: portj functions table 10-18: registers/bits associated with portj name bit buffer type function rj0 bit0 st input/output rj1 bit1 st input/output rj2 bit2 st input/output rj3 bit3 st input/output rj4 bit4 st input/output rj5 bit5 st input/output rj6 bit6 st input/output rj7 bit7 st input/output legend: st = schmitt trigger input address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on, por, bor mclr , wdt 12h, bank 8 ddrj data direction register for portj 1111 1111 1111 1111 13h, bank 8 portj rj7 rj6 rj5 rj4 rj3 rj2 rj1 rj0 xxxx xxxx uuuu uuuu legend: x = unknown, u = unchanged
? 2000 microchip technology inc. ds30289b-page 93 pic17c7xx 10.10 i/o programming considerations 10.10.1 bi-directional i/o ports any instruction which writes, operates internally as a read, followed by a write operation. for example, the bcf and bsf instructions read the register into the cpu, execute the bit operation and write the result back to the register. caution must be used when these instructions are applied to a port with both inputs and outputs defined. for example, a bsf operation on bit5 of portb, will cause all eight bits of portb to be read into the cpu. then the bsf operation takes place on bit5 and portb is written to the output latches. if another bit of portb is used as a bi-directional i/o pin (e.g. bit0) and it is defined as an input at this time, the input signal present on the pin itself would be read into the cpu and rewritten to the data latch of this particular pin, overwriting the previous content. as long as the pin stays in the input mode, no problem occurs. however, if bit0 is switched into output mode later on, the content of the data latch may now be unknown. reading a port reads the values of the port pins. writing to the port register writes the value to the port latch. when using read-modify-write instructions ( bcf, bsf , btg , etc.) on a port, the value of the port pins is read, the desired operation is performed with this value and the value is then written to the port latch. example 10-10 shows the possible effect of two sequential read-modify-write instructions on an i/o port. example 10-10: read-modify-write instructions on an i/o port ; initial port settings: portb<7:4> inputs ; portb<3:0> outputs ; portb<7:6> have pull-ups and are ; not connected to other circuitry ; ; port latch port pins ; ---------- --------- ; bcf portb, 7 ; 01pp pppp 11pp pppp bcf portb, 6 ; 10pp pppp 11pp pppp bcf ddrb, 7 ; 10pp pppp 11pp pppp bcf ddrb, 6 ; 10pp pppp 10pp pppp ; ; note that the user may have expected the ; pin values to be 00pp pppp. the 2nd bcf ; caused rb7 to be latched as the pin value ; (high). note: a pin actively outputting a low or high should not be driven from external devices, in order to change the level on this pin (i.e., ? wired-or ? , ? wired-and ? ). the resulting high output currents may damage the device.
pic17c7xx ds30289b-page 94 ? 2000 microchip technology inc. 10.10.2 successive operations on i/o ports the actual write to an i/o port happens at the end of an instruction cycle, whereas for reading, the data must be valid at the beginning of the instruction cycle (figure 10-20). therefore, care must be exercised if a write followed by a read operation is carried out on the same i/o port. the sequence of instructions should be such to allow the pin voltage to stabilize (load depen- dent) before executing the instruction that reads the values on that i/o port. otherwise, the previous state of that pin may be read into the cpu, rather than the ? new ? state. when in doubt, it is better to separate these instructions with a nop, or another instruction not accessing this i/o port. figure 10-21 shows the i/o model which causes this situation. as the effective capacitance (c) becomes larger, the rise/fall time of the i/o pin increases. as the device frequency increases, or the effective capaci- tance increases, the possibility of this subsequent portx read-modify-write instruction issue increases. this effective capacitance includes the effects of the board traces. the best way to address this is to add a series resistor at the i/o pin. this resistor allows the i/o pin to get to the desired level before the next instruction. the use of nop instructions between the subsequent portx read-modify-write instructions, is a lower cost solution, but has the issue that the number of nop instructions is dependent on the effective capacitance c and the frequency of the device. figure 10-20: successive i/o operation figure 10-21: i/o connection issues pc pc + 1 pc + 2 pc + 3 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 instruction fetched rb7:rb0 movwf portb write to portb nop port pin sampled here nop movf portb,w instruction executed movwf portb write to portb nop movf portb,w note: this example shows a write to portb, followed by a read from portb. note that: data setup time = (0.25t cy - t pd ) where t cy = instruction cycle t pd = propagation delay therefore, at higher clock frequencies, a write followed by a read may be problematic. pic17cxxx i/o c (1) q4 q1 q2 q3 q4 q1 v il bsf portx, piny q2 q3 bsf portx, pinz portx, piny read portx, piny as low bsf portx, pinz clears the value to be driven on the portx, piny pin. note 1: this is not a capacitor to ground, but the effective capacitive loading on the trace.
? 2000 microchip technology inc. ds30289b-page 95 pic17c7xx 11.0 overview of timer resources the pic17c7xx has four timer modules. each module can generate an interrupt to indicate that an event has occurred. these timers are called:  timer0 - 16-bit timer with programmable 8-bit prescaler  timer1 - 8-bit timer  timer2 - 8-bit timer  timer3 - 16-bit timer for enhanced time base functionality, four input cap- tures and three pulse width modulation (pwm) outputs are possible. the pwms use the timer1 and timer2 resources and the input captures use the timer3 resource. 11.1 timer0 overview the timer0 module is a simple 16-bit overflow counter. the clock source can be either the internal system clock (fosc/4) or an external clock. when timer0 uses an external clock source, it has the flexibility to allow user selection of the incrementing edge, rising or falling. the timer0 module also has a programmable pres- caler. the t0ps3:t0ps0 bits (t0sta<4:1>) determine the prescale value. tmr0 can increment at the follow- ing rates: 1:1, 1:2, 1:4, 1:8, 1:16, 1:32, 1:64, 1:128, 1:256. synchronization of the external clock occurs after the prescaler. when the prescaler is used, the external clock frequency may be higher than the device ? s fre- quency. the maximum external frequency on the t0cki pin is 50 mhz, given the high and low time requirements of the clock. 11.2 timer1 overview the timer1 module is an 8-bit timer/counter with an 8- bit period register (pr1). when the tmr1 value rolls over from the period match value to 0h, the tmr1if flag is set and an interrupt will be generated if enabled. in counter mode, the clock comes from the rb4/ tclk12 pin, which can also be selected to be the clock for the timer2 module. tmr1 can be concatenated with tmr2 to form a 16-bit timer. the tmr1 register is the lsb and tmr2 is the msb. when in the 16-bit timer mode, there is a corre- sponding 16-bit period register (pr2:pr1). when the tmr2:tmr1 value rolls over from the period match value to 0h, the tmr1if flag is set and an interrupt will be generated, if enabled. 11.3 timer2 overview the timer2 module is an 8-bit timer/counter with an 8- bit period register (pr2). when the tmr2 value rolls over from the period match value to 0h, the tmr2if flag is set and an interrupt will be generated, if enabled. in counter mode, the clock comes from the rb4/ tclk12 pin, which can also provide the clock for the timer1 module. tmr2 can be concatenated with tmr1 to form a 16-bit timer. the tmr2 register is the msb and tmr1 is the lsb. when in the 16-bit timer mode, there is a corre- sponding 16-bit period register (pr2:pr1). when the tmr2:tmr1 value rolls over from the period match value to 0h, the tmr1if flag is set and an interrupt will be generated, if enabled. 11.4 timer3 overview the timer3 module is a 16-bit timer/counter with a 16- bit period register. when the tmr3h:tmr3l value rolls over to 0h, the tmr3if bit is set and an interrupt will be generated, if enabled. in counter mode, the clock comes from the rb5/tclk3 pin. when operating in the four capture modes, the period registers become the second (of four) 16-bit capture registers. 11.5 role of the timer/counters the timer modules are general purpose, but have ded- icated resources associated with them. timer1 and timer2 are the time bases for the three pulse width modulation (pwm) outputs, while timer3 is the time base for the four input captures.
pic17c7xx ds30289b-page 96 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 97 pic17c7xx 12.0 timer0 the timer0 module consists of a 16-bit timer/counter, tmr0. the high byte is register tmr0h and the low byte is register tmr0l. a software programmable 8-bit prescaler makes timer0 an effective 24-bit overflow timer. the clock source is software programmable as either the internal instruction clock, or an external clock on the ra1/t0cki pin. the control bits for this module are in register t0sta (figure 12-1). register 12-1: t0sta register (address: 05h, unbanked) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 intedg t0se t0cs t0ps3 t0ps2 t0ps1 t0ps0 ? bit 7 bit 0 bit 7 intedg : ra0/int pin interrupt edge select bit this bit selects the edge upon which the interrupt is detected. 1 = rising edge of ra0/int pin generates interrupt 0 = falling edge of ra0/int pin generates interrupt bit 6 t0se : timer0 clock input edge select bit this bit selects the edge upon which tmr0 will increment. when t0cs = 0 (external clock): 1 = rising edge of ra1/t0cki pin increments tmr0 and/or sets the t0ckif bit 0 = falling edge of ra1/t0cki pin increments tmr0 and/or sets the t0ckif bit when t0cs = 1 (internal clock): don ? t care bit 5 t0cs : timer0 clock source select bit this bit selects the clock source for tmr0. 1 = internal instruction clock cycle (t cy ) 0 = external clock input on the t0cki pin bit 4-1 t0ps3:t0ps0 : timer0 prescale selection bits these bits select the prescale value for tmr0. bit 0 unimplemented : read as ? 0 ? legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown t0ps3:t0ps0 prescale value 0000 0001 0010 0011 0100 0101 0110 0111 1xxx 1:1 1:2 1:4 1:8 1:16 1:32 1:64 1:128 1:256
pic17c7xx ds30289b-page 98 ? 2000 microchip technology inc. 12.1 timer0 operation when the t0cs (t0sta<5>) bit is set, tmr0 incre- ments on the internal clock. when t0cs is clear, tmr0 increments on the external clock (ra1/t0cki pin). the external clock edge can be selected in software. when the t0se (t0sta<6>) bit is set, the timer will increment on the rising edge of the ra1/t0cki pin. when t0se is clear, the timer will increment on the falling edge of the ra1/t0cki pin. the prescaler can be programmed to introduce a prescale of 1:1 to 1:256. the timer incre- ments from 0000h to ffffh and rolls over to 0000h. on overflow, the tmr0 interrupt flag bit (t0if) is set. the tmr0 interrupt can be masked by clearing the cor- responding tmr0 interrupt enable bit (t0ie). the tmr0 interrupt flag bit (t0if) is automatically cleared when vectoring to the tmr0 interrupt vector. 12.2 using timer0 with external clock when an external clock input is used for timer0, it is synchronized with the internal phase clocks. figure 12- 2 shows the synchronization of the external clock. this synchronization is done after the prescaler. the output of the prescaler (psout) is sampled twice in every instruction cycle to detect a rising or a falling edge. the timing requirements for the external clock are detailed in the electrical specification section. 12.2.1 delay from external clock edge since the prescaler output is synchronized with the internal clocks, there is a small delay from the time the external clock edge occurs to the time tmr0 is actually incremented. figure 12-2 shows that this delay is between 3t osc and 7t osc . thus, for example, mea- suring the interval between two edges (e.g. period) will be accurate within 4t osc ( 121 ns @ 33 mhz). figure 12-1: timer0 module block diagram figure 12-2: tmr0 timing with external clock (increment on falling edge) ra1/t0cki synchronization prescaler (8 stage async ripple counter) t0se (t0sta<6>) f osc /4 t0cs (t0sta<5>) t0ps3:t0ps0 (t0sta<4:1>) q2 q4 0 1 tmr0h<8> tmr0l<8> interrupt-on-overflow sets t0if (intsta<5>) 4 psout q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 prescaler output (psout) sampled prescaler output increment tmr0 tmr0 t0 t0 + 1 t0 + 2 (note 3) (note 2) note 1: the delay from the t0cki edge to the tmr0 increment is 3tosc to 7tosc. 2: = psout is sampled here. 3: the psout high time is too short and is missed by the sampling circuit. (note 1)
? 2000 microchip technology inc. ds30289b-page 99 pic17c7xx 12.3 read/write consideration for tmr0 although tmr0 is a 16-bit timer/counter, only 8-bits at a time can be read or written during a single instruction cycle. care must be taken during any read or write. 12.3.1 reading 16-bit value the problem in reading the entire 16-bit value is that after reading the low (or high) byte, its value may change from ffh to 00h. example 12-1 shows a 16-bit read. to ensure a proper read, interrupts must be disabled during this routine. example 12-1: 16-bit read 12.3.2 writing a 16-bit value to tmr0 since writing to either tmr0l or tmr0h will effectively inhibit increment of that half of the tmr0 in the next cycle (following write), but not inhibit increment of the other half, the user must write to tmr0l first and tmr0h second, in two consecutive instructions, as shown in example 12-2. the interrupt must be dis- abled. any write to either tmr0l or tmr0h clears the prescaler. example 12-2: 16-bit write 12.4 prescaler assignments timer0 has an 8-bit prescaler. the prescaler selection is fully under software control; i.e., it can be changed ? on the fly ? during program execution. clearing the prescaler is recommended before changing its setting. the value of the prescaler is ? unknown ? and assigning a value that is less than the present value, makes it dif- ficult to take this unknown time into account. figure 12-3: tmr0 timing: write high or low byte movpf tmr0l, tmplo ;read low tmr0 movpf tmr0h, tmphi ;read high tmr0 movfp tmplo, wreg ;tmplo ?> wreg cpfslt tmr0l ;tmr0l < wreg? return ;no then return movpf tmr0l, tmplo ;read low tmr0 movpf tmr0h, tmphi ;read high tmr0 return ;return bsf cpusta, glintd ; disable interrupts movfp ram_l, tmr0l ; movfp ram_h, tmr0h ; bcf cpusta, glintd ; done, enable ; interrupts q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 ad15:ad0 ale tmr0l tmr0h movfp w,tmr0l write to tmr0l movfp tmr0l,w read tmr0l (value = nt0) movfp tmr0l,w read tmr0l (value = nt0) movfp tmr0l,w read tmr0l (value = nt0 +1) t0 t0+1 new t0 (nt0) new t0+1 pc pc+1 pc+2 pc+3 pc+4 fetch instruction executed
pic17c7xx ds30289b-page 100 ? 2000 microchip technology inc. figure 12-4: tmr0 read/write in timer mode table 12-1: registers/bits associated with timer0 instruction executed movfp datal,tmr0l write tmr0l movfp datah,tmr0h write tmr0h movpf tmr0l,w read tmr0l movpf tmr0l,w read tmr0l movpf tmr0l,w read tmr0l q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 ad15:ad0 ale wr_trm0l wr_tmr0h rd_tmr0l tmr0h tmr0l 12 12 13 ab fe ff 56 57 58 note: in this example, old tmr0 value is 12feh, new value of ab56h is written. instruction fetched movfp datal,tmr0l write tmr0l movfp datah,tmr0h write tmr0h movpf tmr0l,w read tmr0l movpf tmr0l,w read tmr0l movpf tmr0l,w read tmr0l movpf tmr0l,w read tmr0l previously fetched instruction address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 05h, unbanked t0sta intedg t0se t0cs t0ps3 t0ps2 t0ps1 t0ps0 ? 0000 000- 0000 000- 06h, unbanked cpusta ? ? stkav glintd to pd por bor --11 11qq --11 qquu 07h, unbanked intsta peif t0ckif t0if intf peie t0ckie t0ie inte 0000 0000 0000 0000 0bh, unbanked tmr0l tmr0 register; low byte xxxx xxxx uuuu uuuu 0ch, unbanked tmr0h tmr0 register; high byte xxxx xxxx uuuu uuuu legend: x = unknown, u = unchanged, - = unimplemented, read as a '0', q = value depends on condition. shaded cells are not used by timer0.
? 2000 microchip technology inc. ds30289b-page 101 pic17c7xx 13.0 timer1, timer2, timer3, pwms and captures the pic17c7xx has a wealth of timers and time based functions to ease the implementation of control applica- tions. these time base functions include three pwm outputs and four capture inputs. timer1 and timer2 are two 8-bit incrementing timers, each with an 8-bit period register (pr1 and pr2, respec- tively) and separate overflow interrupt flags. timer1 and timer2 can operate either as timers (increment on inter- nal f osc /4 clock), or as counters (increment on falling edge of external clock on pin rb4/tclk12). they are also software configurable to operate as a single 16-bit timer/counter. these timers are also used as the time base for the pwm (pulse width modulation) modules. timer3 is a 16-bit timer/counter which uses the tmr3h and tmr3l registers. timer3 also has two additional registers (pr3h/ca1h:pr3l/ca1l) that are config- urable as a 16-bit period register or a 16-bit capture register. tmr3 can be software configured to incre- ment from the internal system clock (f osc /4), or from an external signal on the rb5/tclk3 pin. timer3 is the time base for all of the 16-bit captures. six other registers comprise the capture2, capture3, and capture4 registers (ca2h:ca2l, ca3h:ca3l, and ca4h:ca4l). figure 13-1, figure 13-2 and figure 13-3 are the con- trol registers for the operation of timer1, timer2 and timer3, as well as pwm1, pwm2, pwm3, capture1, capture2, capture3 and capture4. table 13-1 shows the timer resource requirements for these time base functions. each timer is an open resource so that multiple functions may operate with it. table 13-1: time-base function/ resource requirements register 13-1: tcon1 register (address: 16h, bank 3) time base function timer resource pwm1 timer1 pwm2 timer1 or timer2 pwm3 timer1 or timer2 capture1 timer3 capture2 timer3 capture3 timer3 capture4 timer3 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ca2ed1 ca2ed0 ca1ed1 ca1ed0 t16 tmr3cs tmr2cs tmr1cs bit 7 bit 0 bit 7-6 ca2ed1:ca2ed0 : capture2 mode select bits 00 = capture on every falling edge 01 = capture on every rising edge 10 = capture on every 4th rising edge 11 = capture on every 16th rising edge bit 5-4 ca1ed1:ca1ed0 : capture1 mode select bits 00 = capture on every falling edge 01 = capture on every rising edge 10 = capture on every 4th rising edge 11 = capture on every 16th rising edge bit 3 t16 : timer2:timer1 mode select bit 1 = timer2 and timer1 form a 16-bit timer 0 = timer2 and timer1 are two 8-bit timers bit 2 tmr3cs : timer3 clock source select bit 1 = tmr3 increments off the falling edge of the rb5/tclk3 pin 0 = tmr3 increments off the internal clock bit 1 tmr2cs : timer2 clock source select bit 1 = tmr2 increments off the falling edge of the rb4/tclk12 pin 0 = tmr2 increments off the internal clock bit 0 tmr1cs : timer1 clock source select bit 1 = tmr1 increments off the falling edge of the rb4/tclk12 pin 0 = tmr1 increments off the internal clock legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
pic17c7xx ds30289b-page 102 ? 2000 microchip technology inc. register 13-2: tcon2 register (address: 17h, bank 3) r-0 r-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ca2ovf ca1ovf pwm2on pwm1on ca1/pr3 tmr3on tmr2on tmr1on bit 7 bit 0 bit 7 ca2ovf : capture2 overflow status bit this bit indicates that the capture value had not been read from the capture register pair (ca2h:ca2l) before the next capture event occurred. the capture register retains the oldest unread capture value (last capture before overflow). subsequent capture events will not update the capture register with the tmr3 value until the capture register has been read (both bytes). 1 = overflow occurred on capture2 register 0 = no overflow occurred on capture2 register bit 6 ca1ovf : capture1 overflow status bit this bit indicates that the capture value had not been read from the capture register pair (pr3h/ ca1h:pr3l/ca1l), before the next capture event occurred. the capture register retains the old- est unread capture value (last capture before overflow). subsequent capture events will not update the capture register with the tmr3 value until the capture register has been read (both bytes). 1 = overflow occurred on capture1 register 0 = no overflow occurred on capture1 register bit 5 pwm2on : pwm2 on bit 1 = pwm2 is enabled (the rb3/pwm2 pin ignores the state of the ddrb<3> bit.) 0 = pwm2 is disabled (the rb3/pwm2 pin uses the state of the ddrb<3> bit for data direction.) bit 4 pwm1on : pwm1 on bit 1 = pwm1 is enabled (the rb2/pwm1 pin ignores the state of the ddrb<2> bit.) 0 = pwm1 is disabled (the rb2/pwm1 pin uses the state of the ddrb<2> bit for data direction.) bit 3 ca1/pr3 : ca1/pr3 register mode select bit 1 = enables capture1 (pr3h/ca1h:pr3l/ca1l is the capture1 register. timer3 runs without a period register.) 0 = enables the period register (pr3h/ca1h:pr3l/ca1l is the period register for timer3.) bit 2 tmr3on : timer3 on bit 1 = starts timer3 0 = stops timer3 bit 1 tmr2on : timer2 on bit this bit controls the incrementing of the tmr2 register. when tmr2:tmr1 form the 16-bit timer (t16 is set), tmr2on must be set. this allows the msb of the timer to increment. 1 = starts timer2 (must be enabled if the t16 bit (tcon1<3>) is set) 0 = stops timer2 bit 0 tmr1on : timer1 on bit when t16 is set (in 16-bit timer mode): 1 = starts 16-bit tmr2:tmr1 0 = stops 16-bit tmr2:tmr1 when t16 is clear (in 8-bit timer mode: 1 = starts 8-bit timer1 0 = stops 8-bit timer1 legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
? 2000 microchip technology inc. ds30289b-page 103 pic17c7xx register 13-3: tcon3 register (address: 16h, bank 7) u-0 r-0 r-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ? ca4ovf ca3ovf ca4ed1 ca4ed0 ca3ed1 ca3ed0 pwm3on bit 7 bit 0 bit 7 unimplemented : read as ? 0 ? bit 6 ca4ovf : capture4 overflow status bit this bit indicates that the capture value had not been read from the capture register pair (ca4h:ca4l) before the next capture event occurred. the capture register retains the oldest unread capture value (last capture before overflow). subsequent capture events will not update the capture register with the tmr3 value until the capture register has been read (both bytes). 1 = overflow occurred on capture4 registers 0 = no overflow occurred on capture4 registers bit 5 ca3ovf : capture3 overflow status bit this bit indicates that the capture value had not been read from the capture register pair (ca3h:ca3l) before the next capture event occurred. the capture register retains the oldest unread capture value (last capture before overflow). subsequent capture events will not update the capture register with the tmr3 value until the capture register has been read (both bytes). 1 = overflow occurred on capture3 registers 0 = no overflow occurred on capture3 registers bit 4-3 ca4ed1:ca4ed0 : capture4 mode select bits 00 = capture on every falling edge 01 = capture on every rising edge 10 = capture on every 4th rising edge 11 = capture on every 16th rising edge bit 2-1 ca3ed1:ca3ed0 : capture3 mode select bits 00 = capture on every falling edge 01 = capture on every rising edge 10 = capture on every 4th rising edge 11 = capture on every 16th rising edge bit 0 pwm3on : pwm3 on bit 1 = pwm3 is enabled (the rg5/pwm3 pin ignores the state of the ddrg<5> bit) 0 = pwm3 is disabled (the rg5/pwm3 pin uses the state of the ddrg<5> bit for data direction) legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
pic17c7xx ds30289b-page 104 ? 2000 microchip technology inc. 13.1 timer1 and timer2 13.1.1 timer1, timer2 in 8-bit mode both timer1 and timer2 will operate in 8-bit mode when the t16 bit is clear. these two timers can be inde- pendently configured to increment from the internal instruction cycle clock (t cy ), or from an external clock source on the rb4/tclk12 pin. the timer clock source is configured by the tmrxcs bit (x = 1 for timer1, or = 2 for timer2). when tmrxcs is clear, the clock source is internal and increments once every instruc- tion cycle (f osc /4). when tmrxcs is set, the clock source is the rb4/tclk12 pin and the counters will increment on every falling edge of the rb4/tclk12 pin. the timer increments from 00h until it equals the period register (prx). it then resets to 00h at the next incre- ment cycle. the timer interrupt flag is set when the timer is reset. tmr1 and tmr2 have individual inter- rupt flag bits. the tmr1 interrupt flag bit is latched into tmr1if and the tmr2 interrupt flag bit is latched into tmr2if. each timer also has a corresponding interrupt enable bit (tmrxie). the timer interrupt can be enabled/ disabled by setting/clearing this bit. for peripheral interrupts to be enabled, the peripheral interrupt enable bit must be set (peie = ? 1 ? ) and global interrupt must be enabled (glintd = ? 0 ? ). the timers can be turned on and off under software control. when the timer on control bit (tmrxon) is set, the timer increments from the clock source. when tmrxon is cleared, the timer is turned off and cannot cause the timer interrupt flag to be set. 13.1.1.1 external clock input for timer1 and timer2 when tmrxcs is set, the clock source is the rb4/ tclk12 pin, and the counter will increment on every falling edge on the rb4/tclk12 pin. the tclk12 input is synchronized with internal phase clocks. this causes a delay from the time a falling edge appears on tclk12 to the time tmr1 or tmr2 is actually incre- mented. for the external clock input timing require- ments, see the electrical specification section. figure 13-1: timer1 and timer2 in two 8-bit timer/counter mode f osc /4 rb4/tclk12 tmr1on (tcon2<0>) tmr1cs (tcon1<0>) tmr1 pr1 reset equal set tmr1if (pir1<4>) 0 1 comparator<8> comparator x8 f osc /4 tmr2on (tcon2<1>) tmr2cs (tcon1<1>) tmr2 pr2 reset equal set tmr2if (pir1<5>) 1 0 comparator<8> comparator x8
? 2000 microchip technology inc. ds30289b-page 105 pic17c7xx 13.1.2 timer1 and timer2 in 16-bit mode to select 16-bit mode, set the t16 bit. in this mode, tmr2 and tmr1 are concatenated to form a 16-bit timer (tmr2:tmr1). the 16-bit timer increments until it matches the 16-bit period register (pr2:pr1). on the following timer clock, the timer value is reset to 0h, and the tmr1if bit is set. when selecting the clock source for the 16-bit timer, the tmr1cs bit controls the entire 16-bit timer and tmr2cs is a ? don ? t care ? , however, ensure that tmr2on is set (allows tmr2 to increment). when tmr1cs is clear, the timer increments once every instruction cycle (f osc /4). when tmr1cs is set, the timer increments on every falling edge of the rb4/ tclk12 pin. for the 16-bit timer to increment, both tmr1on and tmr2on bits must be set (table 13-2). table 13-2: turning on 16-bit timer 13.1.2.1 external clock input for tmr2:tmr1 when tmr1cs is set, the 16-bit tmr2:tmr1 incre- ments on the falling edge of clock input tclk12. the input on the rb4/tclk12 pin is sampled and synchro- nized by the internal phase clocks twice every instruc- tion cycle. this causes a delay from the time a falling edge appears on rb4/tclk12 to the time tmr2:tmr1 is actually incremented. for the external clock input timing requirements, see the electrical specification section. figure 13-2: tmr2 and tmr1 in 16-bit timer/counter mode t16 tmr2on tmr1on result 11 1 16-bit timer (tmr2:tmr1) on 10 1 only tmr1 increments 1x 0 16-bit timer off 01 1 timers in 8-bit mode rb4/tclk12 f osc /4 tmr1on (tcon2<0>) tmr1cs (tcon1<0>) tmr1 x 8 pr1 x 8 reset equal set interrupt tmr1if (pir1<4>) 1 0 comparator<8> comparator x16 tmr2 x 8 pr2 x 8 msb lsb
pic17c7xx ds30289b-page 106 ? 2000 microchip technology inc. table 13-3: summary of timer1, timer2 and timer3 registers address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 16h, bank 3 tcon1 ca2ed1 ca2ed0 ca1ed1 ca1ed0 t16 tmr3cs tmr2cs tmr1cs 0000 0000 0000 0000 17h, bank 3 tcon2 ca2ovf ca1ovf pwm2on pwm1on ca1/pr3 tmr3on tmr2on tmr1on 0000 0000 0000 0000 16h, bank 7 tcon3 ? ca4ovf ca3ovf ca4ed1 ca4ed0 ca3ed1 ca3ed0 pwm3on -000 0000 -000 0000 10h, bank 2 tmr1 timer1 ? s register xxxx xxxx uuuu uuuu 11h, bank 2 tmr2 timer2 ? s register xxxx xxxx uuuu uuuu 16h, bank 1 pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h, bank 1 pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 07h, unbanked intsta peif t0ckif t0if intf peie t0ckie t0ie inte 0000 0000 0000 0000 06h, unbanked cpusta ? ? stkav glintd to pd por bor --11 11qq --11 qquu 14h, bank 2 pr1 timer1 period register xxxx xxxx uuuu uuuu 15h, bank 2 pr2 timer2 period register xxxx xxxx uuuu uuuu 10h, bank 3 pw1dcl dc1 dc0 ? ? ? ? ? ? xx-- ---- uu-- ---- 11h, bank 3 pw2dcl dc1 dc0 tm2pw2 ? ? ? ? ? xx0- ---- uu0- ---- 10h, bank 7 pw3dcl dc1 dc0 tm2pw3 ? ? ? ? ? xx0- ---- uu0- ---- 12h, bank 3 pw1dch dc9 dc8 dc7 dc6 dc5 dc4 dc3 dc2 xxxx xxxx uuuu uuuu 13h, bank 3 pw2dch dc9 dc8 dc7 dc6 dc5 dc4 dc3 dc2 xxxx xxxx uuuu uuuu 11h, bank 7 pw3dch dc9 dc8 dc7 dc6 dc5 dc4 dc3 dc2 xxxx xxxx uuuu uuuu legend: x = unknown, u = unchanged, - = unimplemented, read as a '0', q = value depends on condition. shaded cells are not used by timer1 or timer2.
? 2000 microchip technology inc. ds30289b-page 107 pic17c7xx 13.1.3 using pulse width modulation (pwm) outputs with timer1 and timer2 three high speed pulse width modulation (pwm) out- puts are provided. the pwm1 output uses timer1 as its time base, while pwm2 and pwm3 may indepen- dently be software configured to use either timer1 or timer2 as the time base. the pwm outputs are on the rb2/pwm1, rb3/pwm2 and rg5/pwm3 pins. each pwm output has a maximum resolution of 10- bits. at 10-bit resolution, the pwm output frequency is 32.2 khz (@ 32 mhz clock) and at 8-bit resolution the pwm output frequency is 128.9 khz. the duty cycle of the output can vary from 0% to 100%. figure 13-3 shows a simplified block diagram of a pwm module. the duty cycle registers are double buffered for glitch free operation. figure 13-4 shows how a glitch could occur if the duty cycle registers were not double buffered. the user needs to set the pwm1on bit (tcon2<4>) to enable the pwm1 output. when the pwm1on bit is set, the rb2/pwm1 pin is configured as pwm1 output and forced as an output, irrespective of the data direc- tion bit (ddrb<2>). when the pwm1on bit is clear, the pin behaves as a port pin and its direction is con- trolled by its data direction bit (ddrb<2>). similarly, the pwm2on (tcon2<5>) bit controls the configura- tion of the rb3/pwm2 pin and the pwm3on (tcon3<0>) bit controls the configuration of the rg5/ pwm3 pin. figure 13-3: simplified pwm block diagram figure 13-4: pwm output (not buffered) pwxdch duty cycle registers pwxdcl<7:6> clear timer, pwmx pin and latch d.c. (slave) comparator tmrx comparator pry (note 1) r s q pwmxon pwmx note 1: 8-bit timer is concatenated with 2-bit internal q clock or 2 bits of the prescaler to create read write 10-bit time base. 0 10203040 0 pwm output timer interrupt write new pwm duty cycle value timer interrupt new pwm duty cycle value transferred to slave the dotted line shows pwm output if duty cycle registers were not double buffered. if the new duty cycle is written after the timer has passed that value, then the pwm does not reset at all during the current cycle, causing a ? glitch ? . in this example, pwm period = 50. old duty cycle is 30. new duty cycle value is 10. 10 20 30 40 0 note:
pic17c7xx ds30289b-page 108 ? 2000 microchip technology inc. 13.1.3.1 pwm periods the period of the pwm1 output is determined by timer1 and its period register (pr1). the period of the pwm2 and pwm3 outputs can be individually software configured to use either timer1 or timer2 as the time- base. for pwm2, when tm2pw2 bit (pw2dcl<5>) is clear, the time base is determined by tmr1 and pr1 and when tm2pw2 is set, the time base is determined by timer2 and pr2. for pwm3, when tm2pw3 bit (pw3dcl<5>) is clear, the time base is determined by tmr1 and pr1, and when tm2pw3 is set, the time base is determined by timer2 and pr2. running two different pwm outputs on two different timers allows different pwm periods. running all pwms from timer1 allows the best use of resources by freeing timer2 to operate as an 8-bit timer. timer1 and timer2 cannot be used as a 16-bit timer if any pwm is being used. the pwm periods can be calculated as follows: period of pwm1 = [(pr1) + 1] x 4t osc period of pwm2 = [(pr1) + 1] x 4t osc or [(pr2) + 1] x 4t osc period of pwm3 = [(pr1) + 1] x 4t osc or [(pr2) + 1] x 4t osc the duty cycle of pwmx is determined by the 10-bit value dcx<9:0>. the upper 8-bits are from register pwxdch and the lower 2-bits are from pwxdcl<7:6> (pwxdch:pwxdcl<7:6>). table 13-4 shows the maximum pwm frequency (f pwm ), given the value in the period register. the number of bits of resolution that the pwm can achieve depends on the operation frequency of the device as well as the pwm frequency (f pwm ). maximum pwm resolution (bits) for a given pwm frequency: where: f pwm = 1 / period of pwm the pwmx duty cycle is as follows: pwmx duty cycle = (dcx) x t osc where dcx represents the 10-bit value from pwxdch:pwxdcl. if dcx = 0, then the duty cycle is zero. if prx = pwxdch, then the pwm output will be low for one to four q-clocks (depending on the state of the pwxdcl<7:6> bits). for a duty cycle to be 100%, the pwxdch value must be greater then the prx value. the duty cycle registers for both pwm outputs are dou- ble buffered. when the user writes to these registers, they are stored in master latches. when tmr1 (or tmr2) overflows and a new pwm period begins, the master latch values are transferred to the slave latches and the pwmx pin is forced high. the user should also avoid any "read-modify-write" operations on the duty cycle registers, such as: addwf pw1dch . this may cause duty cycle outputs that are unpredictable. table 13-4: pwm frequency vs. resolution at 33 mhz 13.1.3.2 pwm interrupts the pwm modules make use of the tmr1 and/or tmr2 interrupts. a timer interrupt is generated when tmr1 or tmr2 equals its period register and on the following increment is cleared to zero. this interrupt also marks the beginning of a pwm cycle. the user can write new duty cycle values before the timer rollover. the tmr1 interrupt is latched into the tmr1if bit and the tmr2 interrupt is latched into the tmr2if bit. these flags must be cleared in software. log ( f pwm log (2) f osc ) bits = note: for pw1dch, pw1dcl, pw2dch, pw2dcl, pw3dch and pw3dcl regis- ters, a write operation writes to the "master latches", while a read operation reads the "slave latches". as a result, the user may not read back what was just written to the duty cycle registers (until transferred to slave latch). pwm frequency frequency (khz) 32.2 64.5 90.66 128.9 515.6 prx value 0xff 0x7f 0x5a 0x3f 0x0f high resolution 10-bit 9-bit 8.5-bit 8-bit 6-bit standard resolution 8-bit 7-bit 6.5-bit 6-bit 4-bit
? 2000 microchip technology inc. ds30289b-page 109 pic17c7xx 13.1.3.3 external clock source the pwms will operate, regardless of the clock source of the timer. the use of an external clock has ramifica- tions that must be understood. because the external tclk12 input is synchronized internally (sampled once per instruction cycle), the time tclk12 changes to the time the timer increments, will vary by as much as 1t cy (one instruction cycle). this will cause jitter in the duty cycle as well as the period of the pwm output. this jitter will be 1t cy , unless the external clock is syn- chronized with the processor clock. use of one of the pwm outputs as the clock source to the tclk12 input, will supply a synchronized clock. in general, when using an external clock source for pwm, its frequency should be much less than the device frequency (f osc ). 13.1.3.4 maximum resolution/frequency for external clock input the use of an external clock for the pwm time base (timer1 or timer2) limits the pwm output to a maxi- mum resolution of 8-bits. the pwxdcl<7:6> bits must be kept cleared. use of any other value will distort the pwm output. all resolutions are supported when inter- nal clock mode is selected. the maximum attainable frequency is also lower. this is a result of the timing requirements of an external clock input for a timer (see the electrical specification section). the maximum pwm frequency, when the timers clock source is the rb4/tclk12 pin, is shown in table 13-4 (standard resolution mode). table 13-5: registers/bits associated with pwm address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 16h, bank 3 tcon1 ca2ed1 ca2ed0 ca1ed1 ca1ed0 t16 tmr3cs tmr2cs tmr1cs 0000 0000 0000 0000 17h, bank 3 tcon2 ca2ovf ca1ovf pwm2on pwm1on ca1/pr3 tmr3on tmr2on tmr1on 0000 0000 0000 0000 16h, bank 7 tcon3 ? ca4ovf ca3ovf ca4ed1 ca4ed0 ca3ed1 ca3ed0 pwm3on -000 0000 -000 0000 10h, bank 2 tmr1 timer1 ? s register xxxx xxxx uuuu uuuu 11h, bank 2 tmr2 timer2 ? s register xxxx xxxx uuuu uuuu 16h, bank 1 pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h, bank 1 pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 07h, unbanked intsta peif t0ckif t0if intf peie t0ckie t0ie inte 0000 0000 0000 0000 06h, unbanked cpusta ? ? stkav glintd to pd por bor --11 11qq --11 qquu 14h, bank 2 pr1 timer1 period register xxxx xxxx uuuu uuuu 15h, bank 2 pr2 timer2 period register xxxx xxxx uuuu uuuu 10h, bank 3 pw1dcl dc1 dc0 ? ? ? ? ? ? xx-- ---- uu-- ---- 11h, bank 3 pw2dcl dc1 dc0 tm2pw2 ? ? ? ? ? xx0- ---- uu0- ---- 10h, bank 7 pw3dcl dc1 dc0 tm2pw3 ? ? ? ? ? xx0- ---- uu0- ---- 12h, bank 3 pw1dch dc9 dc8 dc7 dc6 dc5 dc4 dc3 dc2 xxxx xxxx uuuu uuuu 13h, bank 3 pw2dch dc9 dc8 dc7 dc6 dc5 dc4 dc3 dc2 xxxx xxxx uuuu uuuu 11h, bank 7 pw3dch dc9 dc8 dc7 dc6 dc5 dc4 dc3 dc2 xxxx xxxx uuuu uuuu legend: x = unknown, u = unchanged, - = unimplemented, read as '0', q = value depends on conditions. shaded cells are not used by pwm module.
pic17c7xx ds30289b-page 110 ? 2000 microchip technology inc. 13.2 timer3 timer3 is a 16-bit timer consisting of the tmr3h and tmr3l registers. tmr3h is the high byte of the timer and tmr3l is the low byte. this timer has an associ- ated 16-bit period register (pr3h/ca1h:pr3l/ca1l). this period register can be software configured to be a another 16-bit capture register. when the tmr3cs bit (tcon1<2>) is clear, the timer increments every instruction cycle (f osc /4). when tmr3cs is set, the counter increments on every falling edge of the rb5/tclk3 pin. in either mode, the tmr3on bit must be set for the timer/counter to incre- ment. when tmr3on is clear, the timer will not incre- ment or set flag bit tmr3if. timer3 has two modes of operation, depending on the ca1/pr3 bit (tcon2<3>). these modes are:  three capture and one period register mode  four capture register mode the pic17c7xx has up to four 16-bit capture registers that capture the 16-bit value of tmr3 when events are detected on capture pins. there are four capture pins (rb0/cap1, rb1/cap2, rg4/cap3, and re3/cap4), one for each capture register pair. the capture pins are multiplexed with the i/o pins. an event can be:  a rising edge  a falling edge  every 4th rising edge  every 16th rising edge each 16-bit capture register has an interrupt flag asso- ciated with it. the flag is set when a capture is made. the capture modules are truly part of the timer3 block. figure 13-5 and figure 13-6 show the block diagrams for the two modes of operation. 13.2.1 three capture and one period register mode in this mode, registers pr3h/ca1h and pr3l/ca1l constitute a 16-bit period register. a block diagram is shown in figure 13-5. the timer increments until it equals the period register and then resets to 0000h on the next timer clock. tmr3 interrupt flag bit (tmr3if) is set at this point. this interrupt can be disabled by clearing the tmr3 interrupt enable bit (tmr3ie). tmr3if must be cleared in software. figure 13-5: timer3 with three capture and one period register block diagram pr3h/ca1h tmr3h comparator<8> f osc /4 tmr3on reset equal 0 1 comparator x16 rb5/tclk3 set tmr3if tmr3cs pr3l/ca1l tmr3l ca2h ca2l rb1/cap2 edge select, prescaler select 2 set ca2if capture2 ca2ed1: ca2ed0 (tcon1<7:6>) (tcon2<2>) (tcon1<2>) (pir1<3>) (pir1<6>) enable ca3h ca3l rg4/cap3 edge select, prescaler select 2 set ca3if capture3 ca3ed1: ca3ed0 (tcon3<2:1>) (pir2<2>) enable ca4h ca4l re3/cap4 edge select, prescaler select 2 set ca4if capture4 ca4ed1: ca4ed0 (tcon3<4:3>) (pir2<3>) enable
? 2000 microchip technology inc. ds30289b-page 111 pic17c7xx this mode (3 capture, 1 period) is selected if control bit ca1/pr3 is clear. in this mode, the capture1 register, consisting of high byte (pr3h/ca1h) and low byte (pr3l/ca1l), is configured as the period control regis- ter for tmr3. capture1 is disabled in this mode and the corresponding interrupt bit, ca1if, is never set. tmr3 increments until it equals the value in the period regis- ter and then resets to 0000h on the next timer clock. all other captures are active in this mode. 13.2.1.1 capture operation the caxed1 and caxed0 bits determine the event on which capture will occur. the possible events are:  capture on every falling edge  capture on every rising edge  capture every 4th rising edge  capture every 16th rising edge when a capture takes place, an interrupt flag is latched into the caxif bit. this interrupt can be enabled by set- ting the corresponding mask bit caxie. the peripheral interrupt enable bit (peie) must be set and the global interrupt disable bit (glintd) must be cleared for the interrupt to be acknowledged. the caxif interrupt flag bit is cleared in software. when the capture prescale select is changed, the pres- caler is not reset and an event may be generated. therefore, the first capture after such a change will be ambiguous. however, it sets the time-base for the next capture. the prescaler is reset upon chip reset. the capture pin, capx, is a multiplexed pin. when used as a port pin, the capture is not disabled. how- ever, the user can simply disable the capture interrupt by clearing caxie. if the capx pin is used as an output pin, the user can activate a capture by writing to the port pin. this may be useful during development phase to emulate a capture interrupt. the input on the capture pin capx is synchronized internally to internal phase clocks. this imposes certain restrictions on the input waveform (see the electrical specification section for timing). the capture overflow status flag bit is double buffered. the master bit is set if one captured word is already residing in the capture register (caxh:caxl) and another ? event ? has occurred on the capx pin. the new event will not transfer the tmr3 value to the cap- ture register, protecting the previous unread capture value. when the user reads both the high and the low bytes (in any order) of the capture register, the master overflow bit is transferred to the slave overflow bit (caxovf) and then the master bit is reset. the user can then read tconx to determine the value of cax- ovf. the recommended sequence to read capture registers and capture overflow flag bits is shown in example 13-1.
pic17c7xx ds30289b-page 112 ? 2000 microchip technology inc. 13.2.2 four capture mode this mode is selected by setting bit ca1/pr3 . a block diagram is shown in figure 13-6. in this mode, tmr3 runs without a period register and increments from 0000h to ffffh and rolls over to 0000h. the tmr3 interrupt flag (tmr3if) is set on this rollover. the tmr3if bit must be cleared in software. registers pr3h/ca1h and pr3l/ca1l make a 16-bit capture register (capture1). it captures events on pin rb0/cap1. capture mode is configured by the ca1ed1 and ca1ed0 bits. capture1 interrupt flag bit (ca1if) is set upon detection of the capture event. the corresponding interrupt mask bit is ca1ie. the capture1 overflow status bit is ca1ovf. all the captures operate in the same manner. refer to section 13.2.1 for the operation of capture. figure 13-6: timer3 with four captures block diagram rb0/cap1 edge select, prescaler select pr3h/ca1h pr3l/ca1l rb1/cap2 rg4/cap3 edge select, prescaler select 2 set ca1if (pir1<2>) capture1 enable tmr3on tmr3cs (tcon1<2>) 0 1 set tmr3if (pir1<6>) edge select, prescaler select ca2h ca2l set ca2if (pir1<3>) ca3h ca3l set ca3if (pir2<2>) ca1ed1, ca1ed0 (tcon1<5:4>) (tcon2<2>) f osc /4 rb5/tclk3 capture2 enable capture3 enable ca2ed1, ca2ed0 (tcon1<7:6>) 2 ca3ed1: ca3ed0 (tcon3<2:1>) tmr3h tmr3l 2 re3/cap4 edge select, prescaler select 2 ca4h ca4l set ca4if (pir2<3>) capture4 enable ca4ed1: ca4ed0 (tcon3<4:3>)
? 2000 microchip technology inc. ds30289b-page 113 pic17c7xx 13.2.3 reading the capture registers the capture overflow status flag bits are double buff- ered. the master bit is set if one captured word is already residing in the capture register and another ? event ? has occurred on the capx pin. the new event will not transfer the tmr3 value to the capture register, protecting the previous unread capture value. when the user reads both the high and the low bytes (in any order) of the capture register, the master overflow bit is transferred to the slave overflow bit (caxovf) and then the master bit is reset. the user can then read tconx to determine the value of caxovf. an example of an instruction sequence to read capture registers and capture overflow flag bits is shown in example 13-1. depending on the capture source, dif- ferent registers will need to be read. example 13-1: sequence to read capture registers table 13-6: registers associated with capture movlb 3 ; select bank 3 movpf ca2l, lo_byte ; read capture2 low byte, store in lo_byte movpf ca2h, hi_byte ; read capture2 high byte, store in hi_byte movpf tcon2, stat_val ; read tcon2 into file stat_val address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 16h, bank 3 tcon1 ca2ed1 ca2ed0 ca1ed1 ca1ed0 t16 tmr3cs tmr2cs tmr1cs 0000 0000 0000 0000 17h, bank 3 tcon2 ca2ovf ca1ovf pwm2on pwm1on ca1/pr3 tmr3on tmr2on tmr1on 0000 0000 0000 0000 16h, bank 7 tcon3 ? ca4ovf ca3ovf ca4ed1 ca4ed0 ca3ed1 ca3ed0 pwm3on -000 0000 -000 0000 12h, bank 2 tmr3l holding register for the low byte of the 16-bit tmr3 register xxxx xxxx uuuu uuuu 13h, bank 2 tmr3h holding register for the high byte of the 16-bit tmr3 register xxxx xxxx uuuu uuuu 16h, bank 1 pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h, bank 1 pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 10h, bank 4 pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0010 000- 0010 11h, bank 4 pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 07h, unbanked intsta peif t0ckif t0if intf peie t0ckie t0ie inte 0000 0000 0000 0000 06h, unbanked cpusta ? ? stkav glintd to pd por bor --11 11qq --11 qquu 16h, bank 2 pr3l/ca1l timer3 period register, low byte/capture1 register, low byte xxxx xxxx uuuu uuuu 17h, bank 2 pr3h/ca1h timer3 period register, high byte/capture1 register, high byte xxxx xxxx uuuu uuuu 14h, bank 3 ca2l capture2 low byte xxxx xxxx uuuu uuuu 15h, bank 3 ca2h capture2 high byte xxxx xxxx uuuu uuuu 12h, bank 7 ca3l capture3 low byte xxxx xxxx uuuu uuuu 13h, bank 7 ca3h capture3 high byte xxxx xxxx uuuu uuuu 14h, bank 7 ca4l capture4 low byte xxxx xxxx uuuu uuuu 15h, bank 7 ca4h capture4 high byte xxxx xxxx uuuu uuuu legend: x = unknown, u = unchanged, - = unimplemented, read as '0', q = value depends on condition. shaded cells are not used by capture.
pic17c7xx ds30289b-page 114 ? 2000 microchip technology inc. 13.2.4 external clock input for timer3 when tmr3cs is set, the 16-bit tmr3 increments on the falling edge of clock input tclk3. the input on the rb5/tclk3 pin is sampled and synchronized by the internal phase clocks, twice every instruction cycle. this causes a delay from the time a falling edge appears on tclk3 to the time tmr3 is actually incre- mented. for the external clock input timing require- ments, see the electrical specification section. figure 13-7 shows the timing diagram when operating from an external clock. 13.2.5 reading/writing timer3 since timer3 is a 16-bit timer and only 8-bits at a time can be read or written, care should be taken when reading or writing while the timer is running. the best method is to stop the timer, perform any read or write operation and then restart timer3 (using the tmr3on bit). however, if it is necessary to keep timer3 free- running, care must be taken. for writing to the 16-bit tmr3, example 13-2 may be used. for reading the 16- bit tmr3, example 13-3 may be used. interrupts must be disabled during this routine. example 13-2: writing to tmr3 example 13-3: reading from tmr3 figure 13-7: timer1, timer2 and timer3 operation (in counter mode) bsf cpusta, glintd ; disable interrupts movfp ram_l, tmr3l ; movfp ram_h, tmr3h ; bcf cpusta, glintd ; done, enable interrupts movpf tmr3l, tmplo ; read low tmr3 movpf tmr3h, tmphi ; read high tmr3 movfp tmplo, wreg ; tmplo ?> wreg cpfslt tmr3l ; tmr3l < wreg? return ; no then return movpf tmr3l, tmplo ; read low tmr3 movpf tmr3h, tmphi ; read high tmr3 return ; return q1q2q3q4 q1q2q3q4 q1q2q3q4 q1q2q3q4 q1q2q3q4 q1q2q3q4 instruction executed movwf movfp tmrx,w tmrx movfp tmrx,w write to tmrx read tmrx read tmrx 34h 35h a8h a9h 00h ? a9h ?? a9h ? tclk12 tmr1, tmr2, or tmr3 pr1, pr2, or pr3h:pr3l wr_tmr rd_tmr tmrxif note 1: tclk12 is sampled in q2 and q4. 2: indicates a sampling point. 3: the latency from tclk12 to timer increment is between 2tosc and 6tosc. or tclk3
? 2000 microchip technology inc. ds30289b-page 115 pic17c7xx figure 13-8: timer1, timer2 and timer3 operation (in timer mode) 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 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 ad15:ad0 ale instruction fetched tmr1 pr1 tmr1on wr_tmr1 wr_tcon2 tmr1if rd_tmr1 tmr1 reads 03h tmr1 reads 04h movwf tmr1 write tmr1 movf tmr1, w read tmr1 movf tmr1, w read tmr1 bsf tcon2, 0 stop tmr1 bcf tcon2, 0 start tmr1 movlb 3 nop nop nop nop nop 04h 05h 03h 04h 05h 06h 07h 08h 00h
pic17c7xx ds30289b-page 116 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 117 pic17c7xx 14.0 universal synchronous asynchronous receiver transmitter (usart) modules each usart module is a serial i/o module. there are two usart modules that are available on the pic17c7xx. they are specified as usart1 and usart2. the description of the operation of these mod- ules is generic in regard to the register names and pin names used. table 14-1 shows the generic names that are used in the description of operation and the actual names for both usart1 and usart2. since the control bits in each register have the same function, their names are the same (there is no need to differentiate). the transmit status and control register (txsta) is shown in figure 14-1, while the receive status and control register (rcsta) is shown in figure 14-2. table 14-1: usart module generic names register 14-1: txsta1 register (address: 15h, bank 0) txsta2 register (address: 15h, bank 4) generic name usart1 name usart2 name registers rcsta rcsta1 rcsta2 txsta txsta1 txsta2 spbrg spbrg1 spbrg2 rcreg rcreg1 rcreg2 txreg txreg1 txreg2 interrupt control bits rcie rc1ie rc2ie rcif rc1if rc2if txie tx1ie tx2ie txif tx1if tx2if pins rx/dt ra4/rx1/dt1 rg6/rx2/dt2 tx/ck ra5/tx1/ck1 rg7/tx2/ck2 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 r-1 r/w-x csrc tx9 txen sync ? ? trmt tx9d bit 7 bit 0 bit 7 csrc : clock source select bit synchronous mode: 1 = master mode (clock generated internally from brg) 0 = slave mode (clock from external source) asynchronous mode : don ? t care bit 6 tx9 : 9-bit transmit select bit 1 = selects 9-bit transmission 0 = selects 8-bit transmission bit 5 txen : transmit enable bit 1 = transmit enabled 0 = transmit disabled sren/cren overrides txen in sync mode bit 4 sync : usart mode select bit (synchronous/asynchronous) 1 = synchronous mode 0 = asynchronous mode bit 3-2 unimplemented : read as '0' bit 1 trmt : transmit shift register (tsr) empty bit 1 = tsr empty 0 = tsr full bit 0 tx9d : 9th bit of transmit data (can be used to calculate the parity in software) legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
pic17c7xx ds30289b-page 118 ? 2000 microchip technology inc. the usart can be configured as a full duplex asyn- chronous system that can communicate with peripheral devices such as crt terminals and personal comput- ers, or it can be configured as a half duplex synchro- nous system that can communicate with peripheral devices such as a/d or d/a integrated circuits, serial eeproms etc. the usart can be configured in the following modes:  asynchronous (full duplex)  synchronous - master (half duplex)  synchronous - slave (half duplex) the spen (rcsta<7>) bit has to be set in order to configure the i/o pins as the serial communication interface (usart). the usart module will control the direction of the rx/ dt and tx/ck pins, depending on the states of the usart configuration bits in the rcsta and txsta registers. the bits that control i/o direction are:  spen  txen  sren  cren  csrc register 14-2: rcsta1 register (address: 13h, bank 0) rcsta2 register (address: 13h, bank 4) r/w-0 r/w-0 r/w-0 r/w-0 u-0 r-0 r-0 r-x spen rx9 sren cren ? ferr oerr rx9d bit 7 bit 0 bit 7 spen : serial port enable bit 1 = configures tx/ck and rx/dt pins as serial port pins 0 = serial port disabled bit 6 rx9 : 9-bit receive select bit 1 = selects 9-bit reception 0 = selects 8-bit reception bit 5 sren : single receive enable bit this bit enables the reception of a single byte. after receiving the byte, this bit is automatically cleared. synchronous mode: 1 = enable reception 0 = disable reception note: this bit is ignored in synchronous slave reception. asynchronous mode: don ? t care bit 4 cren : continuous receive enable bit this bit enables the continuous reception of serial data. asynchronous mode: 1 = enable continuous reception 0 = disables continuous reception synchronous mode: 1 = enables continuous reception until cren is cleared (cren overrides sren) 0 = disables continuous reception bit 3 unimplemented : read as '0' bit 2 ferr : framing error bit 1 = framing error (updated by reading rcreg) 0 = no framing error bit 1 bit oerr : overrun error bit 1 = overrun (cleared by clearing cren) 0 = no overrun error bit 0 rx9d : 9th bit of receive data (can be the software calculated parity bit) legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
? 2000 microchip technology inc. ds30289b-page 119 pic17c7xx figure 14-1: usart transmit figure 14-2: usart receive ck/tx dt sync/async tsr start 0 1 7 8 stop ? ? ? 16 4 brg 01 7 ? ? ? 8 bit count txie interrupt txen/ write to txreg clock sync/async sync/async txsta<0> sync master/slave data bus load txreg ck rx 0 1 7 8 stop ? ? ? 16 4 brg bit count clock buffer logic buffer logic spen osc start 0 1 7 rx9d ? ? ? 0 1 7 rx9d ? ? ? ferr ferr majority detect data msb lsb rsr rcreg async/sync sync/async master/slave sync enable fifo logic clk fifo rcie interrupt rx9 data bus sren/ cren/ start_bit async/sync detect
pic17c7xx ds30289b-page 120 ? 2000 microchip technology inc. 14.1 usart baud rate generator (brg) the brg supports both the asynchronous and syn- chronous modes of the usart. it is a dedicated 8-bit baud rate generator. the spbrg register controls the period of a free running 8-bit timer. table 14-2 shows the formula for computation of the baud rate for differ- ent usart modes. these only apply when the usart is in synchronous master mode (internal clock) and asynchronous mode. given the desired baud rate and fosc, the nearest inte- ger value between 0 and 255 can be calculated using the formula below. the error in baud rate can then be determined. table 14-2: baud rate formula example 14-1 shows the calculation of the baud rate error for the following conditions: f osc = 16 mhz desired baud rate = 9600 sync = 0 example 14-1: calculating baud rate error writing a new value to the spbrg, causes the brg timer to be reset (or cleared). this ensures that the brg does not wait for a timer overflow before output- ting the new baud rate. effects of reset after any device reset, the spbrg register is cleared. the spbrg register will need to be loaded with the desired value after each reset. table 14-3: registers associated with baud rate generator sync mode baud rate 0 1 asynchronous synchronous f osc /(64(x+1)) f osc /(4(x+1)) x = value in spbrg (0 to 255) desired baud rate = f osc / (64 (x + 1)) 9600 = 16000000 /(64 (x + 1)) x = 25.042 25 calculated baud rate = 16000000 / (64 (25 + 1)) = 9615 error = (calculated baud rate - desired baud rate) desired baud rate = (9615 - 9600) / 9600 =0.16% address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt usart1 13h, bank 0 rcsta1 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 15h, bank 0 txsta1 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 0 spbrg1 baud rate generator register 0000 0000 0000 0000 usart2 13h, bank 4 rcsta2 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 15h, bank 4 txsta2 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 4 spbrg2 baud rate generator register 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. shaded cells are not used by the baud rate generator.
? 2000 microchip technology inc. ds30289b-page 121 pic17c7xx table 14-4: baud rates for synchronous mode baud rate (k) f osc = 33 mhz spbrg value (decimal) f osc = 25 mhz spbrg value (decimal) f osc = 20 mhz spbrg value (decimal) f osc = 16 mhz spbrg value (decimal) kbaud %error kbaud %error kbaud %error kbaud %error 0.3 na ?? na ?? na ?? na ?? 1.2 na ?? na ?? na ?? na ?? 2.4 na ?? na ?? na ?? na ?? 9.6 na ?? na ?? na ?? na ?? 19.2 na ?? na ?? 19.53 +1.73 255 19.23 +0.16 207 76.8 77.10 +0.39 106 77.16 +0.47 80 76.92 +0.16 64 76.92 +0.16 51 96 95.93 -0.07 85 96.15 +0.16 64 96.15 +0.16 51 95.24 -0.79 41 300 294.64 -1.79 27 297.62 -0.79 20 294.1 -1.96 16 307.69 +2.56 12 500 485.29 -2.94 16 480.77 -3.85 12 500 0 9 500 0 7 high 8250 ? 06250 ? 05000 ? 0 4000 ? 0 low 32.22 ? 255 24.41 ? 255 19.53 ? 255 15.625 ? 255 baud rate (k) f osc = 10 mhz spbrg value (decimal) f osc = 7.159 mhz spbrg value (decimal) f osc = 5.068 mhz spbrg value (decimal) kbaud %error kbaud %error kbaud %error 0.3 na ?? na ?? na ?? 1.2 na ?? na ?? na ?? 2.4 na ?? na ?? na ?? 9.6 9.766 +1.73 255 9.622 +0.23 185 9.6 0 131 19.2 19.23 +0.16 129 19.24 +0.23 92 19.2 0 65 76.8 75.76 -1.36 32 77.82 +1.32 22 79.2 +3.13 15 96 96.15 +0.16 25 94.20 -1.88 18 97.48 +1.54 12 300 312.5 +4.17 7 298.3 -0.57 5 316.8 +5.60 3 500 500 0 4 na ? ? na ?? high 2500 ? 0 1789.8 ? 0 1267 ? 0 low 9.766 ? 255 6.991 ? 255 4.950 ? 255 baud rate (k) f osc = 3.579 mhz spbrg value (decimal) f osc = 1 mhz spbrg value (decimal) f osc = 32.768 khz spbrg value (decimal) kbaud %error kbaud %error kbaud %error 0.3 na ?? na ?? 0.303 +1.14 26 1.2 na ?? 1.202 +0.16 207 1.170 -2.48 6 2.4 na ?? 2.404 +0.16 103 na ?? 9.6 9.622 +0.23 92 9.615 +0.16 25 na ?? 19.2 19.04 -0.83 46 19.24 +0.16 12 na ?? 76.8 74.57 -2.90 11 83.34 +8.51 2 na ?? 96 99.43 _3.57 8 na ?? na ?? 300 298.3 -0.57 2 na ?? na ?? 500 na ?? na ?? na ?? high 894.9 ? 0250 ? 0 8.192 ? 0 low 3.496 ? 255 0.976 ? 255 0.032 ? 255
pic17c7xx ds30289b-page 122 ? 2000 microchip technology inc. table 14-5: baud rates for asynchronous mode baud rate (k) f osc = 33 mhz spbrg value (decimal) f osc = 25 mhz spbrg value (decimal) f osc = 20 mhz spbrg value (decimal) f osc = 16 mhz spbrg value (decimal) kbaud %error kbaud %error kbaud %error kbaud %error 0.3 na ?? na ?? na ?? na ?? 1.2 na ?? na ?? 1.221 +1.73 255 1.202 +0.16 207 2.4 2.398 -0.07 214 2.396 0.14 162 2.404 +0.16 129 2.404 +0.16 103 9.6 9.548 -0.54 53 9.53 -0.76 40 9.469 -1.36 32 9.615 +0.16 25 19.2 19.09 -0.54 26 19.53 +1.73 19 19.53 +1.73 15 19.23 +0.16 12 76.8 73.66 -4.09 6 78.13 +1.73 4 78.13 +1.73 3 83.33 +8.51 2 96 103.12 +7.42 4 97.65 +1.73 3 104.2 +8.51 2 na ?? 300 257.81 -14.06 1 390.63 +30.21 0 312.5 +4.17 0 na ?? 500 515.62 +3.13 0 na ?? na ?? na ?? high 515.62 ? 0 ?? 0312.5 ? 0250 ? 0 low 2.014 ? 255 1.53 ? 255 1.221 ? 255 0.977 ? 255 baud rate (k) f osc = 10 mhz spbrg value (decimal) f osc = 7.159 mhz spbrg value (decimal) f osc = 5.068 mhz spbrg value (decimal) kbaud %error kbaud %error kbaud %error 0.3 na ?? na ?? 0.31 +3.13 255 1.2 1.202 +0.16 129 1.203 _0.23 92 1.2 0 65 2.4 2.404 +0.16 64 2.380 -0.83 46 2.4 0 32 9.6 9.766 +1.73 15 9.322 -2.90 11 9.9 -3.13 7 19.2 19.53 +1.73 7 18.64 -2.90 5 19.8 +3.13 3 76.8 78.13 +1.73 1 na ?? 79.2 +3.13 0 96 na ?? na ?? na ?? 300 na ?? na ?? na ?? 500 na ?? na ?? na ?? high 156.3 ? 0 111.9 ? 079.2 ? 0 low 0.610 ? 255 0.437 ? 255 0.309 ? 2 55 baud rate (k) f osc = 3.579 mhz spbrg value (decimal) f osc = 1 mhz spbrg value (decimal) f osc = 32.768 khz spbrg value (decimal) kbaud %error kbaud %error kbaud %error 0.3 0.301 +0.23 185 0.300 +0.16 51 0.256 -14.67 1 1.2 1.190 -0.83 46 1.202 +0.16 12 na ?? 2.4 2.432 +1.32 22 2.232 -6.99 6 na ?? 9.6 9.322 -2.90 5 na ?? na ?? 19.2 18.64 -2.90 2 na ?? na ?? 76.8 na ?? na ?? na ?? 96 na ?? na ?? na ?? 300 na ?? na ?? na ?? 500 na ?? na ?? na ?? high 55.93 ? 015.63 ? 0 0.512 ? 0 low 0.218 ? 255 0.061 ? 255 0.002 ? 255
? 2000 microchip technology inc. ds30289b-page 123 pic17c7xx 14.2 usart asynchronous mode in this mode, the usart uses standard nonreturn-to- zero (nrz) format (one start bit, eight or nine data bits, and one stop bit). the most common data format is 8-bits. an on-chip dedicated 8-bit baud rate genera- tor can be used to derive standard baud rate frequen- cies from the oscillator. the usart ? s transmitter and receiver are functionally independent but use the same data format and baud rate. the baud rate generator produces a clock x64 of the bit shift rate. parity is not supported by the hardware, but can be implemented in software (and stored as the ninth data bit). asynchro- nous mode is stopped during sleep. the asynchronous mode is selected by clearing the sync bit (txsta<4>). the usart asynchronous module consists of the fol- lowing components:  baud rate generator  sampling circuit  asynchronous transmitter  asynchronous receiver 14.2.1 usart asynchronous transmitter the usart transmitter block diagram is shown in figure 14-1. the heart of the transmitter is the transmit shift register (tsr). the shift register obtains its data from the read/write transmit buffer (txreg). txreg is loaded with data in software. the tsr is not loaded until the stop bit has been transmitted from the previous load. as soon as the stop bit is transmitted, the tsr is loaded with new data from the txreg (if available). once txreg transfers the data to the tsr (occurs in one t cy at the end of the current brg cycle), the txreg is empty and an interrupt bit, txif, is set. this interrupt can be enabled/disabled by setting/clearing the txie bit. txif will be set, regardless of txie and cannot be reset in software. it will reset only when new data is loaded into txreg. while txif indicates the status of the txreg, the trmt (txsta<1>) bit shows the status of the tsr. trmt is a read only bit which is set when the tsr is empty. no interrupt logic is tied to this bit, so the user has to poll this bit in order to determine if the tsr is empty. transmission is enabled by setting the txen (txsta<5>) bit. the actual transmission will not occur until txreg has been loaded with data and the baud rate generator (brg) has produced a shift clock (figure 14-3). the transmission can also be started by first loading txreg and then setting txen. normally, when transmission is first started, the tsr is empty, so a transfer to txreg will result in an immediate transfer to tsr, resulting in an empty txreg. a back-to-back transfer is thus possible (figure 14-4). clearing txen during a transmission will cause the transmission to be aborted. this will reset the transmitter and the tx/ck pin will revert to hi-impedance. in order to select 9-bit transmission, the tx9 (txsta<6>) bit should be set and the ninth bit value should be written to tx9d (txsta<0>). the ninth bit value must be written before writing the 8-bit data to the txreg. this is because a data write to txreg can result in an immediate transfer of the data to the tsr (if the tsr is empty). steps to follow when setting up an asynchronous transmission: 1. initialize the spbrg register for the appropriate baud rate. 2. enable the asynchronous serial port by clearing the sync bit and setting the spen bit. 3. if interrupts are desired, then set the txie bit. 4. if 9-bit transmission is desired, then set the tx9 bit. 5. if 9-bit transmission is selected, the ninth bit should be loaded in tx9d. 6. load data to the txreg register. 7. enable the transmission by setting txen (starts transmission). figure 14-3: asynchronous master transmission note: the tsr 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 txif bit trmt bit (tx/ck pin)
pic17c7xx ds30289b-page 124 ? 2000 microchip technology inc. figure 14-4: asynchronous master transmission (back to back) table 14-6: registers associated with asynchronous transmission transmit shift reg. write to txreg brg output (shift clock) tx txif bit trmt bit 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. (tx/ck pin) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 16h, bank 1 pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h, bank 1 pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 13h, bank 0 rcsta1 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 16h, bank 0 txreg1 serial port transmit register (usart1) xxxx xxxx uuuu uuuu 15h, bank 0 txsta1 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 0 spbrg1 baud rate generator register (usart1) 0000 0000 0000 0000 10h, bank 4 pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0010 000- 0010 11h, bank 4 pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 13h, bank 4 rcsta2 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 16h, bank 4 txreg2 serial port transmit register (usart2) xxxx xxxx uuuu uuuu 15h, bank 4 txsta2 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 4 spbrg2 baud rate generator register (usart2) 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as a '0'. shaded cells are not used for asynchronous transmission.
? 2000 microchip technology inc. ds30289b-page 125 pic17c7xx 14.2.2 usart asynchronous receiver the receiver block diagram is shown in figure 14-2. the data comes in 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 main receive serial shifter operates at the bit rate or at f osc . once asynchronous mode is selected, reception is enabled by setting bit cren (rcsta<4>). the heart of the receiver is the receive (serial) shift reg- ister (rsr). after sampling the stop bit, the received data in the rsr is transferred to the rcreg (if it is empty). if the transfer is complete, the interrupt bit, rcif, is set. the actual interrupt can be enabled/ disabled by setting/clearing the rcie bit. rcif is a read only bit which is cleared by the hardware. it is cleared when rcreg has been read and is empty. rcreg is a double buffered register (i.e., it is a two- deep fifo). it is possible for two bytes of data to be received and transferred to the rcreg fifo and a third byte begin shifting to the rsr. on detection of the stop bit of the third byte, if the rcreg is still full, then the overrun error bit, oerr (rcsta<1>) will be set. the word in the rsr will be lost. rcreg can be read twice to retrieve the two bytes in the fifo. the oerr bit has to be cleared in software which is done by reset- ting the receive logic (cren is set). if the oerr bit is set, transfers from the rsr to rcreg are inhibited, so it is essential to clear the oerr bit if it is set. the fram- ing error bit ferr (rcsta<2>) is set if a stop bit is not detected. 14.2.3 sampling the data on the rx/dt pin is sampled three times by a majority detect circuit to determine if a high or a low level is present at the rx/dt pin. the sampling is done on the seventh, eighth and ninth falling edges of a x16 clock (figure 14-5). the x16 clock is a free running clock and the three sample points occur at a frequency of every 16 falling edges. figure 14-5: rx pin sampling scheme figure 14-6: start bit detect note: the ferr and the 9th receive bit are buff- ered the same way as the receive data. reading the rcreg register will allow the rx9d and ferr bits to be loaded with val- ues for the next received data. therefore, it is essential for the user to read the rcsta register before reading rcreg, in order not to lose the old ferr and rx9d information. rx baud clk x16 clk start bit bit0 samples 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 baud clk for all but start bit (rx/dt pin) rx x16 clk q2, q4 clk start bit (rx/dt pin) first rising edge of x16 clock after rx pin goes low rx sampled low
pic17c7xx ds30289b-page 126 ? 2000 microchip technology inc. steps to follow when setting up an asynchronous reception: 1. initialize the spbrg register for the appropriate baud rate. 2. enable the asynchronous serial port by clearing the sync bit and setting the spen bit. 3. if interrupts are desired, then set the rcie bit. 4. if 9-bit reception is desired, then set the rx9 bit. 5. enable the reception by setting the cren bit. 6. the rcif bit will be set when reception com- pletes and an interrupt will be generated if the rcie bit was set. 7. read rcsta to get the ninth bit (if enabled) and ferr bit to determine if any error occurred dur- ing reception. 8. read rcreg for the 8-bit received data. 9. if an overrun error occurred, clear the error by clearing the oerr bit. figure 14-7: asynchronous reception table 14-7: registers associated with asynchronous reception note: to terminate a reception, either clear the sren and cren bits, or the spen bit. this will reset the receive logic, so that it will be in the proper state when receive is re-enabled. start bit bit7/8 bit1 bit0 bit7/8 bit0 stop bit start bit start bit bit7/8 stop bit rx 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. (rx/dt pin) word 3 address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 16h, bank 1 pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h, bank 1 pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 13h, bank 0 rcsta1 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 14h, bank 0 rcreg1 rx7 rx6 rx5 rx4 rx3 rx2 rx1 rx0 xxxx xxxx uuuu uuuu 15h, bank 0 txsta1 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 0 spbrg1 baud rate generator register 0000 0000 0000 0000 10h, bank 4 pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0010 000- 0010 11h, bank 4 pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 13h, bank 4 rcsta2 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 14h, bank 4 rcreg2 rx7 rx6 rx5 rx4 rx3 rx2 rx1 rx0 xxxx xxxx uuuu uuuu 15h, bank 4 txsta2 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 4 spbrg2 baud rate generator register 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as a '0'. shaded cells are not used for asynchronous reception.
? 2000 microchip technology inc. ds30289b-page 127 pic17c7xx 14.3 usart synchronous master mode in master synchronous mode, the data is transmitted in a half-duplex manner; i.e., transmission and reception do not occur at the same time: when transmitting data, the reception is inhibited and vice versa. the synchro- nous mode is entered by setting the sync (txsta<4>) bit. in addition, the spen (rcsta<7>) bit is set in order to configure the i/o pins to ck (clock) and dt (data) lines, respectively. the master mode indi- cates that the processor transmits the master clock on the ck line. the master mode is entered by setting the csrc (txsta<7>) bit. 14.3.1 usart synchronous master transmission the usart transmitter block diagram is shown in figure 14-1. the heart of the transmitter is the transmit (serial) shift register (tsr). the shift register obtains its data from the read/write transmit buffer txreg. txreg is loaded with data in software. the tsr is not loaded until the last bit has been transmitted from the previous load. as soon as the last bit is transmitted, the tsr is loaded with new data from txreg (if available). once txreg transfers the data to the tsr (occurs in one t cy at the end of the current brg cycle), txreg is empty and the txif bit is set. this interrupt can be enabled/disabled by setting/clearing the txie bit. txif will be set regardless of the state of bit txie and cannot be cleared in software. it will reset only when new data is loaded into txreg. while txif indicates the status of txreg, trmt (txsta<1>) shows the status of the tsr. trmt is a read only bit which is set when the tsr is empty. no interrupt logic is tied to this bit, so the user has to poll this bit in order to determine if the tsr is empty. the tsr is not mapped in data memory, so it is not available to the user. transmission is enabled by setting the txen (txsta<5>) bit. the actual transmission will not occur until txreg has been loaded with data. the first data bit will be shifted out on the next available rising edge of the clock on the tx/ck pin. data out is stable around the falling edge of the synchronous clock (figure 14-9). the transmission can also be started by first loading txreg and then setting txen. this is advantageous when slow baud rates are selected, since brg is kept in reset when the txen, cren, and sren bits are clear. setting the txen bit will start the brg, creating a shift clock immediately. normally when transmission is first started, the tsr is empty, so a transfer to txreg will result in an immediate transfer to the tsr, resulting in an empty txreg. back-to-back transfers are possible. clearing txen during a transmission will cause the transmission to be aborted and will reset the transmit- ter. the rx/dt and tx/ck pins will revert to hi-imped- ance. if either cren or sren are set during a transmission, the transmission is aborted and the rx/ dt pin reverts to a hi-impedance state (for a reception). the tx/ck pin will remain an output if the csrc bit is set (internal clock). the transmitter logic is not reset, although it is disconnected from the pins. in order to reset the transmitter, the user has to clear the txen bit. if the sren bit is set (to interrupt an ongoing transmis- sion and receive a single word), then after the single word is received, sren will be cleared and the serial port will revert back to transmitting, since the txen bit is still set. the dt line will immediately switch from hi- impedance receive mode to transmit and start driving. to avoid this, txen should be cleared. in order to select 9-bit transmission, the tx9 (txsta<6>) bit should be set and the ninth bit should be written to tx9d (txsta<0>). the ninth bit must be written before writing the 8-bit data to txreg. this is because a data write to txreg can result in an immediate transfer of the data to the tsr (if the tsr is empty). if the tsr was empty and txreg was written before writing the ? new ? tx9d, the ? present ? value of tx9d is loaded. steps to follow when setting up a synchronous master transmission: 1. initialize the spbrg register for the appropriate baud rate (see baud rate generator section for details). 2. enable the synchronous master serial port by setting the sync, spen, and csrc bits. 3. ensure that the cren and sren bits are clear (these bits override transmission when set). 4. if interrupts are desired, then set the txie bit (the glintd bit must be clear and the peie bit must be set). 5. if 9-bit transmission is desired, then set the tx9 bit. 6. if 9-bit transmission is selected, the ninth bit should be loaded in tx9d. 7. start transmission by loading data to the txreg register. 8. enable the transmission by setting txen. writing the transmit data to the txreg, then enabling the transmit (setting txen), allows transmission to start sooner than doing these two events in the reverse order. note: to terminate a transmission, either clear the spen bit, or the txen bit. this will reset the transmit logic, so that it will be in the proper state when transmit is re- enabled.
pic17c7xx ds30289b-page 128 ? 2000 microchip technology inc. table 14-8: registers associated with synchronous master transmission figure 14-8: synchronous transmission figure 14-9: synchronous transmission (through txen) address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 16h, bank 1 pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h, bank 1 pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 13h, bank 0 rcsta1 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 16h, bank 0 txreg1 tx7 tx6 tx5 tx4 tx3 tx2 tx1 tx0 xxxx xxxx uuuu uuuu 15h, bank 0 txsta1 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 0 spbrg1 baud rate generator register 0000 0000 0000 0000 10h, bank 4 pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0010 000- 0010 11h, bank 4 pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 13h, bank 4 rcsta2 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 16h, bank 4 txreg2 tx7 tx6 tx5 tx4 tx3 tx2 tx1 tx0 xxxx xxxx uuuu uuuu 15h, bank 4 txsta2 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 4 spbrg2 baud rate generator register 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as a '0'. shaded cells are not used for synchronous master transmission. q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 q1 q2q3 q4 q3 q4 dt ck write to txreg txif interrupt flag trmt txen ? 1 ? write word 1 write word 2 bit0 bit1 bit2 bit7 bit0 word 1 word 2 (rx/dt pin) (tx/ck pin) dt ck write to txreg txif bit trmt bit bit0 bit1 bit2 bit6 bit7 (rx/dt pin) (tx/ck pin)
? 2000 microchip technology inc. ds30289b-page 129 pic17c7xx 14.3.2 usart synchronous master reception once synchronous mode is selected, reception is enabled by setting either the sren (rcsta<5>) bit or the cren (rcsta<4>) bit. data is sampled on the rx/ dt pin on the falling edge of the clock. if sren is set, then only a single word is received. if cren is set, the reception is continuous until cren is reset. if both bits are set, then cren takes precedence. after clocking the last bit, the received data in the receive shift register (rsr) is transferred to rcreg (if it is empty). if the transfer is complete, the interrupt bit rcif is set. the actual interrupt can be enabled/disabled by set- ting/clearing the rcie bit. rcif is a read only bit which is reset by the hardware. in this case, it is reset when rcreg has been read and is empty. rcreg is a dou- ble buffered register; i.e., it is a two deep fifo. it is possible for two bytes of data to be received and trans- ferred to the rcreg fifo and a third byte to begin shifting into the rsr. on the clocking of the last bit of the third byte, if rcreg is still full, then the overrun error bit oerr (rcsta<1>) is set. the word in the rsr will be lost. rcreg can be read twice to retrieve the two bytes in the fifo. the oerr bit has to be cleared in software. this is done by clearing the cren bit. if oerr is set, transfers from rsr to rcreg are inhibited, so it is essential to clear the oerr bit if it is set. the 9th receive bit is buffered the same way as the receive data. reading the rcreg register will allow the rx9d and ferr bits to be loaded with values for the next received data; therefore, it is essential for the user to read the rcsta register before reading rcreg in order not to lose the old ferr and rx9d information. steps to follow when setting up a synchronous master reception: 1. initialize the spbrg register for the appropriate baud rate. see section 14.1 for details. 2. enable the synchronous master serial port by setting bits sync, spen, and csrc. 3. if interrupts are desired, then set the rcie bit. 4. if 9-bit reception is desired, then set the rx9 bit. 5. if a single reception is required, set bit sren. for continuous reception set bit cren. 6. the rcif bit will be set when reception is com- plete and an interrupt will be generated if the rcie bit was set. 7. read rcsta to get the ninth bit (if enabled) and determine if any error occurred during reception. 8. read the 8-bit received data by reading rcreg. 9. if any error occurred, clear the error by clearing cren. figure 14-10: synchronous reception (master mode, sren) note: to terminate a reception, either clear the sren and cren bits, or the spen bit. this will reset the receive logic so that it will be in the proper state when receive is re- enabled. cren bit dt ck write to the sren bit sren bit rcif bit read rcreg note: timing diagram demonstrates sync master mode with sren = 1. q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 q2 q1 q2 q3 q4q1 q2 q3 q4 q1 q2 q3 q4q1 q2 q3 q4 q1 q2 q3 q4q1 q2 q3 q4 q1 q2 q3 q4 ? 0 ? bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 ? 0 ? q1 q2 q3 q4 (rx/dt pin) (tx/ck pin)
pic17c7xx ds30289b-page 130 ? 2000 microchip technology inc. table 14-9: registers associated with synchronous master reception address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 16h, bank 1 pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h, bank 1 pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 13h, bank 0 rcsta1 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 14h, bank 0 rcreg1 rx7 rx6 rx5 rx4 rx3 rx2 rx1 rx0 xxxx xxxx uuuu uuuu 15h, bank 0 txsta1 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 0 spbrg1 baud rate generator register 0000 0000 0000 0000 10h, bank 4 pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0010 000- 0010 11h, bank 4 pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 13h, bank 4 rcsta2 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 14h, bank 4 rcreg2 rx7 rx6 rx5 rx4 rx3 rx2 rx1 rx0 xxxx xxxx uuuu uuuu 15h, bank 4 txsta2 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 4 spbrg2 baud rate generator register 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as a '0'. shaded cells are not used for synchronous master reception.
? 2000 microchip technology inc. ds30289b-page 131 pic17c7xx 14.4 usart synchronous slave mode the synchronous slave mode differs from the master mode, in the fact that the shift clock is supplied exter- nally at the tx/ck pin (instead of being supplied inter- nally in the master mode). this allows the device to transfer or receive data in the sleep mode. the slave mode is entered by clearing the csrc (txsta<7>) bit. 14.4.1 usart synchronous slave transmit the operation of the sync master and slave modes are identical except in the case of the sleep mode. if two words are written to txreg and then the sleep instruction executes, the following will occur. the first word will immediately transfer to the tsr and will trans- mit as the shift clock is supplied. the second word will remain in txreg. txif will not be set. when the first word has been shifted out of tsr, txreg will transfer the second word to the tsr and the txif flag will now be set. if txie is enabled, the interrupt will wake the chip from sleep and if the global interrupt is enabled, then the program will branch to the interrupt vector (0020h). steps to follow when setting up a synchronous slave transmission: 1. enable the synchronous slave serial port by set- ting the sync and spen bits and clearing the csrc bit. 2. clear the cren bit. 3. if interrupts are desired, then set the txie bit. 4. if 9-bit transmission is desired, then set the tx9 bit. 5. if 9-bit transmission is selected, the ninth bit should be loaded in tx9d. 6. start transmission by loading data to txreg. 7. enable the transmission by setting txen. writing the transmit data to the txreg, then enabling the transmit (setting txen), allows transmission to start sooner than doing these two events in the reverse order. 14.4.2 usart synchronous slave reception operation of the synchronous master and slave modes are identical except in the case of the sleep mode. also, sren is a ? don't care ? in slave mode. if receive is enabled (cren) prior to the sleep instruc- tion, then a word may be received during sleep. on completely receiving the word, the rsr will transfer the data to rcreg (setting rcif) and if the rcie bit is set, the interrupt generated will wake the chip from sleep. if the global interrupt is enabled, the program will branch to the interrupt vector (0020h). steps to follow when setting up a synchronous slave reception: 1. enable the synchronous master serial port by setting the sync and spen bits and clearing the csrc bit. 2. if interrupts are desired, then set the rcie bit. 3. if 9-bit reception is desired, then set the rx9 bit. 4. to enable reception, set the cren bit. 5. the rcif bit will be set when reception is com- plete and an interrupt will be generated if the rcie bit was set. 6. read rcsta to get the ninth bit (if enabled) and determine if any error occurred during reception. 7. read the 8-bit received data by reading rcreg. 8. if any error occurred, clear the error by clearing the cren bit. note: to terminate a transmission, either clear the spen bit, or the txen bit. this will reset the transmit logic, so that it will be in the proper state when transmit is re- enabled. note: to abort reception, either clear the spen bit, or the cren bit (when in continuous receive mode). this will reset the receive logic, so that it will be in the proper state when receive is re-enabled.
pic17c7xx ds30289b-page 132 ? 2000 microchip technology inc. table 14-10: registers associated with synchronous slave transmission table 14-11: registers associated with synchronous slave reception address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 16h, bank 1 pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h, bank 1 pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 13h, bank 0 rcsta1 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 15h, bank 0 txsta1 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 16h, bank 0 txreg1 tx7 tx6 tx5 tx4 tx3 tx2 tx1 tx0 xxxx xxxx uuuu uuuu 17h, bank 0 spbrg1 baud rate generator register 0000 0000 0000 0000 10h, bank 4 pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0010 000- 0010 11h, bank 4 pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 13h, bank 4 rcsta2 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 16h, bank 4 txreg2 tx7 tx6 tx5 tx4 tx3 tx2 tx1 tx0 xxxx xxxx uuuu uuuu 15h, bank 4 txsta2 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 4 spbrg2 baud rate generator register 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as a '0'. shaded cells are not used for synchronous slave transmission. address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt 16h, bank1 pir1 rbif tmr3if tmr2if tmr1if ca2if ca1if tx1if rc1if x000 0010 u000 0010 17h, bank1 pie1 rbie tmr3ie tmr2ie tmr1ie ca2ie ca1ie tx1ie rc1ie 0000 0000 0000 0000 13h, bank0 rcsta1 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 14h, bank0 rcreg1 rx7 rx6 rx5 rx4 rx3 rx2 rx1 rx0 xxxx xxxx uuuu uuuu 15h, bank 0 txsta1 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 0 spbrg1 baud rate generator register 0000 0000 0000 0000 10h, bank 4 pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0010 000- 0010 11h, bank 4 pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 13h, bank 4 rcsta2 spen rx9 sren cren ? ferr oerr rx9d 0000 -00x 0000 -00u 14h, bank 4 rcreg2 rx7 rx6 rx5 rx4 rx3 rx2 rx1 rx0 xxxx xxxx uuuu uuuu 15h, bank 4 txsta2 csrc tx9 txen sync ? ? trmt tx9d 0000 --1x 0000 --1u 17h, bank 4 spbrg2 baud rate generator register 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as a '0'. shaded cells are not used for synchronous slave reception.
? 2000 microchip technology inc. ds30289b-page 133 pic17c7xx 15.0 master synchronous serial port (mssp) module 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 tm (i 2 c) figure 15-1 shows a block diagram for the spi mode, while figure 15-2 and figure 15-3 show the block diagrams for the two different i 2 c modes of operation. figure 15-1: spi mode block diagram figure 15-2: i 2 c slave mode block diagram figure 15-3: i 2 c master mode block diagram read write internal data bus sspsr reg sspbuf reg sspm3:sspm0 bit0 shift clock ss control enable edge select clock select tmr2 output to s c prescaler 4, 16, 64 2 edge select 2 4 data to tx/rx in sspsr data direction bit 2 smp:cke sdi sdo ss sck 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 shift clock msb lsb sda or general call detected read write sspsr reg match detect sspadd reg start and stop bit detect/generate sspbuf reg internal data bus addr match set/clear s bit clear/set p, bit (sspstat reg) scl shift clock msb lsb sda baud rate generator 7 sspadd<6:0> and and set sspif or general call detected
pic17c7xx ds30289b-page 134 ? 2000 microchip technology inc. register 15-1: sspstat: sync serial port status register (address: 13h, bank 6) r/w-0 r/w-0 r-0 r-0 r-0 r-0 r-0 r-0 smp cke d/a psr/w ua bf bit 7 bit 0 bit 7 smp : 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 (figure 15-6, figure 15-8 and figure 15-9) ckp = 0: 1 = data transmitted on rising edge of sck 0 = data transmitted on falling edge of sck ckp = 1: 1 = data transmitted on falling edge of sck 0 = data transmitted on rising edge of sck 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 mssp 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 mssp 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 (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 legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
? 2000 microchip technology inc. ds30289b-page 135 pic17c7xx register 15-2: sspcon1: sync serial port control register1 (address 11h, bank 6) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 bit 7 bit 0 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 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 is 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 writing 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 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 0 = disables serial port and configures these pins as i/o port pins note: in spi mode, these pins must be properly configured as input or output. 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 sspm3:sspm0 : 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) ) 1xx1 = reserved 1x1x = reserved legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
pic17c7xx ds30289b-page 136 ? 2000 microchip technology inc. register 15-3: sspcon2: sync serial port control register2 (address 12h, bank 6) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 gcen ackstat ackdt acken rcen pen rsen sen bit 7 bit 0 bit 7 gcen : general call enable bit (in i 2 c slave mode only) 1 = enable interrupt when a general call address (0000h) is received in the sspsr 0 = general call address disabled bit 6 ackstat : acknowledge status bit (in i 2 c master mode only) in master transmit mode: 1 = acknowledge was not received from slave 0 = acknowledge was received from slave bit 5 ackdt : acknowledge data bit (in i 2 c master mode only) in master receive mode: value that will be 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 akdt data bit. automatically cleared by hardware. 0 = acknowledge sequence idle note: 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). bit 3 rcen : receive enable bit (in i 2 c master mode only) 1 = enables receive mode for i 2 c 0 = receive idle note: 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). 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 note: 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). 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 note: 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). bit 0 sen : start condition enabled bit (in i 2 c master mode only) 1 = initiate start condition on sda and scl pins. automatically cleared by hardware. 0 = start condition idle. note: 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). legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
? 2000 microchip technology inc. ds30289b-page 137 pic17c7xx 15.1 spi mode the spi mode allows 8-bits of data to be synchronously transmitted and received simultaneously. all four modes of spi are supported. to accomplish communi- cation, 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 ) 15.1.1 operation when initializing the spi, several options need to be specified. this is done by programming the appropriate control bits in the sspcon1 register (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) figure 15-4 shows the block diagram of the mssp module when in spi mode. figure 15-4: mssp block diagram (spi mode) 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 (sspstat<0>) and the interrupt flag bit sspif (pir2<7>) 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 (sspcon1<7>) will be set. user software must clear the wcol bit so that it can be determined if the following write(s) to the sspbuf register completed successfully. read write internal data bus sspsr reg sspbuf reg sspm3:sspm0 bit0 shift clock ss control enable edge select clock select tmr2 output to sc prescaler 4, 16, 64 2 edge select 2 4 data to tx/rx in sspsr data direction bit 2 smp:cke sdi sdo ss sck
pic17c7xx ds30289b-page 138 ? 2000 microchip technology inc. 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. buffer full bit, bf (sspstat<0>), indicates when sspbuf has been loaded with the received data (transmission is complete). when the sspbuf is read, bit bf 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 com- pleted. the sspbuf must be read and/or written. 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. example 15-1 shows the loading of the sspbuf (sspsr) for data transmission. example 15-1: loading the sspbuf (sspsr) register the sspsr is not directly readable, or writable and can only be accessed by addressing the sspbuf reg- ister. additionally, the mssp status register (sspstat) indicates the various status conditions. 15.1.2 enabling spi i/o to enable the serial port, mssp enable bit, sspen (sspcon1<5>), must be set. to reset or reconfigure spi mode, clear bit sspen, re-initialize the sspcon registers and then set bit sspen. this configures the sdi, sdo, sck and ss pins as serial port pins. for the pins to behave as the serial port function, some must have their data direction bits (in the ddr register) appropriately programmed. that is:  sdi is automatically controlled by the spi module  sdo must have ddrb<7> cleared  sck (master mode) must have ddrb<6> cleared  sck (slave mode) must have ddrb<6> set  ss must have porta<2> set any serial port function that is not desired may be over- ridden by programming the corresponding data direc- tion (ddr) register to the opposite value. 15.1.3 typical connection figure 15-5 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 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 15-5: spi master/slave connection movlb 6 ; bank 6 loop btfss sspstat, bf ; has data been ; received ; (transmit ; complete)? goto loop ; no movpf sspbuf, rxdata ; save in user ram movfp txdata, sspbuf ; new data to xmit serial input buffer (sspbuf) shift register (sspsr) msb lsb sdo sdi processor 1 sck spi master sspm3:sspm0 = 00 xxb serial input buffer (sspbuf) shift register (sspsr) lsb msb sdi sdo processor 2 sck spi slave sspm3:sspm0 = 010 xb serial clock
? 2000 microchip technology inc. ds30289b-page 139 pic17c7xx 15.1.4 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 15-5) is to broad- cast 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). this could be useful in receiver applications as a ? line activity monitor ? mode. the clock polarity is selected by appropriately program- ming bit ckp (sspcon1<4>). this then, would give waveforms for spi communication as shown in figure 15-6, figure 15-8 and figure 15-9, 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 this allows a maximum bit clock frequency (at 33 mhz) of 8.25 mhz. figure 15-6 shows the waveforms for master mode. when cke = 1, 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 15-6: 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 bit7 bit0 sdo bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit0 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 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 (cke = 0) (cke = 1) next q4 cycle after q2
pic17c7xx ds30289b-page 140 ? 2000 microchip technology inc. 15.1.5 slave mode in slave mode, the data is transmitted and received as the external clock pulses appear on sck. when the last bit is latched, the interrupt flag bit sspif (pir2<7>) is set. 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. when a byte is received, the device will wake-up from sleep. 15.1.6 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> = 04h). the pin must not be driven low for the ss pin to function as an input. the ra2 data latch must be high. 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 mid- dle of a transmitted byte and becomes a floating output. external pull-up/pull-down resistors may be desirable, depending on the application. 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. to emulate two-wire communication, the sdo pin can be connected to the sdi pin. when the spi needs to operate as a receiver, the sdo pin can be configured as an input. this disables transmissions from the sdo. the sdi can always be left as an input (sdi function), since it cannot create a bus conflict. figure 15-7: slave synchronization waveform note 1: when the spi is in slave mode with ss pin control enabled (sspcon<3:0> = 0100 ), the spi module will reset if the ss pin is set to v dd . 2: if the spi is used in slave mode with cke = ? 1 ? , then the ss pin control must be enabled. sck (ckp = 1 sck (ckp = 0 input sample sdi bit7 sdo bit7 bit6 bit7 sspif interrupt (smp = 0) cke = 0) cke = 0) (smp = 0) write to sspbuf sspsr to sspbuf ss flag bit0 bit7 bit0 next q4 cycle after q2
? 2000 microchip technology inc. ds30289b-page 141 pic17c7xx figure 15-8: spi mode waveform (slave mode with cke = 0) figure 15-9: spi mode waveform (slave mode with cke = 1) sck (ckp = 1 sck (ckp = 0 input sample sdi bit7 bit0 sdo bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sspif interrupt (smp = 0) cke = 0) cke = 0) (smp = 0) write to sspbuf sspsr to sspbuf ss flag optional next q4 cycle after q2 sck (ckp = 1 sck (ckp = 0 input sample sdi bit7 bit0 sdo bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sspif interrupt (smp = 0) cke = 1) cke = 1) (smp = 0) write to sspbuf sspsr to sspbuf ss flag not optional next q4 cycle after q2
pic17c7xx ds30289b-page 142 ? 2000 microchip technology inc. 15.1.7 sleep operation in master mode, all module clocks are halted, and the transmission/reception will remain in that state until the device wakes from sleep. after the device returns to normal mode, the module will continue to transmit/ receive data. in slave mode, the spi transmit/receive shift register operates asynchronously to the device. this allows the device to be placed in sleep mode and data to be shifted into the spi transmit/receive shift register. when all 8-bits have been received, the mssp inter- rupt flag bit will be set and if enabled, will wake the device from sleep. 15.1.8 effects of a reset a reset disables the mssp module and terminates the current transfer. table 15-1: registers associated with spi operation address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 por, bor mclr , wdt 07h, unbanked intsta peif t0ckif t0if intf peie t0ckie t0ie inte 0000 0000 0000 0000 10h, bank 4 pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0010 000- 0010 11h, bank 4 pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 14h, bank 6 sspbuf synchronous serial port receive buffer/transmit register xxxx xxxx uuuu uuuu 11h, bank 6 sspcon1 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 13h, bank 6 sspstat smp cke d/a p s r/w ua bf 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. shaded cells are not used by the ssp in spi mode.
? 2000 microchip technology inc. ds30289b-page 143 pic17c7xx 15.2 mssp i 2 c operation the mssp module in i 2 c mode fully implements all master and slave functions (including general call sup- port) and provides interrupts on start and stop bits in hardware to determine a free bus (multi-master func- tion). the mssp module implements the standard mode specifications as well as 7-bit and 10-bit addressing. refer to application note an578, ?use of the ssp module in the i 2 c multi-master environment.? a ?glitch? filter is on the scl and sda pins when the pin is an input. this filter operates in both the 100 khz and 400 khz modes. in the 100 khz mode, when these pins are an output, there is a slew rate control of the pin that is independent of device frequency. figure 15-10: i 2 c slave mode block diagram figure 15-11: i 2 c master mode block diagram two pins are used for data transfer. these are the scl pin, which is the clock and the sda pin, which is the data. the sda and scl pins are automatically config- ured when the i 2 c mode is enabled. the ssp module functions are enabled by setting ssp enable bit sspen (sspcon1<5>). the mssp module has six registers for i 2 c operation. these are the:  ssp control register1 (sspcon1)  ssp control register2 (sspcon2)  ssp status register (sspstat)  serial receive/transmit buffer (sspbuf)  ssp shift register (sspsr) - not directly acces- sible  ssp address register (sspadd) the sspcon1 register allows control of the i 2 c oper- ation. four mode selection bits (sspcon1<3:0>) allow one of the following i 2 c modes to be selected: i 2 c slave mode (7-bit address) i 2 c slave mode (10-bit address) i 2 c master mode, clock = osc/4 (sspadd +1) before selecting any i 2 c mode, the scl and sda pins must be programmed to inputs by setting the appropri- ate ddr bits. selecting an i 2 c mode, by setting the sspen bit, enables the scl and sda pins to be used as the clock and data lines in i 2 c mode. 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 shift clock msb lsb sda read write sspsr reg match detect sspadd reg start and stop bit detect/generate sspbuf reg internal data bus addr match set/clear s bit clear/set p, bit (sspstat reg) scl shift clock msb lsb sda baud rate generator 7 sspadd<6:0> and and set sspif
pic17c7xx ds30289b-page 144 ? 2000 microchip technology inc. the sspstat register gives the status of the data transfer. this information includes detection of a start or stop bit, specifies if the received byte was data or address if the next byte is the completion of 10-bit address and if this will be a read or write data transfer. the sspbuf is the register to which transfer data is written to or read from. the sspsr register shifts the data in or out of the device. in receive operations, the sspbuf and sspsr create a doubled buffered receiver. this allows reception of the next byte to begin before reading the last byte of received data. when the complete byte is received, it is transferred to the sspbuf register and flag bit sspif is set. if another complete byte is received before the sspbuf register is read, a receiver overflow has occurred and bit sspov (sspcon1<6>) is set and the byte in the sspsr is lost. the sspadd register holds the slave address. in 10-bit mode, the user needs to write the high byte of the address ( 1111 0 a9 a8 0 ). following the high byte address match, the low byte of the address needs to be loaded (a7:a0). 15.2.1 slave mode in slave mode, the scl and sda pins must be config- ured as inputs. the mssp module will override the input state with the output data when required (slave- transmitter). when an address is matched or the data transfer after an address match is received, the hardware automati- cally will generate the acknowledge (ack ) pulse and then load the sspbuf register with the received value currently in the sspsr register. there are certain conditions that will cause the mssp module not to give this ack pulse. these are if either (or both): a) the buffer full bit bf (sspstat<0>) was set before the transfer was received. b) the overflow bit sspov (sspcon1<6>) was set before the transfer was received. if the bf bit is set, the sspsr register value is not loaded into the sspbuf, but bit sspif and sspov are set. table 15-2 shows what happens when a data transfer byte is received, given the status of bits bf and sspov. the shaded cells show the condition where user software did not properly clear the overflow condi- tion. flag bit bf is cleared by reading the sspbuf reg- ister, while bit sspov is cleared through software. the scl clock input must have a minimum high and low time for proper operation. the high and low times of the i 2 c specification, as well as the requirement of the mssp module, are shown in timing parameter #100 and parameter #101 of the electrical specifications.
? 2000 microchip technology inc. ds30289b-page 145 pic17c7xx 15.2.1.1 addressing once the mssp module has been enabled, it waits for a start condition to occur. following the start con- dition, the 8-bits are shifted into the sspsr register. all incoming bits are sampled with the rising edge of the clock (scl) line. the value of register sspsr<7:1> is compared to the value of the sspadd register. the address is compared on the falling edge of the eighth clock (scl) pulse. if the addresses match and the bf and sspov bits are clear, the following events occur: a) the sspsr register value is loaded into the sspbuf register on the falling edge of the 8th scl pulse. b) the buffer full bit, bf, is set on the falling edge of the 8th scl pulse. c) an ack pulse is generated. d) ssp interrupt flag bit, sspif (pir2<7>), is set (interrupt is generated if enabled) - on the falling edge of the 9th scl pulse. in 10-bit address mode, two address bytes need to be received by the slave. the five most significant bits (msbs) of the first address byte specify if this is a 10-bit address. bit r/w (sspstat<2>) must specify a write so the slave device will receive the second address byte. for a 10-bit address, the first byte would equal ? 1111 0 a9 a8 0 ? , where a9 and a8 are the two msbs of the address. the sequence of events for a 10-bit address is as follows, with steps 7- 9 for slave-transmitter: 1. receive first (high) byte of address (bits sspif, bf and bit ua (sspstat<1>) are set). 2. update the sspadd register with second (low) byte of address (clears bit ua and releases the scl line). 3. read the sspbuf register (clears bit bf) and clear flag bit sspif. 4. receive second (low) byte of address (bits sspif, bf and ua are set). 5. update the sspadd register with the first (high) byte of address. this will clear bit ua and release the scl line. 6. read the sspbuf register (clears bit bf) and clear flag bit sspif. 7. receive repeated start condition. 8. receive first (high) byte of address (bits sspif and bf are set). 9. read the sspbuf register (clears bit bf) and clear flag bit sspif. 15.2.1.2 slave reception when the r/w bit of the address byte is clear and an address match occurs, the r/w bit of the sspstat register is cleared. the received address is loaded into the sspbuf register. when the address byte overflow condition exists, then no acknowledge (ack ) pulse is given. an overflow con- dition is defined as either bit bf (sspstat<0>) is set, or bit sspov (sspcon1<6>) is set. an ssp interrupt is generated for each data transfer byte. flag bit sspif (pir2<7>) must be cleared in soft- ware. the sspstat register is used to determine the status of the received byte. table 15-2: data transfer received byte actions note: following the repeated start condition (step 7) in 10-bit mode, the user only needs to match the first 7-bit address. the user does not update the sspadd for the second half of the address. note: the sspbuf will be loaded if the sspov bit is set and the bf flag is cleared. if a read of the sspbuf was performed, but the user did not clear the state of the sspov bit before the next receive occurred, the ack is not sent and the ssp- buf is updated. status bits as data transfer is received sspsr sspbuf generate ack pulse set bit sspif (ssp interrupt occurs if enabled) bf sspov 00 yes yes yes 10 no no yes 11 no no yes 0 1 yes no yes note 1: shaded cells show the conditions where the user software did not properly clear the overflow condition.
pic17c7xx ds30289b-page 146 ? 2000 microchip technology inc. 15.2.1.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. the ack pulse will be sent on the ninth bit, and the scl pin is held low. the transmit data must be loaded into the sspbuf register, which also loads the sspsr register. then scl pin should be enabled by setting bit ckp (sspcon1<4>). the master must monitor the scl pin prior to asserting another clock pulse. the slave devices may be holding off the master by stretching the clock. the eight data bits are shifted out on the falling edge of the scl input. this ensures that the sda sig- nal is valid during the scl high time (figure 15-13). an ssp interrupt is generated for each data transfer byte. the sspif flag bit must be cleared in software, and the sspstat register is used to determine the sta- tus of the byte transfer. the sspif flag bit is set on the falling edge of the ninth clock pulse. as a slave-transmitter, the ack pulse from the master- receiver is latched on the rising edge of the ninth scl input pulse. if the sda line was high (not ack ), then the data transfer is complete. when the not ack is latched by the slave, the slave logic is reset and the slave then monitors for another occurrence of the start bit. if the sda line was low (ack ), the transmit data must be loaded into the sspbuf register, which also loads the sspsr register. then, the scl pin should be enabled by setting the ckp bit. figure 15-12: i 2 c waveforms for reception (7-bit address) figure 15-13: i 2 c waveforms for transmission (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 56 7 89 123 4 bus master term ina tes transfer bit sspov is set because the sspbuf register is still full. cleared in software sspbuf register is read ack receiving data receiving data d0 d1 d2 d3 d4 d5 d6 d7 ack r/w = 0 receiving address sspif bf (sspstat<0>) sspov (sspcon1<6>) ack ack is not sent. not sda scl sspif bf (sspstat<0>) ckp (sspcon1<4>) a7 a6 a5 a4 a3 a2 a1 ack d7 d6 d5 d4 d3 d2 d1 d0 not ack transmitting data r/w = 1 receiving address 123456789 123456789 p cleared in software sspbuf is written in software from ssp interrupt service routine set bit after writing to sspbuf s data in sampled scl held low while cpu responds to sspif (the sspbuf must be written to before the ckp bit can be set) r/w = 0
? 2000 microchip technology inc. ds30289b-page 147 pic17c7xx figure 15-14: i 2 c slave-transmitter (10-bit address) sda scl sspif bf (sspstat<0>) s 1 234 56 7 89 1 2345 67 89 1 2345 7 89 p 1 111 0a9a8 a7 a6a5a4a3a2a1a0 11110 a8 r/w =1 ack ack r/w = 0 ack receive first byte of address cleared in software master sends nack a9 6 (pir1<3>) receive second byte of address cleared by hardware when sspadd is updated. ua (sspstat<1>) clock is held low until update of sspadd has taken place ua is set indicating that the sspadd needs to be updated ua is set indicating that sspadd needs to be updated cleared by hardware when sspadd is updated. sspbuf is written with contents of sspsr dummy read of sspbuf to clear bf flag receive first byte of address 12345 789 d7 d6 d5 d4 d3 d1 ack d2 6 transmitting data byte d0 dummy read of sspbuf to clear bf flag sr cleared in software write of sspbuf initiates transmit cleared in software transmit is complete ckp has to be set for clock to be released bus master terminates transfer
pic17c7xx ds30289b-page 148 ? 2000 microchip technology inc. figure 15-15: i 2 c slave-receiver (10-bit address) sda scl sspif bf (sspstat<0>) s 1 234 56 7 89 1 2345 67 89 1 2345 7 89 p 1 1 1 1 0 a9a8 a7 a6 a5a4a3a2a1 a0 d7d6d5d4d3 d1d0 receive data byte ack r/w = 0 ack receive first byte of address cleared in software bus master terminates transfer d2 6 (pir1<3>) receive second byte of address cleared by hardware when sspadd is updated with low byte of address. ua (sspstat<1>) clock is held low until update of sspadd has taken place ua is set indicating that the sspadd needs to be updated ua is set indicating that sspadd needs to be updated sspbuf is written with contents of sspsr dummy read of sspbuf to clear bf flag ack r/w = 1 cleared in software dummy read of sspbuf to clear bf flag read of sspbuf clears bf flag cleared by hardware when sspadd is updated with high byte of address.
? 2000 microchip technology inc. ds30289b-page 149 pic17c7xx 15.2.2 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. 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 one of eight addresses reserved for specific purposes by the i 2 c protocol. it consists of all 0 ? s with r/w = 0. the general call address is recognized when the gen- eral call enable bit (gcen) is enabled (sspcon2<7> is set). following a start bit detect, 8-bits are shifted into sspsr and the address is compared against sspadd and is also compared to the general call address, fixed in hardware. if the general call address matches, the sspsr is transferred to the sspbuf, the bf flag is set (eighth bit) and on the falling edge of the ninth bit (ack bit), the sspif flag is set. when the interrupt is serviced, the source for the inter- rupt can be checked by reading the contents of the sspbuf to determine if the address was device spe- cific, or a general call address. in 10-bit mode, the sspadd is required to be updated for the second half of the address to match and the ua bit is set (sspstat<1>). if the general call address is sampled when gcen is set, while the slave is config- ured in 10-bit address mode, then the second half of the address is not necessary, the ua bit will not be set and the slave will begin receiving data after the acknowledge (figure 15-16). figure 15-16: slave mode general call address sequence (7 or 10-bit mode) sda scl s sspif bf (sspstat<0>) sspov (sspcon1<6>) cleared in software sspbuf is read r/w = 0 ack general call address address is compared to general call address gcen (sspcon2<7>) receiving data ack 123456789123456789 d7 d6 d5 d4 d3 d2 d1 d0 after ack , set interrupt ? 0 ? ? 1 ?
pic17c7xx ds30289b-page 150 ? 2000 microchip technology inc. 15.2.3 sleep operation while in sleep mode, the i 2 c module can receive addresses or data and when an address match or com- plete byte transfer occurs, wake the processor from sleep (if the ssp interrupt is enabled). 15.2.4 effects of a reset a reset disables the ssp module and terminates the current transfer. table 15-3: registers associated with i 2 c operation address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 por, bor mclr , wdt 07h, unbanked intsta peif t0ckif t0if intf peie t0ckie t0ie inte 0000 0000 0000 0000 10h, bank 4 pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0000 000- 0000 11h, bank 4 pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 10h. bank 6 sspadd synchronous serial port (i 2 c mode) address register 0000 0000 0000 0000 14h, bank 6 sspbuf synchronous serial port receive buffer/transmit register xxxx xxxx uuuu uuuu 11h, bank 6 sspcon1 wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 0000 0000 0000 12h, bank 6 sspcon2 gcen ackstat ackdt acken rcen pen rsen sen 0000 0000 0000 0000 13h, bank 6 sspstat smp cke d/a psr/w ua bf 0000 0000 0000 0000 legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. shaded cells are not used by the ssp in i 2 c mode.
? 2000 microchip technology inc. ds30289b-page 151 pic17c7xx 15.2.5 master mode master mode of operation is supported by interrupt generation on the detection of the start and stop conditions. 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, with both the s and p bits clear. in master mode, the scl and sda lines are manipu- lated by the mssp hardware. the following events will cause ssp interrupt flag bit, sspif, to be set (ssp interrupt if enabled):  start condition  stop condition  data transfer byte transmitted/received  acknowledge transmit  repeated start figure 15-17: ssp block diagram (i 2 c master mode) read write sspsr start bit, stop bit, sspbuf internal data bus set/reset, s, p, wcol (sspstat) shift clock msb lsb sda acknowledge generate scl scl in bus collision sda in receive enable clock cntl clock arbitrate/wcol detect (hold off clock source) sspadd<6:0> baud set sspif, bclif reset ackstat, pen (sspcon2) rate generator sspm3:sspm0 start bit detect, stop bit detect write collision detect clock arbitration state counter for end of xmit/rcv
pic17c7xx ds30289b-page 152 ? 2000 microchip technology inc. 15.2.6 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 bit p (sspstat<4>) 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 moni- tored for arbitration, to see if the signal level is the expected output level. this check is performed in hard- ware, 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 15.2.7 i 2 c master mode support master mode is enabled by setting and clearing the appropriate sspm bits in sspcon1 and by setting the sspen bit. once master mode is enabled, the user has six options.  assert a start condition on sda and scl.  assert a repeated start condition on sda and scl.  write to the sspbuf register initiating transmission of data/address.  generate a stop condition on sda and scl.  configure the i 2 c port to receive data.  generate an acknowledge condition at the end of a received byte of data. 15.2.7.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 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 transmitted. start and stop conditions indicate the beginning and end of transmission. the baud rate generator used for spi mode operation is now used to set the scl clock frequency for either 100 khz, 400 khz, or 1 mhz i 2 c operation. the baud rate generator reload value is contained in the lower 7 bits of the sspadd register. the baud rate generator will automatically begin counting on a write to the ssp- buf. once the given operation is complete (i.e., trans- mission of the last data bit is followed by ack), the internal clock will automatically stop counting and the scl pin will remain in its last state note: the mssp module, when configured in i 2 c master mode, does not allow queueing 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 condition 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.
? 2000 microchip technology inc. ds30289b-page 153 pic17c7xx a typical transmit sequence would go as follows: a) the user generates a start condition by set- ting the start enable bit (sen) in sspcon2. b) sspif is set. the module will wait the required start time before any other operation takes place. c) the user loads the sspbuf with address to transmit. d) address is shifted out the sda pin until all 8 bits are transmitted. e) the mssp module shifts in the ack bit from the slave device and writes its value into the sspcon2 register (sspcon2<6>). f) the module generates an interrupt at the end of the ninth clock cycle by setting sspif. g) the user loads the sspbuf with eight bits of data. h) data is shifted out the sda pin until all 8 bits are transmitted. i) the mssp module shifts in the ack bit from the slave device, and writes its value into the sspcon2 register (sspcon2<6>). j) the mssp module generates an interrupt at the end of the ninth clock cycle by setting the sspif bit. k) the user generates a stop condition by setting the stop enable bit pen in sspcon2. l) interrupt is generated once the stop condition is complete. 15.2.8 baud rate generator in i 2 c master mode, the reload value for the brg is located in the lower 7 bits of the sspadd register (figure 15-18). when the brg is loaded with this value, the brg counts down to 0 and stops until another reload has taken place. the brg count is dec- remented twice per instruction cycle (t cy ), on the q2 and q4 clock. in i 2 c master mode, the brg is reloaded automatically. if clock arbitration is taking place, for instance, the brg will be reloaded when the scl pin is sampled high (figure 15-19). figure 15-18: baud rate generator block diagram figure 15-19: baud rate generator timing with clock arbitration sspm3:sspm0 brg down counter clkout f osc /4 sspadd<6:0> sspm3:sspm0 scl reload control reload sda scl scl de-asserted 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).
pic17c7xx ds30289b-page 154 ? 2000 microchip technology inc. 15.2.9 i 2 c master mode start condition timing to initiate a start condition, the user sets the start condition enable bit, sen (sspcon2<0>). if the sda and scl pins are sampled high, the baud rate genera- tor is reloaded with the contents of sspadd<6: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 (sspstat<3>) to be set. follow- ing this, the baud rate generator is reloaded with the contents of sspadd<6:0> and resumes its count. when the baud rate generator times out (t brg ), the sen bit (sspcon2<0>) will be automatically cleared by hardware, the baud rate generator is suspended, leaving the sda line held low and the start condition is complete. 15.2.9.1 wcol status flag if the user writes the sspbuf when a start sequence is in progress, then wcol is set and the contents of the buffer are unchanged (the write doesn ? t occur). figure 15-20: first start bit timing note: if at the beginning of start condition, the sda and scl pins are already sampled 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. note: because queueing of events is not allowed, writing to the lower 5 bits of sspcon2 is disabled until the start condition is complete. 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.
? 2000 microchip technology inc. ds30289b-page 155 pic17c7xx figure 15-21: start condition flow chart idle mode sen (sspcon2<0> = 1) bus collision detected, set bclif, sda = 1? load brg with yes brg rollover? force sda = 0, load brg with sspadd<6:0>, no yes force scl = 0, clear sen set s bit. sspadd<6:0> scl = 1? sda = 0? no ye s brg rollover? no clear sen start condition done, no yes reset brg scl= 0? no yes scl = 0? no yes reset brg release scl, sspen = 1, sspcon1<3:0> = 1000 and set sspif
pic17c7xx ds30289b-page 156 ? 2000 microchip technology inc. 15.2.10 i 2 c master mode repeated start condition timing a repeated start condition occurs when the rsen bit (sspcon2<1>) is programmed high and the i 2 c mod- ule is in the idle state. 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 with the contents of sspadd<6:0> 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 de-asserted (brought high). when scl is sampled high the baud rate generator is reloaded with the contents of sspadd<6:0> 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 is low) for one t brg while scl is high. following this, the rsen bit in the sspcon2 register will be automatically cleared and the baud rate generator is not reloaded, leaving the sda pin held low. as soon as a start con- dition is detected on the sda and scl pins, the s bit (sspstat<3>) will be set. the sspif bit will not be set until the baud rate generator has timed out. immediately following the sspif bit getting set, the user may write the sspbuf with the 7-bit address in 7- bit mode, or the default first address in 10-bit mode. after the first eight bits are transmitted and an ack is received, the user may then transmit an additional eight bits of address (10-bit mode), or eight bits of data (7-bit mode). 15.2.10.1 wcol status flag if the user writes the sspbuf when a repeated start sequence is in progress, then wcol is set and the contents of the buffer are unchanged (the write doesn ? t occur). figure 15-22: repeat start condition waveform note 1: if the 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 ? . note: because queueing of events is not allowed, writing of the lower 5 bits of sspcon2 is disabled until the repeated start condition is complete. sda scl sr = repeated start write to sspcon2 write to sspbuf occurs here falling edge of ninth clock end of xmit at completion of start bit, hardware clear rsen bit 1st bit set s (sspstat<3>) t brg t brg sda = 1, sda = 1, scl (no change) scl = 1 occurs here. t brg t brg t brg and set sspif
? 2000 microchip technology inc. ds30289b-page 157 pic17c7xx figure 15-23: repeated start condition flow chart (page 1) idle mode, sspen = 1, force scl = 0 scl = 0? release sda, load brg with scl = 1? no yes no yes brg no yes release scl sspcon1<3:0> = 1000 rollover? sspadd<6:0> load brg with sspadd<6:0> (clock arbitration) a b c sda = 1? no yes start rsen = 1 bus collision, set bclif, release sda, clear rsen
pic17c7xx ds30289b-page 158 ? 2000 microchip technology inc. figure 15-24: repeated start condition flow chart (page 2) force sda = 0, load brg with sspadd<6:0> ye s repeated start clear rsen, ye s brg rollover? brg rollover? ye s sda = 0? no scl = 1? no b set s c a no no yes force scl = 0, reset brg set sspif. scl = ? 0 ? ? reset brg no ye s condition done,
? 2000 microchip technology inc. ds30289b-page 159 pic17c7xx 15.2.11 i 2 c master mode transmission transmission of a data byte, a 7-bit address, or either half of a 10-bit address, is accomplished by simply writ- ing a value to sspbuf register. this action will set the buffer full flag (bf) and allow the baud rate generator to begin counting and start the next transmission. each bit of address/data will be shifted out onto the sda pin after the falling edge of scl is asserted (see data hold time spec). scl is held low for one baud rate generator roll over count (t brg ). data should be valid before scl is released high (see data setup time spec). 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, allowing the slave device being addressed to respond with an ack bit during the ninth bit time, if an address match occurs or if data was received properly. the status of ack is read into the ackdt on the falling edge of the ninth clock. if the master receives an acknowledge, the acknowledge status bit (akstat) is cleared. if not, the bit is set. after the ninth clock, the sspif 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 15-26). after the write to the sspbuf, each bit of 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 fall- ing edge of the eighth clock, the master will de-assert 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 (sspcon2<6>). following the falling edge of the ninth clock transmis- sion 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, holding scl low and allowing sda to float. 15.2.11.1 bf status flag in transmit mode, the bf bit (sspstat<0>) is set when the cpu writes to sspbuf and is cleared when all 8 bits are shifted out. 15.2.11.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), then wcol is set and the contents of the buffer are unchanged (the write doesn ? t occur). wcol must be cleared in software. 15.2.11.3 akstat status flag in transmit mode, the akstat bit (sspcon2<6>) is cleared when the slave has sent an acknowledge (ack = 0) and is set when the slave does not acknowledge (ack = 1). a slave sends an acknowledge when it has recognized its address (including a general call), or when the slave has properly received its data.
pic17c7xx ds30289b-page 160 ? 2000 microchip technology inc. figure 15-25: master transmit flow chart idle mode num_clocks = 0, release sda so slave can drive ack, num_clocks load brg with sda = current data bit yes brg rollover? no brg no ye s force scl = 0 = 8? ye s no ye s brg rollover? no force scl = 1, stop brg scl = 1? load brg with count high time rollover? no read sda and place into ackstat bit (sspcon2<6>) force scl = 0, scl = 1? sda = data bit? no yes yes rollover? no yes stop brg, force scl = 1 (clock arbitration) (clock arbitration) num_clocks = num_clocks + 1 bus collision detected set bclif, hold prescale off, ye s no bf = 1 force bf = 0 sspadd<6:0>, start brg count, load brg with sspadd<6:0>, start brg count sspadd<6:0>, load brg with count scl high time sspadd<6:0>, sda = data bit? yes no clear xmit enable scl = 0? no yes reset brg write sspbuf set sspif
? 2000 microchip technology inc. ds30289b-page 161 pic17c7xx figure 15-26: i 2 c master mode timing (transmission, 7 or 10-bit address) sda scl sspif bf (sspstat<0>) sen a7 a6 a5 a4 a3 a2 a1 ack = 0 d7d6d5d4d3d2d1d0 ack transmitting data or second half r/w = 0 transmit address to slave 123456789 123456789 p cleared in software service routine sspbuf is written in 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 in software sspbuf written pen cleared in software r/w
pic17c7xx ds30289b-page 162 ? 2000 microchip technology inc. 15.2.12 i 2 c master mode reception master mode reception is enabled by programming the receive enable bit, rcen (sspcon2<3>). 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 contents of the sspsr are loaded into the sspbuf, the bf flag is set, the sspif is set and the baud rate generator is sus- pended from counting, holding scl low. the ssp is now in idle state, awaiting the next command. when the buffer is read by the cpu, the bf flag is automati- cally cleared. the user can then send an acknowledge bit at the end of reception, by setting the acknowledge sequence enable bit, acken (sspcon2<4>). 15.2.12.1 bf status flag in receive operation, bf is set when an address or data byte is loaded into sspbuf from sspsr. it is cleared when sspbuf is read. 15.2.12.2 sspov status flag in receive operation, sspov is set when 8 bits are received into the sspsr, and the bf flag is already set from a previous reception. 15.2.12.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), then wcol is set and the contents of the buffer are unchanged (the write doesn ? t occur). note: the ssp module must be in an idle state before the rcen bit is set, or the rcen bit will be disregarded.
? 2000 microchip technology inc. ds30289b-page 163 pic17c7xx figure 15-27: master receiver flow chart idle mode num_clocks = 0, release sda force scl=0, yes no brg rollover? release scl yes no scl = 1? load brg with yes no brg rollover? (clock arbitration) load brg w/ start count sspadd<6:0>, start count. sample sda, shift data into sspsr num_clocks = num_clocks + 1 ye s num_clocks = 8? no force scl = 0, set sspif, set bf. move contents of sspsr into sspbuf, clear rcen. rcen = 1 sspadd<6:0>, scl = 0? ye s no
pic17c7xx ds30289b-page 164 ? 2000 microchip technology inc. figure 15-28: i 2 c master mode timing (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 = 1 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 in software start xmit sen = 0 sspov sda = 0, scl = 1 while cpu (sspstat<0>) ack last bit is shifted into sspsr and contents are unloaded into sspbuf cleared in software cleared in 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 in software sda = ackdt = 0
? 2000 microchip technology inc. ds30289b-page 165 pic17c7xx 15.2.13 acknowledge sequence timing an acknowledge sequence is enabled by setting the acknowledge sequence enable bit, acken (sspcon2<4>). when this bit is set, the scl pin is pulled low and the contents of the acknowledge data bit is 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 de-asserted (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 ssp module then goes into idle mode (figure 15-29). 15.2.13.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). figure 15-29: acknowledge sequence waveform note: t brg = one baud rate generator period. sda scl set sspif at the end acknowledge sequence starts here, write to sspcon2 acken automatically cleared cleared in of receive ack 8 acken = 1, ackdt = 0 d0 9 sspif software set sspif at the end of acknowledge sequence cleared in software t brg t brg
pic17c7xx ds30289b-page 166 ? 2000 microchip technology inc. figure 15-30: acknowledge flow chart idle mode force scl = 0 yes no scl = 0? drive ackdt bit ye s no brg rollover? (sspcon2<5>) onto sda pin, load brg with sspadd<6:0>, start count. force scl = 1 yes no scl = 1? no ackdt = 1? load brg with no brg rollover? sspadd <6:0>, start count. no sda = 1? bus collision detected, set bclif, ye s force scl = 0, (clock arbitration) clear acken no scl = 0? reset brg clear acken set acken release scl, ye s yes ye s set sspif
? 2000 microchip technology inc. ds30289b-page 167 pic17c7xx 15.2.14 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 (sspcon2<2>). 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 sam- pled 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 de-asserted. when the sda pin is sampled high while scl is high, the p bit (sspstat<4>) is set. a t brg later, the pen bit is cleared and the sspif bit is set (figure 15-31). whenever the firmware decides to take control of the bus, it will first determine if the bus is busy by checking the s and p bits in the sspstat register. if the bus is busy, then the cpu can be interrupted (notified) when a stop bit is detected (i.e., bus is free). 15.2.14.1 wcol status flag if the user writes the sspbuf when a stop sequence is in progress, then wcol is set and the contents of the buffer are unchanged (the write doesn ? t occur). figure 15-31: stop condition receive or transmit mode 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.
pic17c7xx ds30289b-page 168 ? 2000 microchip technology inc. figure 15-32: stop condition flow chart idle mode, sspen = 1, force sda = 0 scl doesn ? t change sda = 0? de-assert scl, scl = 1 scl = 1? no ye s start brg no yes brg sda going from 0 to 1 while scl = 1 no yes set sspif, release sda, start brg stop condition done, sspcon1<3:0> = 1000 rollover? no brg rollover? yes p bit set? no ye s bus collision detected, set bclif, clear pen start brg no ye s brg rollover? (clock arbitration) pen = 1 pen cleared
? 2000 microchip technology inc. ds30289b-page 169 pic17c7xx 15.2.15 clock arbitration clock arbitration occurs when the master, during any receive, transmit, or repeated start/stop condition, de- asserts 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<6: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 15-33). 15.2.16 sleep operation while in sleep mode, the i 2 c module can receive addresses or data and when an address match or com- plete byte transfer occurs, wake the processor from sleep (if the ssp interrupt is enabled). 15.2.17 effects of a reset a reset disables the ssp module and terminates the current transfer. figure 15-33: clock arbitration timing in master transmit mode scl sda brg overflow, release scl, if scl = 1 load brg with sspadd<6:0>, and start count brg overflow occurs, release scl, slave device holds scl low. scl = 1 brg starts counting clock high interval. scl line sampled once every machine cycle (t osc ? 4). hold off brg until scl is sampled high. t brg t brg t brg to measure high time interval.
pic17c7xx ds30289b-page 170 ? 2000 microchip technology inc. 15.2.18 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 = ? 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 15-34). 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 de-asserted and the sspbuf can be written to. when the user ser- vices the bus collision interrupt service routine and if the i 2 c bus is free, the user can resume communica- tion by asserting a start condition. if a start, repeated start, stop, or acknowledge condition was in progress when the bus collision occurred, the condition is aborted, the sda and scl lines are de-asserted and the respective control bits in the sspcon2 register are cleared. when the user services the bus collision interrupt service routine, and if the i 2 c bus is free, the user can resume commu- nication by asserting a start condition. the master will continue to monitor the sda and scl pins and 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 trans- mitter left off when bus collision occurred. in multi-master mode, the interrupt generation on the detection of start and stop conditions allows the determination of when the bus is free. control of the i 2 c bus can be taken when the p bit is set in the ssp- stat register, or the bus is idle and the s and p bits are cleared. figure 15-34: 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. by the master. by master. data changes while scl = 0.
? 2000 microchip technology inc. ds30289b-page 171 pic17c7xx 15.2.18.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 15-35). b) scl is sampled low before sda is asserted low (figure 15-36). 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: the start condition is aborted, and the bclif flag is set, and the ssp module is reset to its idle state (figure 15-35). the start condition begins with the sda and scl pins de-asserted. when the sda pin is sampled high, the baud rate generator is loaded from sspadd<6:0> and counts down to ? 0 ? . if the scl pin is sampled low while sda is high, a bus collision 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 15-37). 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 0 and during this time, if the scl pin is sampled as '0', a bus collision does not occur. at the end of the brg count, the scl pin is asserted low. figure 15-35: 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 collision because the two masters must be allowed to arbitrate the first address follow- ing the start condition and 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 in software. sspif and bclif are cleared in software. . set bclif, start condition. set bclif.
pic17c7xx ds30289b-page 172 ? 2000 microchip technology inc. figure 15-36: bus collision during start condition (scl = 0) figure 15-37: brg reset due to sda collision 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 interrupts cleared in software. bus collision occurs, set bclif. scl = 0 before brg time-out, ? 0 ? ? 0 ? ? 0 ? ? 0 ? sda scl sen set s set sen, enable start sequence if sda = 1, scl = 1. less than t brg t brg sda = 0, scl = 1 bclif s sspif s interrupts cleared in software. set sspif. sda = 0, scl = 1 sda pulled low by other master. reset brg and assert sda. scl pulled low after brg time-out. set sspif ? 0 ?
? 2000 microchip technology inc. ds30289b-page 173 pic17c7xx 15.2.18.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, indi- cating that another master is attempting to trans- mit a data ? 1 ? . when the user de-asserts sda and the pin is allowed to float high, the brg is loaded with sspadd<6:0> and counts down to ? 0 ? . the scl pin is then de- asserted and when sampled high, the sda pin is sam- pled. if sda is low, a bus collision has occurred (i.e., another master is attempting to transmit a data ? 0 ? ). if, however, sda is sampled high, then 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, however, scl goes from high to low before the brg times out and sda has not already been asserted, then a bus collision occurs. in this case, another master is attempting to transmit a data ? 1 ? during the repeated start condition. if, at the end of the brg time-out, both scl and sda are still high, the sda pin is driven low, 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 com- plete (figure 15-38). figure 15-38: bus collision during a repeated start condition (case 1) figure 15-39: bus collision during repeated 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 in software. ? 0 ? ? 0 ? ? 0 ? ? 0 ? sda scl bclif rsen s sspif interrupt cleared in software. scl goes low before sda, set bclif. release sda and scl. t brg t brg ? 0 ? ? 0 ? ? 0 ? ? 0 ?
pic17c7xx ds30289b-page 174 ? 2000 microchip technology inc. 15.2.18.3 bus collision during a stop condition bus collision occurs during a stop condition if: a) after the sda pin has been de-asserted and allowed to float high, sda is sampled low after the brg has timed out. b) after the scl pin is de-asserted, scl is sam- pled 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<6:0> 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'. 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 15-40). figure 15-40: bus collision during a stop condition (case 1) figure 15-41: 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 ? ? 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 ?
? 2000 microchip technology inc. ds30289b-page 175 pic17c7xx 15.3 connection considerations for i 2 c bus for standard mode i 2 c bus devices, the values of resistors r p r s in figure 15-42 depends on the follow- ing parameters:  supply voltage  bus capacitance  number of connected devices (input current + leakage current) the supply voltage limits the minimum value of resistor r p due to the specified minimum sink current of 3 ma at v ol max = 0.4v for the specified output stages. for example, with a supply voltage of v dd = 5v + 10% and v ol max = 0.4v at 3 ma, r p min = (5.5-0.4)/0.003 = 1.7 k ?. v dd as a function of r p is shown in figure 15- 42. the desired noise margin of 0.1 v dd for the low level, limits the maximum value of r s . series resistors are optional and used to improve esd susceptibility. the bus capacitance is the total capacitance of wire, connections and pins. this capacitance limits the max- imum value of r p due to the specified rise time (figure 15-42). the smp bit is the slew rate control enabled bit. this bit is in the sspstat register and controls the slew rate of the i/o pins when in i 2 c mode (master or slave). figure 15-42: sample device configuration for i 2 c bus r p r p v dd + 10% sda scl note: i 2 c devices with input levels related to v dd must have one common supply line to which the pull-up resistor is device c b = 10 - 400 pf r s r s also connected.
pic17c7xx ds30289b-page 176 ? 2000 microchip technology inc. 15.4 example program example 15-2 shows mplab ? c17 ? c ? code for using the i 2 c module in master mode to communicate with a 24lc01b serial eeprom. this example uses the picmicro ? ? c ? libraries included with mplab c17. example 15-2: interfacing to a 24lc01b serial eeprom (using mplab c17) // include necessary header files #include // processor header file #include // delay routines header file #include // standard library header file #include // i2c routines header file #define control 0xa0 // control byte definition for 24lc01b // function declarations void main(void); void writeportd(static unsigned char data); void bytewrite(static unsigned char address,static unsigned char data); unsigned char byteread(static unsigned char address); void ackpoll(void); // main program void main(void) { static unsigned char address; // i2c address of 24lc01b static unsigned char datao; // data written to 24lc01b static unsigned char datai; // data read from 24lc01b address = 0; // preset address to 0 openi2c(master,slew_on); // configure i2c module master mode, slew rate control on sspadd = 39; // configure clock for 100khz while(address<128) // loop 128 times, 24lc01b is 128x8 { datao = portb; do { bytewrite(address,datao); // write data to eeprom ackpoll(); // poll the 24lc01b for state datai = byteread(address); // read data from eeprom into sspbuf } while(datai != datao); // loop as long as data not correctly // written to 24lc01b address++; // increment address } while(1) // done writing 128 bytes to 24lc01b, loop forever { nop(); } }
? 2000 microchip technology inc. ds30289b-page 177 pic17c7xx // writes the byte data to 24lc01b at the specified address void bytewrite(static unsigned char address, static unsigned char data) { starti2c(); // send start bit idlei2c(); // wait for idle condition writei2c(control); // send control byte idlei2c(); // wait for idle condition if (!sspcon2bits.ackstat) // if 24lc01b acks { writei2c(address); // send control byte idlei2c(); // wait for idle condition if (!sspcon2bits.ackstat) // if 24lc01b acks writei2c(data); // send data } idlei2c(); // wait for idle condition stopi2c(); // send stop bit idlei2c(); // wait for idle condition return; } // reads a byte of data from 24lc01b at the specified address unsigned char byteread(static unsigned char address) { starti2c(); // send start bit idlei2c(); // wait for idle condition writei2c(control); // send control byte idlei2c(); // wait for idle condition if (!sspcon2bits.ackstat) // if the 24lc01b acks { writei2c(address); // send address idlei2c(); // wait for idle condition if (!sspcon2bits.ackstat) // if the 24lc01b acks { restarti2c(); // send restart idlei2c(); // wait for idle condition writei2c(control+1); // send control byte with r/w set idlei2c(); // wait for idle condition if (!sspcon2bits.ackstat) // if the 24lc01b acks { getci2c(); // read a byte of data from 24lc01b idlei2c(); // wait for idle condition notacki2c(); // send a nack to 24lc01b idlei2c(); // wait for idle condition stopi2c(); // send stop bit idlei2c(); // wait for idle condition } } } return(sspbuf); } example 15-2: interfacing to a 24lc01b serial eeprom (using mplab c17)
pic17c7xx ds30289b-page 178 ? 2000 microchip technology inc. void ackpoll(void) { starti2c(); // send start bit idlei2c(); // wait for idle condition writei2c(control); // send control byte idlei2c(); // wait for idle condition // poll the ack bit coming from the 24lc01b // loop as long as the 24lc01b nacks while (sspcon2bits.ackstat) { restarti2c(); // send a restart bit idlei2c(); // wait for idle condition writei2c(control); // send control byte idlei2c(); // wait for idle condition } idlei2c(); // wait for idle condition stopi2c(); // send stop bit idlei2c(); // wait for idle condition return; } example 15-2: interfacing to a 24lc01b serial eeprom (using mplab c17)
? 2000 microchip technology inc. ds30289b-page 179 pic17c7xx 16.0 analog-to-digital converter (a/d) module the analog-to-digital (a/d) converter module has twelve analog inputs for the pic17c75x devices and sixteen for the pic17c76x devices. the analog input charges a sample and hold capacitor. the output of the sample and hold capacitor is the input into the converter. the converter then generates a dig- ital result of this analog level via successive approxima- tion. this a/d conversion of the analog input signal, results in a corresponding 10-bit digital number. the analog reference voltages (positive and negative supply) are software selectable to either the device ? s supply voltages (av dd , avss), or the voltage level on the rg3/an0/v ref + and rg2/an1/v ref - pins. the a/d converter has a unique feature of being able to operate while the device is in sleep mode. to oper- ate in sleep, the a/d clock must be derived from the a/d ? s internal rc oscillator. the a/d module has four registers. these registers are:  a/d result high register (adresh)  a/d result low register (adresl)  a/d control register0 (adcon0)  a/d control register1 (adcon1) the adcon0 register, shown in register 16-1, con- trols the operation of the a/d module. the adcon1 register, shown in register 16-2, configures the func- tions of the port pins. the port pins can be configured as analog inputs (rg3 and rg2 can also be the volt- age references), or as digital i/o. register 16-1: adcon0 register (address: 14h, bank 5) r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 u-0 r/w-0 chs3 chs2 chs1 chs0 ? go/done ? adon bit 7 bit 0 bit 7-4 chs3:chs0 : analog channel select bits 0000 = channel 0, (an0) 0001 = channel 1, (an1) 0010 = channel 2, (an2) 0011 = channel 3, (an3) 0100 = channel 4, (an4) 0101 = channel 5, (an5) 0110 = channel 6, (an6) 0111 = channel 7, (an7) 1000 = channel 8, (an8) 1001 = channel 9, (an9) 1010 = channel 10, (an10) 1011 = channel 11, (an11) 1100 = channel 12, (an12) (pic17c76x only) 1101 = channel 13, (an13) (pic17c76x only) 1110 = channel 14, (an14) (pic17c76x only) 1111 = channel 15, (an15) (pic17c76x only) 11xx = reserved , do not select (pic17c75x only) bit 3 unimplemented : read as ? 0 ? bit 2 go/done : a/d conversion status bit if adon = 1: 1 = a/d conversion in progress (setting this bit starts the a/d conversion, which is automatically cleared by hardware when the a/d conversion is complete) 0 = a/d conversion not in progress bit 1 unimplemented : read as ? 0 ? bit 0 adon : a/d on bit 1 = a/d converter module is operating 0 = a/d converter module is shut-off and consumes no operating current legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown
pic17c7xx ds30289b-page 180 ? 2000 microchip technology inc. register 16-2: adcon1 register (address 15h, bank 5) r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 adcs1 adcs0 adfm ? pcfg3 pcfg2 pcfg1 pcfg0 bit 7 bit 0 bit 7-6 adcs1:adcs0 : a/d conversion clock select bits 00 = f osc /8 01 = f osc /32 10 = f osc /64 11 = f rc (clock derived from an internal rc oscillator) bit 5 adfm : a/d result format select 1 = right justified. 6 most significant bits of adresh are read as ? 0 ? . 0 = left justified. 6 least significant bits of adresl are read as ? 0 ? . bit 4 unimplemented : read as '0' bit 3-1 pcfg3:pcfg1 : a/d port configuration control bits bit 0 pcfg0 : a/d voltage reference select bit 1 = a/d reference is the v ref + and v ref - pins 0 = a/d reference is av dd and av ss note: when this bit is set, ensure that the a/d voltage reference specifications are met. legend: r = readable bit w = writable bit u = unimplemented bit, read as ? 0 ? - n = value at por reset ? 1 ? = bit is set ? 0 ? = bit is cleared x = bit is unknown a = analog input d = digital i/o pcfg3:pcfg0 an15 an14 an13 an12 an11 an10 an9 an8 an7 an6 an5 an4 an3 an2 an1 an0 000x a aaaaaaaaaaaaaaa 001x daaaaaaadaaaaaaa 010x ddaaaaaaddaaaaaa 011x d d d a a a aadddaaaaa 100x d dddaaaaddddaaaa 101x d ddddaaadddddaaa 110x d dddddaaddddddaa 111x d ddddddddddddddd
? 2000 microchip technology inc. ds30289b-page 181 pic17c7xx the adresh:adresl registers contain the 10-bit result of the a/d conversion. when the a/d conversion is complete, the result is loaded into this a/d result reg- ister pair, the go/done bit (adcon0<2>) is cleared and a/d interrupt flag bit, adif is set. the block diagrams of the a/d module are shown in figure 16-1. after the a/d module has been configured as desired, the selected channel must be acquired before the con- version is started. the analog input channels must have their corresponding ddr bits selected as inputs. to determine sample time, see section 16.1. after this acquisition time has elapsed, the a/d conversion can be started. the following steps should be followed for doing an a/d conversion: 1. configure the a/d module: a) configure analog pins/voltage reference/ and digital i/o (adcon1) b) select a/d input channel (adcon0) c) select a/d conversion clock (adcon0) d) turn on a/d module (adcon0) 2. configure a/d interrupt (if desired): a) clear adif bit b) set adie bit c) clear glintd bit 3. wait the required acquisition time. 4. start conversion: a) set go/done bit (adcon0) 5. wait for a/d conversion to complete, by either: a) polling for the go/done bit to be cleared or b) waiting for the a/d interrupt 6. read a/d result register pair (adresh:adresl), clear bit adif, if required. 7. for next conversion, go to step 1 or step 2, as required. the a/d conversion time per bit is defined as t ad . a minimum wait of 2t ad is required before next acquisition starts. figure 16-1: a/d block diagram (input voltage) v in v ref - (reference voltage) av dd pcfg0 chs3:chs0 an7 an6 an5 an4 an3 an2 an1/v ref - an0/v ref + 0111 0110 0101 0100 0011 0010 0001 0000 a/d converter an11 an10 an9 an8 1011 1010 1001 1000 v ref + av ss an12 (1) 1011 an13 (1) 1011 an14 (1) 1011 an15 (1) 1011 note 1 : these channels are only available on pic16c76x devices.
pic17c7xx ds30289b-page 182 ? 2000 microchip technology inc. figure 16-2 shows the conversion sequence and the terms that are used. acquisition time is the time that the a/d module ? s holding capacitor is connected to the external voltage level. then, there is the conversion time of 12 t ad , which is started when the go bit is set. the sum of these two times is the sampling time. there is a minimum acquisition time to ensure that the holding capacitor is charged to a level that will give the desired accuracy for the a/d conversion. figure 16-2: a/d conversion sequence acquisition time a/d conversion time a/d sample time when a/d holding capacitor starts to charge. after a/d conversion, or when new a/d channel is selected. when a/d conversion is started (setting the go bit). a/d conversion complete, result is loaded in adres register. holding capacitor begins acquiring voltage level on selected channel, adif bit is set.
? 2000 microchip technology inc. ds30289b-page 183 pic17c7xx 16.1 a/d acquisition requirements for the a/d converter 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 16-3. 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 ), figure 16-3. the maximum recommended impedance for analog sources is 10 k ? . as the impedance is decreased, the acquisition time may be decreased. after the analog input channel is selected (changed) this acquisition must be done before the conversion can be started. to calculate the minimum acquisition time, equation 16-1 may be used. this equation assumes that 1/2 lsb error is used (1024 steps for the a/d). the 1/2 lsb error is the maximum error allowed for the a/d to meet its specified resolution. example 16-1 shows the calculation of the minimum required acquisition time (t acq ). this is based on the following application system assumptions. c hold = 120 pf rs = 10 k ? conversion error 1/2 lsb v dd = 5v rss = 7 k ? (see graph in figure 16-3) temperature = 50 c (system max.) v hold =0v @ time = 0 equation 16-1: a cquisition time equation 16-2: a/d minimum charging time example 16-1: calculating the minimum required acquisition time t acq = amplifier settling time + holding capacitor charging time + temperature coefficient =t amp + t c + t coff v hold = (v ref - (v ref /2048)) ? (1 - e (-tc/c hold (r ic + r ss + r s )) ) or t c = -(120 pf)(1 k ? + r ss + r s ) ln(1/2047) t acq =t amp + t c + t coff temperature coefficient is only required for temperatures > 25 c. t acq =2 s + tc + [(temp - 25 c)(0.05 s/ c)] t c =-c hold (r ic + r ss + r s ) ln(1/2047) -120 pf (1 k ? + 7 k ? + 10 k ? ) ln(0.0004885) -120 pf (18 k ? ) ln(0.0004885) -2.16 s (-7.6241) 16.47 s t acq =2 s + 16.47 s + [(50 c - 25 c)(0.05 s / c)] 18.447 s + 1.25 s 19.72 s 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. 4: after a conversion has completed, a 2.0 t ad delay must complete before acquisition can begin again. during this time, the holding capacitor is not connected to the selected a/d input channel.
pic17c7xx ds30289b-page 184 ? 2000 microchip technology inc. figure 16-3: analog input model c pin va r s anx 5 pf v dd v t = 0.6v v t = 0.6v i leakage r ic 1k sampling switch ss r ss c hold = dac capacitance v ss 6v sampling switch 5v 4v 3v 2v 567891011 ( k ? ) v dd = 120 pf 500 na 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 (from dac) various junctions
? 2000 microchip technology inc. ds30289b-page 185 pic17c7xx 16.2 selecting the a/d conversion clock the a/d conversion time per bit is defined as t ad . the a/d conversion requires a minimum 12t ad per 10-bit conversion. the source of the a/d conversion clock is software selected. the four possible options for t ad are:  8t osc  32t osc  64t osc  internal rc oscillator for correct a/d conversions, the a/d conversion clock (t ad ) must be selected to ensure a minimum t ad time of 1.6 s. table 16-1 and table 16-2 show the resultant t ad times derived from the device operating frequencies and the a/d clock source selected. these times are for stan- dard voltage range devices. table 16-1: t ad vs. device operating frequencies (standard devices (c)) table 16-2: t ad vs. device operating frequencies (extended voltage devices (lc)) ad clock source (t ad ) max f osc (mhz) operation adcs1:adcs0 8t osc 00 5 32t osc 01 20 64t osc 10 33 rc 11 ? note: when the device frequency is greater than 1 mhz, the rc a/d conversion clock source is only recommended for sleep operation. ad clock source (t ad ) max f osc (mhz) operation adcs1:adcs0 8t osc 00 2.67 32t osc 01 10.67 64t osc 10 21.33 rc 11 ? note: when the device frequency is greater than 1 mhz, the rc a/d conversion clock source is only recommended for sleep operation.
pic17c7xx ds30289b-page 186 ? 2000 microchip technology inc. 16.3 configuring analog port pins the adcon1, and ddr registers control the operation of the a/d port pins. the port pins that are desired as analog inputs must have their corresponding ddr bits set (input). if the ddr bit is cleared (output), the digital output level (v oh or v ol ) will be converted. the a/d operation is independent of the state of the chs2:chs0 bits and the ddr bits. 16.4 a/d conversions example 16-2 shows how to perform an a/d conver- sion. the portf and lower four portg pins are con- figured as analog inputs. the analog references (v ref + and v ref -) are the device av dd and av ss . the a/d interrupt is enabled, and the a/d conversion clock is f rc . the conversion is performed on the rg3/an0 pin (channel 0). clearing the go/done bit during a conversion will abort the current conversion. the a/d result register pair will not be updated with the partially completed a/ d conversion sample. that is, the adresh:adresl registers will continue to contain the value of the last completed conversion (or the last value written to the adresh:adresl registers). after the a/d conversion is aborted, a 2t ad wait is required before the next acquisition is started. after this 2t ad wait, acquisition on the selected channel is automatically started. in figure 16-4, after the go bit is set, the first time seg- ment has a minimum of t cy and a maximum of t ad . example 16-2: a/d conversion figure 16-4: a/d conversion t ad cycles note 1: when reading the port register, any pin configured as an analog input channel will read as cleared (a low level). pins config- ured as digital inputs, will convert an ana- log input. analog levels on a digitally configured input will not affect the conver- sion accuracy. 2: analog levels on any pin that is defined as a digital input (including the an15:an0 pins), may cause the input buffer to con- sume current that is out of the devices specification. note: the go/done bit should not be set in the same instruction that turns on the a/d. movlb 5 ; bank 5 clrf adcon1, f ; configure a/d inputs, all analog, tad = fosc/8, left just. movlw 0x01 ; a/d is on, channel 0 is selected movwf adcon0 ; movlb 4 ; bank 4 bcf pir2, adif ; clear a/d interrupt flag bit bsf pie2, adie ; enable a/d interrupts bsf intsta, peie ; enable peripheral interrupts bcf cpusta, glintd ; enable all interrupts ; ; ensure that the required sampling time for the selected input channel has elapsed. ; then the conversion may be started. ; movlb 5 ; bank 5 bsf adcon0, go ; start a/d conversion : ; the adif bit will be set and the go/done bit : ; is cleared upon completion of the a/d conversion 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 9 set go bit holding capacitor is disconnected from analog input (typically 100 ns). holding capacitor is connected to analog input. b9 b8 b7 b6 b5 b4 b3 b2 t ad 10 t ad 11 b1 b0 t cy to t ad go bit is cleared, next q4: adres is loaded, adif bit is set, conversion starts.
? 2000 microchip technology inc. ds30289b-page 187 pic17c7xx figure 16-5: flow chart of a/d operation acquire adon = 0 adon = 0? go = 0? a/d clock go = 0, adif = 0 abort conversion sleep power-down a/d wait 2t ad wake-up yes no yes no no yes finish conversion go = 0, adif = 1 device in no yes finish conversion go = 0, adif = 1 wait 2t ad stay in sleep selected channel = rc? sleep no yes instruction? start of a/d conversion delayed 1 instruction cycle from sleep? power-down a/d ye s no wait 2t ad finish conversion go = 0, adif = 1 sleep?
pic17c7xx ds30289b-page 188 ? 2000 microchip technology inc. 16.4.1 a/d result registers the adresh:adresl register pair is the location where the 10-bit a/d result is loaded at the completion of the a/d conversion. this register pair is 16-bits wide. the a/d module gives the flexibility to left or right justify the 10-bit result in the 16-bit result register. the a/d format select bit (adfm) controls this justification. figure 16-6 shows the operation of the a/d result justi- fication. the extra bits are loaded with ? 0 ? s ? . when an a/ d result will not overwrite these locations (a/d disable), these registers may be used as two general purpose 8- bit registers. 16.5 a/d operation during sleep the a/d module can operate during sleep mode. this requires that the a/d clock source be set to rc (adcs1:adcs0 = 11 ). when the rc clock source is selected, the a/d module waits one instruction cycle before starting the conversion. this allows the sleep instruction to be executed, which eliminates all digital switching noise from the conversion. when the conver- sion is completed, the go/done bit will be cleared, and the result loaded into the adres register. if the a/ d interrupt is enabled, the device will wake-up from sleep. if the a/d interrupt is not enabled, the a/d mod- ule will then be turned off, although the adon bit will remain set. when the a/d clock source is another clock option (not rc), a sleep instruction will cause the present conver- sion to be aborted and the a/d module to be turned off, though the adon bit will remain set. turning off the a/d places the a/d module in its lowest current consumption state. 16.6 effects of a reset a device reset forces all registers to their reset state. this forces the a/d module to be turned off, and any conversion is aborted. the value that is in the adresh:adresl registers is not modified for a power-on reset. the adresh:adresl registers will contain unknown data after a power-on reset. figure 16-6: a/d result justification note: for the a/d module to operate in sleep, the a/d clock source must be set to rc (adcs1:adcs0 = 11 ). to allow the con- version to occur during sleep, ensure the sleep instruction immediately follows the instruction that sets the go/done bit. 10-bit result adresh adresl 0000 00 adfm = 0 0 2 1 0 7 7 10-bits result adresh adresl 10-bits 0000 00 7 0 7 6 5 0 result adfm = 1 right justified left justified
? 2000 microchip technology inc. ds30289b-page 189 pic17c7xx 16.7 a/d accuracy/error in systems where the device frequency is low, use of the a/d rc clock is preferred. at moderate to high fre- quencies, t ad should be derived from the device oscil- lator. the absolute accuracy specified for the a/d converter includes the sum of all contributions for quantization error, integral error, differential error, full scale error, off- set error, and monotonicity. it is defined as the maxi- mum deviation from an actual transition versus an ideal transition for any code. the absolute error of the a/d converter is specified at < 1 lsb for v dd = v ref (over the device ? s specified operating range). however, the accuracy of the a/d converter will degrade as v ref diverges from v dd . for a given range of analog inputs, the output digital code will be the same. this is due to the quantization of the analog input to a digital code. quantization error is typically 1/2 lsb and is inherent in the analog to dig- ital conversion process. the only way to reduce quan- tization error is to increase the resolution of the a/d converter or oversample. offset error measures the first actual transition of a code versus the first ideal transition of a code. offset error shifts the entire transfer function. offset error can be calibrated out of a system or introduced into a sys- tem through the interaction of the total leakage current and source impedance at the analog input. gain error measures the maximum deviation of the last actual transition and the last ideal transition adjusted for offset error. this error appears as a change in slope of the transfer function. the difference in gain error to full scale error is that full scale does not take offset error into account. gain error can be calibrated out in soft- ware. linearity error refers to the uniformity of the code changes. linearity errors cannot be calibrated out of the system. integral non-linearity error measures the actual code transition versus the ideal code transition, adjusted by the gain error for each code. differential non-linearity measures the maximum actual code width versus the ideal code width. this measure is unadjusted. the maximum pin leakage current is specified in the device data sheet electrical specification (table 20-2, parameter #d060). in systems where the device frequency is low, use of the a/d rc clock is preferred. at moderate to high fre- quencies, t ad should be derived from the device oscil- lator. t ad must not violate the minimum and should be minimized to reduce inaccuracies due to noise and sampling capacitor bleed off. in systems where the device will enter sleep mode after the start of the a/d conversion, the rc clock source selection is required. in this mode, the digital noise from the modules in sleep are stopped. this method gives high accuracy. 16.8 connection considerations if the input voltage exceeds the rail values (v ss or v dd ) by greater than 0.3v, then the accuracy of the conver- sion is out of specification. an external rc filter is sometimes added for anti- aliasing of the input signal. the r component should be selected to ensure that the total source impedance is kept under the 10 k ? recommended specification. any external components connected (via hi-impedance) to an analog input pin (capacitor, zener diode, etc.) should have very little leakage current at the pin. 16.9 transfer function the transfer function of the a/d converter is as follows: the first transition occurs when the analog input voltage (v ain ) equals analog v ref / 1024 (figure 16-7). figure 16-7: a/d transfer function digital code output 3feh 003h 002h 001h 000h 0.5 lsb 1 lsb 1.5 lsb 2 lsb 2.5 lsb 1022 lsb 1022.5 lsb 3 lsb analog input voltage 3ffh 1023 lsb 1023.5 lsb
pic17c7xx ds30289b-page 190 ? 2000 microchip technology inc. 16.10 references a good reference for understanding a/d converter is the "analog-digital conversion handbook" third edition, published by prentice hall (isbn 0-13-03-2848-0). table 16-3: registers/bits associated with a/d address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 por, bor mclr , wdt 06h, unbanked cpusta ? ? stakav glintd to pd por bor --11 1100 --11 qq11 07h, unbanked intsta peif t0ckif t0if intf peie t0ckie t0ie inte 0000 0000 0000 0000 10h, bank 4 pir2 sspif bclif adif ? ca4if ca3if tx2if rc2if 000- 0010 000- 0010 11h, bank 4 pie2 sspie bclie adie ? ca4ie ca3ie tx2ie rc2ie 000- 0000 000- 0000 10h, bank 5 ddrf data direction register for portf 1111 1111 1111 1111 11h, bank 5 portf rf7/ an11 rf6/ an10 rf5/ an9 rf4/ an8 rf3/ an7 rf2/ an6 rf1/ an5 rf0/ an4 0000 0000 0000 0000 12h, bank 5 ddrg data direction register for portg 1111 1111 1111 1111 13h, bank 5 portg rg7/ tx2/ck2 rg6/ rx2/dt2 rg5/ pwm3 rg4/ cap3 rg3/ an0/v ref + rg2/ an1/v ref - rg1/ an2 rg0/ an3 xxxx 0000 uuuu 0000 14h, bank 5 adcon0 chs3 chs2 chs1 chs0 ? go/done ? adon 0000 -0-0 0000 -0-0 15h, bank 5 adcon1 adcs1 adcs0 adfm ? pcfg3 pcfg2 pcfg1 pcfg0 000- 0000 000- 0000 16h, bank 5 adresl a/d result low register xxxx xxxx uuuu uuuu 17h, bank 5 adresh a/d result high register xxxx xxxx uuuu uuuu legend: x = unknown, u = unchanged, - = unimplemented, read as '0'. shaded cells are not used for a/d conversion. note: other (non power-up) resets include: external reset through mclr and watchdog timer reset.
? 2000 microchip technology inc. ds30289b-page 191 pic17c7xx 17.0 special features of the cpu what sets a microcontroller apart from other proces- sors are special circuits to deal with the needs of real- time applications. the pic17cxxx family has a host of such features intended to maximize system reliability, minimize cost through elimination of external compo- nents, provide power saving operating modes and offer code protection. these are:  oscillator selection (section 4.0)  reset (section 5.0) - power-on reset (por) - power-up timer (pwrt) - oscillator start-up timer (ost) - brown-out reset (bor)  interrupts (section 6.0)  watchdog timer (wdt)  sleep mode  code protection the pic17cxxx has a watchdog timer which can be shut-off only through eprom bits. it runs off its own rc oscillator for added reliability. there are two timers that offer necessary delays on por and bor. one is the oscillator start-up timer (ost), intended to keep the chip in reset until the crystal oscillator is stable. the other is the power-up timer (pwrt), which provides a fixed delay of 96 ms (nominal) on power-up only, designed to keep the part in reset while the power supply stabilizes. with these two timers on-chip, most applications need no external reset circuitry. the sleep mode is designed to offer a very low cur- rent power-down mode. the user can wake from sleep through external reset, watchdog timer reset, or through an interrupt. several oscillator options are also made available to allow the part to fit the application. the rc oscillator option saves system cost, while the lf crystal option saves power. configu- ration bits are used to select various options. this con- figuration word has the format shown in figure 17-1. register 17-1: configuration words high (h) table read addr. u-x r/p-1 r/p-1 u-x u-x u-x u-x u-x u-x fe0fh - fe08h ? pm2 boden ? ? ? ? ? ? bit 15 bit 8 bit 7 bit 0 low (l) table read addr. u-x u-x r/p-1 u-x r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 fe07h - fe00h ? ? pm1 ? pm0 wdtps1 wdtps0 fosc1 fosc0 bit 15 bit 8 bit 7 bit 0 bits 7h, 6l, 4l pm2, pm1, pm0: processor mode select bits 111 = microprocessor mode 110 = microcontroller mode 101 = extended microcontroller mode 000 = code protected microcontroller mode bit 6h boden: brown-out detect enable 1 = brown-out detect circuitry is enabled 0 = brown-out detect circuitry is disabled bits 3l:2l wdtps1:wdtps0 : wdt postscaler select bits 11 = wdt enabled, postscaler = 1 10 = wdt enabled, postscaler = 256 01 = wdt enabled, postscaler = 64 00 = wdt disabled, 16-bit overflow timer bits 1l:0l fosc1:fosc0 : oscillator select bits 11 = ec oscillator 10 = xt oscillator 01 = rc oscillator 00 = lf oscillator shaded bits ( ? ) reserved
pic17c7xx ds30289b-page 192 ? 2000 microchip technology inc. 17.1 configuration bits the pic17cxxx has eight configuration locations (table 17-1). these locations can be programmed (read as ? 0 ? ), or left unprogrammed (read as ? 1 ? ) to select various device configurations. any write to a configuration location, regardless of the data, will pro- gram that configuration bit. a tablwt instruction and raising the mclr /v pp pin to the programming voltage are both required to write to program memory loca- tions. the configuration bits can be read by using the tablrd instructions. reading any configuration loca- tion between fe00h and fe07h will read the low byte of the configuration word (figure 17-1) into the tab- latl register. the tablath register will be ffh. reading a configuration location between fe08h and fe0fh will read the high byte of the configuration word into the tablatl register. the tablath register will be ffh. addresses fe00h through fe0fh are only in the pro- gram memory space for microcontroller and code pro- tected microcontroller modes. a device programmer will be able to read the configuration word in any pro- cessor mode. see programming specifications for more detail. table 17-1: configuration locations 17.2 oscillator configurations 17.2.1 oscillator types the pic17cxxx can be operated in four different oscil- lator modes. the user can program two configuration bits (fosc1:fosc0) to select one of these four modes:  lf low power crystal  xt crystal/resonator  ec external clock input  rc resistor/capacitor for information on the different oscillator types and how to use them, please refer to section 4.0. bit address fosc0 fe00h fosc1 fe01h wdtps0 fe02h wdtps1 fe03h pm0 fe04h pm1 fe06h boden fe0eh pm2 fe0fh note: when programming the desired configura- tion locations, they must be programmed in ascending order, starting with address fe00h.
? 2000 microchip technology inc. ds30289b-page 193 pic17c7xx 17.3 watchdog timer (wdt) the watchdog timer ? s function is to recover from soft- ware malfunction, or to reset the device while in sleep mode. the wdt uses an internal free running on-chip rc oscillator for its clock source. this does not require any external components. this rc oscillator is sepa- rate from the rc oscillator of the osc1/clkin pin. that means that the wdt will run even if the clock on the osc1/clkin and osc2/clkout pins has been stopped, for example, by execution of a sleep instruc- tion. during normal operation, a wdt time-out gener- ates a device reset. the wdt can be permanently disabled by programming the configuration bits wdtps1:wdtps0 as ' 00 ' (section 17.1). under normal operation, the wdt must be cleared on a regular interval. this time must be less than the min- imum wdt overflow time. not clearing the wdt in this time frame will cause the wdt to overflow and reset the device. 17.3.1 wdt period the wdt has a nominal time-out period of 12 ms (with postscaler = 1). the time-out periods vary with temper- ature, v dd and process variations from part to part (see dc specs). if longer time-out periods are desired, con- figuration bits should be used to enable the wdt with a greater prescale. thus, typical time-out periods up to 3.0 seconds can be realized. the clrwdt and sleep instructions clear the wdt and its postscale setting and prevent it from timing out, thus generating a device reset condition. the to bit in the cpusta register will be cleared upon a wdt time-out. 17.3.2 clearing the wdt and postscaler the wdt and postscaler are cleared when:  the device is in the reset state  a sleep instruction is executed  a clrwdt instruction is executed  wake-up from sleep by an interrupt the wdt counter/postscaler will start counting on the first edge after the device exits the reset state. 17.3.3 wdt programming considerations it should also be taken in account that under worst case conditions (v dd = min., temperature = max., max. wdt postscaler), it may take several seconds before a wdt time-out occurs. the wdt and postscaler become the power-up timer whenever the pwrt is invoked. 17.3.4 wdt as normal timer when the wdt is selected as a normal timer, the clock source is the device clock. neither the wdt nor the postscaler are directly readable or writable. the over- flow time is 65536 t osc cycles. on overflow, the to bit is cleared (device is not reset). the clrwdt instruc- tion can be used to set the to bit. this allows the wdt to be a simple overflow timer. the simple timer does not increment when in sleep. figure 17-1: watchdog timer block diagram table 17-2: registers/bits associated with the watchdog timer wdt wdt enable postscaler 4 - to - 1 mux wdtps1:wdtps0 on-chip rc wdt overflow oscillator (1) note 1: this oscillator is separate from the external rc oscillator on the osc1 pin. address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 value on por, bor mclr , wdt ? config see figure 17-1 for location of wdtpsx bits in configuration word. (note 1) (note 1) 06h, unbanked cpusta ? ? stkav glintd to pd por bor --11 11qq --11 qquu legend: - = unimplemented, read as '0', q = value depends on condition. shaded cells are not used by the wdt. note 1: this value will be as the device was programmed, or if unprogrammed, will read as all '1's.
pic17c7xx ds30289b-page 194 ? 2000 microchip technology inc. 17.4 power-down mode (sleep) the power-down mode is entered by executing a sleep instruction. this clears the watchdog timer and postscaler (if enabled). the pd bit is cleared and the to bit is set (in the cpusta register). in sleep mode, the oscillator driver is turned off. the i/o ports maintain their status (driving high,low, or hi-impedance input). the mclr/ v pp pin must be at a logic high level (v ihmc ). a wdt time-out reset does not drive the mclr/ v pp pin low. 17.4.1 wake-up from sleep the device can wake-up from sleep through one of the following events:  power-on reset  brown-out reset  external reset input on mclr/ v pp pin  wdt reset (if wdt was enabled)  interrupt from ra0/int pin, rb port change, t0cki interrupt, or some peripheral interrupts the following peripheral interrupts can wake the device from sleep:  capture interrupts  usart synchronous slave transmit interrupts  usart synchronous slave receive interrupts  a/d conversion complete  spi slave transmit/receive complete  i 2 c slave receive other peripherals cannot generate interrupts since dur- ing sleep, no on-chip q clocks are present. any reset event will cause a device reset. any interrupt event is considered a continuation of program execution. the to and pd bits in the cpusta register can be used to determine the cause of a device reset. the pd bit, which is set on power-up, is cleared when sleep is invoked. the to bit is cleared if wdt time-out occurred (and caused a reset). when the sleep instruction is being executed, the next instruction (pc + 1) is pre-fetched. 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 glintd bit. if the glintd bit is set (disabled), the device continues execution at the instruction after the sleep instruction. if the glintd bit is clear (enabled), the device executes the instruction after the sleep instruction and then branches to the interrupt vector address. 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 from sleep, regardless of the source of wake-up. 17.4.1.1 wake-up delay when the oscillator type is configured in xt or lf mode, the oscillator start-up timer (ost) is activated on wake-up. the ost will keep the device in reset for 1024t osc . this needs to be taken into account when considering the interrupt response time when coming out of sleep. figure 17-2: wake-up from sleep through interrupt note: if the global interrupt is disabled (glintd is set), but any interrupt source has both its interrupt enable bit and the corresponding interrupt flag bit set, the device will imme- diately wake-up from sleep. the to bit is set and the pd bit is cleared. q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 q2 q1 q3 q4 osc1 clkout (4) int intf flag glintd bit instruction flow pc instruction fetched instruction executed interrupt latency (2) pc pc+1 pc+2 0004h 0005h dummy cycle inst (pc) = sleep inst (pc+1) inst (pc-1) sleep t ost (2) processor in sleep inst (pc+2) inst (pc+1) note 1: xt or lf oscillator mode assumed. 2: t ost = 1024t osc (drawing not to scale). this delay will not be there for rc osc mode. 3: when glintd = 0, processor jumps to interrupt routine after wake-up. if glintd = 1, execution will continue in line. 4: clkout is not available in these osc modes, but shown here for timing reference. (ra0/int pin) ? 0 ? or ? 1 ?
? 2000 microchip technology inc. ds30289b-page 195 pic17c7xx 17.4.2 minimizing current consumption to minimize current consumption, 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 hi-impedance inputs should be pulled high or low externally to avoid switching currents caused by floating inputs. the t0cki input should be at v dd or v ss . the contributions from on-chip pull-ups on portb should also be con- sidered and disabled, when possible. 17.5 code protection the code in the program memory can be protected by selecting the microcontroller in code protected mode (pm2:pm0 = ? 000 ? ). in this mode, instructions that are in the on-chip pro- gram memory space, can continue to read or write the program memory. an instruction that is executed out- side of the internal program memory range will be inhibited from writing to, or reading from, program memory. if the code protection bit(s) have not been pro- grammed, the on-chip program memory can be read out for verification purposes. note: microchip does not recommend code pro- tecting windowed devices.
pic17c7xx ds30289b-page 196 ? 2000 microchip technology inc. 17.6 in-circuit serial programming the pic17c7xx group of the high-end family (pic17cxxx) has an added feature that allows serial programming while in the end application circuit. this is simply done with two lines for clock and data and three other lines for power, ground, and the programming voltage. this allows customers to manufacture boards with unprogrammed devices and then program the microcontroller just before shipping the product. this also allows the most recent firmware, or a custom firm- ware to be programmed. devices may be serialized to make the product unique; ? special ? variants of the product may be offered and code updates are possible. this allows for increased design flexibility. to place the device into the serial programming test mode, two pins will need to be placed at v ihh . these are the test pin and the mclr /v pp pin. also, a sequence of events must occur as follows: 1. the test pin is placed at v ihh . 2. the mclr /v pp pin is placed at v ihh . there is a setup time between step 1 and step 2 that must be met. after this sequence, the program counter is pointing to program memory address 0xff60. this location is in the boot rom. the code initializes the usart/sci so that it can receive commands. for this, the device must be clocked. the device clock source in this mode is the ra1/t0cki pin. after delaying to allow the usart/sci to initialize, commands can be received. the flow is shown in these 3 steps: 1. the device clock source starts. 2. wait 80 device clocks for boot rom code to configure the usart/sci. 3. commands may now be sent. for complete details of serial programming, please refer to the pic17c7xx programming specification. (contact your local microchip technology sales office for availability.) figure 17-3: typical in-circuit serial programming connection table 17-3: icsp interface pins external connector signals to n o rm a l connections to n o rm a l connections pic17c7xx v dd v ss mclr /v pp ra1/t0cki ra4/rx1/dt1 +5v 0v v pp dev. clk data i/o v dd ra5/tx1/ck1 data clk test test cntl during programming name function type description ra4/rx1/dt1 dt i/o serial data ra5/tx1/ck1 ck i serial clock ra1/t0cki osci i device clock source test test i test mode selection control input, force to v ihh mclr /v pp mclr /v pp p master clear reset and device programming voltage v dd v dd p positive supply for logic and i/o pins v ss v ss p ground reference for logic and i/o pins
? 2000 microchip technology inc. ds30289b-page 197 pic17c7xx 18.0 instruction set summary the pic17cxxx instruction set consists of 58 instruc- tions. each instruction is a 16-bit word divided into an opcode and one or more operands. the opcode specifies the instruction type, while the operand(s) fur- ther specify the operation of the instruction. the pic17cxxx instruction set can be grouped into three types:  byte-oriented  bit-oriented  literal and control operations these formats are shown in figure 18-1. table 18-1 shows the field descriptions for the opcodes. these descriptions are useful for understand- ing the opcodes in table 18-2 and in each specific instruction descriptions. for byte-oriented instructions , 'f' represents a file register designator and 'd' represents a destination designator. the file register designator specifies which file register is to be used by the instruction. the destination designator specifies where the result of the operation is to be placed. if 'd' = '0', the result is placed in the wreg register. if 'd' = '1', the result is placed in the file register specified by the instruction. for bit-oriented instructions , 'b' represents a bit field designator which selects the number of the bit affected by the operation, while 'f' represents the number of the file in which the bit is located. for literal and control operations , 'k' represents an 8- or 13-bit constant or literal value. the instruction set is highly orthogonal and is grouped into:  byte-oriented operations  bit-oriented operations  literal and control operations all instructions are executed within one single instruc- tion cycle, unless:  a conditional test is true  the program counter is changed as a result of an instruction  a table read or a table write instruction is executed (in this case, the execution takes two instruction cycles with the second cycle executed as a nop) one instruction cycle consists of four oscillator periods. thus, for an oscillator frequency of 25 mhz, the normal instruction execution time is 160 ns. if a conditional test is true or the program counter is changed as a result of an instruction, the instruction execution time is 320 ns. table 18-1: opcode field descriptions field description f register file address (00h to ffh) p peripheral register file address (00h to 1fh) i table pointer control i = ? 0 ? (do not change) i = ? 1 ? (increment after instruction execution) t table byte select t = ? 0 ? (perform operation on lower byte) t = ? 1 ? (perform operation on upper byte literal field, constant data) wreg 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 0 = store result in wreg 1 = store result in file register f default is d = ? 1 ? u unused, encoded as ? 0 ? s destination select 0 = store result in file register f and in the wreg 1 = store result in file register f default is s = ? 1 ? label label name c,dc, z,ov alu status bits carry, digit carry, zero, overflow glintd global interrupt disable bit (cpusta<4>) tblptr table pointer (16-bit) tblat table latch (16-bit) consists of high byte (tblath) and low byte (tblatl) tblatl table latch low byte tblath table latch high byte tos top-of-stack pc program counter bsr bank select register wdt watchdog timer counter to time-out bit pd power-down bit dest destination either the wreg register or the speci- fied register file location [ ] options ( ) contents assigned to < > register bit field in the set of i talics user defined term (font is courier)
pic17c7xx ds30289b-page 198 ? 2000 microchip technology inc. table 18-2 lists the instructions recognized by the mpasm assembler. all instruction examples use the following format to rep- resent a hexadecimal number: 0xhh where h signifies a hexadecimal digit. to represent a binary number: 0000 0100b where b signifies a binary string. figure 18-1: general format for instructions 18.1 special function registers as source/destination the pic17c7xx ? s orthogonal instruction set allows read and write of all file registers, including special function registers. there are some special situations the user should be aware of: 18.1.1 alusta as destination if an instruction writes to alusta, the z, c, dc and ov bits may be set or cleared as a result of the instruction and overwrite the original data bits written. for exam- ple, executing clrf alusta will clear register alusta and then set the z bit leaving 0000 0100b in the register. 18.1.2 pcl as source or destination read, write or read-modify-write on pcl may have the following results: read pc: pch pclath; pcl dest write pcl: pclath pch; 8-bit destination value pcl read-modify-write: pcl alu operand pclath pch; 8-bit result pcl where pch = program counter high byte (not an addressable register), pclath = program counter high holding latch, dest = destination, wreg or f. 18.1.3 bit manipulation all bit manipulation instructions are done by first read- ing the entire register, operating on the selected bit and writing the result back (read-modify-write (r-m-w)). the user should keep this in mind when operating on some special function registers, such as ports. note 1: any unused opcode is reserved. use of any reserved opcode may cause unex- pected operation. byte-oriented file register operations 15 9 8 7 0 d = 0 for destination wreg opcode d f (file #) d = 1 for destination f f = 8-bit file register address bit-oriented file register operations 15 11 10 8 7 0 opcode b (bit #) f (file #) b = 3-bit address f = 8-bit file register address literal and control operations 15 8 7 0 opcode k (literal) k = 8-bit immediate value byte to byte move operations 15 13 12 8 7 0 opcode p (file #) f (file #) call and goto operations 15 13 12 0 opcode k (literal) k = 13-bit immediate value p = peripheral register file address f = 8-bit file register address note: status bits that are manipulated by the device (including the interrupt flag bits) are set or cleared in the q1 cycle. so, there is no issue on doing r-m-w instructions on registers which contain these bits
? 2000 microchip technology inc. ds30289b-page 199 pic17c7xx 18.2 q cycle activity each instruction cycle (t cy ) is comprised of four q cycles (q1-q4). the q cycle is the same as the device oscillator cycle (t osc ). the q cycles provide the timing/ designation for the decode, read, process data, write, etc., of each instruction cycle. the following dia- gram shows the relationship of the q cycles to the instruction cycle. the four q cycles that make up an instruction cycle (t cy ) can be generalized as: q1: instruction decode cycle or forced no operation q2: instruction read cycle or no operation q3: process the data q4: instruction write cycle or no operation each instruction will show the detailed q cycle opera- tion for the instruction. figure 18-2: q cycle activity q1 q2 q3 q4 q1 q2 q3 q4 q1 q2 q3 q4 t cy 1t cy 2t cy 3 t osc
pic17c7xx ds30289b-page 200 ? 2000 microchip technology inc. table 18-2: pic17cxxx instruction set mnemonic, operands description cycles 16-bit opcode status affected notes msb lsb byte-oriented file register operations addwf f,d add wreg to f 1 0000 111d ffff ffff ov,c,dc,z addwfc f,d add wreg and carry bit to f 1 0001 000d ffff ffff ov,c,dc,z andwf f,d and wreg with f 1 0000 101d ffff ffff z clrf f,s clear f, or clear f and clear wreg 1 0010 100s ffff ffff none 3 comf f,d complement f 1 0001 001d ffff ffff z cpfseq f compare f with wreg, skip if f = wreg 1 (2) 0011 0001 ffff ffff none 6,8 cpfsgt f compare f with wreg, skip if f > wreg 1 (2) 0011 0010 ffff ffff none 2,6,8 cpfslt f compare f with wreg, skip if f < wreg 1 (2) 0011 0000 ffff ffff none 2,6,8 daw f,s decimal adjust wreg register 1 0010 111s ffff ffff c3 decf f,d decrement f 1 0000 011d ffff ffff ov,c,dc,z decfsz f,d decrement f, skip if 0 1 (2) 0001 011d ffff ffff none 6,8 dcfsnz f,d decrement f, skip if not 0 1 (2) 0010 011d ffff ffff none 6,8 incf f,d increment f 1 0001 010d ffff ffff ov,c,dc,z incfsz f,d increment f, skip if 0 1 (2) 0001 111d ffff ffff none 6,8 infsnz f,d increment f, skip if not 0 1 (2) 0010 010d ffff ffff none 6,8 iorwf f,d inclusive or wreg with f 1 0000 100d ffff ffff z movfp f,p move f to p 1 011p pppp ffff ffff none movpf p,f move p to f 1 010p pppp ffff ffff z movwf f move wreg to f 1 0000 0001 ffff ffff none mulwf f multiply wreg with f 1 0011 0100 ffff ffff none negw f,s negate wreg 1 0010 110s ffff ffff ov,c,dc,z 1,3 nop ? no operation 1 0000 0000 0000 0000 none rlcf f,d rotate left f through carry 1 0001 101d ffff ffff c rlncf f,d rotate left f (no carry) 1 0010 001d ffff ffff none rrcf f,d rotate right f through carry 1 0001 100d ffff ffff c rrncf f,d rotate right f (no carry) 1 0010 000d ffff ffff none setf f,s set f 1 0010 101s ffff ffff none 3 subwf f,d subtract wreg from f 1 0000 010d ffff ffff ov,c,dc,z 1 subwfb f,d subtract wreg from f with borrow 1 0000 001d ffff ffff ov,c,dc,z 1 swapf f,d swap f 1 0001 110d ffff ffff none tablrd t,i,f table read 2 (3) 1010 10ti ffff ffff none 7 tablwt t,i,f table write 2 1010 11ti ffff ffff none 5 tlrd t,f table latch read 1 1010 00tx ffff ffff none tlwt t,f table latch write 1 1010 01tx ffff ffff none legend: refer to table 18-1 for opcode field descriptions. note 1: 2 ? s complement method. 2: unsigned arithmetic. 3: if s = '1', only the file is affected: if s = '0', both the wreg register and the file are affected; if only the working regist er (wreg) is required to be affected, then f = wreg must be specified. 4: during an lcall, the contents of pclath are loaded into the msb of the pc and kkkk kkkk is loaded into the lsb of the pc (pcl). 5: multiple cycle instruction for eprom programming when table pointer selects internal eprom. the instruction is termi- nated by an interrupt event. when writing to external program memory, it is a two-cycle instruction. 6: two-cycle instruction when condition is true, else single cycle instruction. 7: two-cycle instruction except for tablrd to pcl (program counter low byte), in which case it takes 3 cycles. 8: a ? skip ? means that instruction fetched during execution of current instruction is not executed, instead a nop is executed.
? 2000 microchip technology inc. ds30289b-page 201 pic17c7xx tstfsz f test f, skip if 0 1 (2) 0011 0011 ffff ffff none 6,8 xorwf f,d exclusive or wreg with f 1 0000 110d ffff ffff z bit-oriented file register operations bcf f,b bit clear f 1 1000 1bbb ffff ffff none bsf f,b bit set f 1 1000 0bbb ffff ffff none btfsc f,b bit test, skip if clear 1 (2) 1001 1bbb ffff ffff none 6,8 btfss f,b bit test, skip if set 1 (2) 1001 0bbb ffff ffff none 6,8 btg f,b bit toggle f 1 0011 1bbb ffff ffff none literal and control operations addlw k add literal to wreg 1 1011 0001 kkkk kkkk ov,c,dc,z andlw k and literal with wreg 1 1011 0101 kkkk kkkk z call k subroutine call 2 111k kkkk kkkk kkkk none 7 clrwdt ? clear watchdog timer 1 0000 0000 0000 0100 to , pd goto k unconditional branch 2 110k kkkk kkkk kkkk none 7 iorlw k inclusive or literal with wreg 1 1011 0011 kkkk kkkk z lcall k long call 2 1011 0111 kkkk kkkk none 4,7 movlb k move literal to low nibble in bsr 1 1011 1000 uuuu kkkk none movlr k move literal to high nibble in bsr 1 1011 101x kkkk uuuu none movlw k move literal to wreg 1 1011 0000 kkkk kkkk none mullw k multiply literal with wreg 1 1011 1100 kkkk kkkk none retfie ? return from interrupt (and enable interrupts) 2 0000 0000 0000 0101 glintd 7 retlw k return literal to wreg 2 1011 0110 kkkk kkkk none 7 return ? return from subroutine 2 0000 0000 0000 0010 none 7 sleep ? enter sleep mode 1 0000 0000 0000 0011 to , pd sublw k subtract wreg from literal 1 1011 0010 kkkk kkkk ov,c,dc,z xorlw k exclusive or literal with wreg 1 1011 0100 kkkk kkkk z table 18-2: pic17cxxx instruction set (continued) mnemonic, operands description cycles 16-bit opcode status affected notes msb lsb legend: refer to table 18-1 for opcode field descriptions. note 1: 2 ? s complement method. 2: unsigned arithmetic. 3: if s = '1', only the file is affected: if s = '0', both the wreg register and the file are affected; if only the working regist er (wreg) is required to be affected, then f = wreg must be specified. 4: during an lcall, the contents of pclath are loaded into the msb of the pc and kkkk kkkk is loaded into the lsb of the pc (pcl). 5: multiple cycle instruction for eprom programming when table pointer selects internal eprom. the instruction is termi- nated by an interrupt event. when writing to external program memory, it is a two-cycle instruction. 6: two-cycle instruction when condition is true, else single cycle instruction. 7: two-cycle instruction except for tablrd to pcl (program counter low byte), in which case it takes 3 cycles. 8: a ? skip ? means that instruction fetched during execution of current instruction is not executed, instead a nop is executed.
pic17c7xx ds30289b-page 202 ? 2000 microchip technology inc. addlw add literal to wreg syntax: [ label ] addlw k operands: 0 k 255 operation: (wreg) + k (wreg) status affected: ov, c, dc, z encoding: 1011 0001 kkkk kkkk description: the contents of wreg are added to the 8-bit literal ? k ? and the result is placed in wreg.   
  q cycle activity: q1 q2 q3 q4 decode read literal ? k ? process data write to wreg example : addlw 0x15 before instruction wreg = 0x10 after instruction wreg = 0x25 addwf add wreg to f syntax: [ label ] addwf f,d operands: 0 f 255 d [0,1] operation: (wreg) + (f) (dest) status affected: ov, c, dc, z encoding: 0000 111d ffff ffff description: add wreg to register ? f ? . if ? d ? is 0 the result is stored in wreg. if ? d ? is 1 the result is stored back in register ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example : addwf reg, 0 before instruction wreg = 0x17 reg = 0xc2 after instruction wreg = 0xd9 reg = 0xc2
? 2000 microchip technology inc. ds30289b-page 203 pic17c7xx addwfc add wreg and carry bit to f syntax: [ label ] addwfc f,d operands: 0 f 255 d [0,1] operation: (wreg) + (f) + c (dest) status affected: ov, c, dc, z encoding: 0001 000d ffff ffff description: add wreg, the carry flag and data memory location ? f ? . if ? d ? is 0, the result is placed in wreg. if ? d ? is 1, the result is placed in data memory location ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example : addwfc reg 0 before instruction carry bit = 1 reg = 0x02 wreg = 0x4d after instruction carry bit = 0 reg = 0x02 wreg = 0x50 andlw and literal with wreg syntax: [ label ] andlw k operands: 0 k 255 operation: (wreg) .and. (k) (wreg) status affected: z encoding: 1011 0101 kkkk kkkk description: the contents of wreg are and ? ed with the 8-bit literal 'k'. the result is placed in wreg. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read literal 'k' process data write to wreg example : andlw 0x5f before instruction wreg = 0xa3 after instruction wreg = 0x03
pic17c7xx ds30289b-page 204 ? 2000 microchip technology inc. andwf and wreg with f syntax: [ label ] andwf f,d operands: 0 f 255 d [0,1] operation: (wreg) .and. (f) (dest) status affected: z encoding: 0000 101d ffff ffff description: the contents of wreg are and ? ed with register 'f'. if 'd' is 0 the result is stored in wreg. if 'd' is 1 the result is stored back in register 'f'. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register 'f' process data write to destination example : andwf reg, 1 before instruction wreg = 0x17 reg = 0xc2 after instruction wreg = 0x17 reg = 0x02 bcf bit clear f syntax: [ label ] bcf f,b operands: 0 f 255 0 b 7 operation: 0 (f) status affected: none encoding: 1000 1bbb ffff ffff description: bit 'b' in register 'f' is cleared. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register 'f' process data write register 'f' example : bcf flag_reg, 7 before instruction flag_reg = 0xc7 after instruction flag_reg = 0x47
? 2000 microchip technology inc. ds30289b-page 205 pic17c7xx bsf bit set f syntax: [ label ] bsf f,b operands: 0 f 255 0 b 7 operation: 1 (f) status affected: none encoding: 1000 0bbb ffff ffff description: bit ? b ? in register ? f ? is set. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write register ? f ? example : bsf flag_reg, 7 before instruction flag_reg = 0x0a after instruction flag_reg = 0x8a btfsc bit test, skip if clear syntax: [ label ] btfsc f,b operands: 0 f 255 0 b 7 operation: skip if (f) = 0 status affected: none encoding: 1001 1bbb ffff ffff description: if bit 'b' in register ? f' is 0, then the next instruction is skipped. if bit 'b' is 0, then the next instruction fetched during the current instruction exe- cution is discarded and a nop is executed instead, making this a two-cycle instruction. words: 1 cycles: 1(2) q cycle activity: q1 q2 q3 q4 decode read register 'f' process data no operation if skip: q1 q2 q3 q4 no operation no operation no operation no operation example : here false true btfsc : : flag,1 before instruction pc = address (here) after instruction if flag<1> = 0; pc = address (true) if flag<1> = 1; pc = address (false)
pic17c7xx ds30289b-page 206 ? 2000 microchip technology inc. btfss bit test, skip if set syntax: [ label ] btfss f,b operands: 0 f 127 0 b < 7 operation: skip if (f) = 1 status affected: none encoding: 1001 0bbb ffff ffff description: if bit ? b ? in register ? f ? is 1, then the next instruction is skipped. if bit ? b ? is 1, then the next instruction fetched during the current instruction exe- cution is discarded and a nop is executed instead, making this a two-cycle instruction. words: 1 cycles: 1(2) q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data no operation if skip: q1 q2 q3 q4 no operation no operation no operation no operation example : here false true btfss : : flag,1 before instruction pc = address (here) after instruction if flag<1> = 0; pc = address (false) if flag<1> = 1; pc = address (true) btg bit toggle f syntax: [ label ] btg f,b operands: 0 f 255 0 b < 7 operation: (f ) (f) status affected: none encoding: 0011 1bbb ffff ffff description: bit ? b ? in data memory location ? f ? is inverted. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write register ? f ? example : btg portc, 4 before instruction: portc = 0111 0101 [0x75] after instruction: portc = 0110 0101 [0x65]
? 2000 microchip technology inc. ds30289b-page 207 pic17c7xx call subroutine call syntax: [ label ] call k operands: 0 k 8191 operation: pc+ 1 tos, k pc<12:0>, k<12:8> pclath<4:0>; pc<15:13> pclath<7:5> status affected: none encoding: 111k kkkk kkkk kkkk description: subroutine call within 8k page. first, return address (pc+1) is pushed onto the stack. the 13-bit value is loaded into pc bits<12:0>. then the upper- eight bits of the pc are copied into pclath. call is a two-cycle instruction. see lcall for calls outside 8k memory space. words: 1 cycles: 2 q cycle activity: q1 q2 q3 q4 decode read literal ? k ? <7:0>, push pc to stack process data write to pc no operation no operation no operation no operation example : here call there before instruction pc = address (here) after instruction pc = address (there) tos = address (here + 1) clrf clear f syntax: [ label ] clrf f,s operands: 0 f 255 operation: 00h f, s [0,1] 00h dest status affected: none encoding: 0010 100s ffff ffff description: clears the contents of the specified register(s). s = 0: data memory location ? f ? and wreg are cleared. s = 1: data memory location ? f ? is cleared. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write register ? f ? and if specified wreg example : clrf flag_reg, 1 before instruction flag_reg = 0x5a wreg = 0x01 after instruction flag_reg = 0x00 wreg = 0x01
pic17c7xx ds30289b-page 208 ? 2000 microchip technology inc. clrwdt clear watchdog timer syntax: [ label ] clrwdt operands: none operation: 00h wdt 0 wdt postscaler, 1 to 1 pd status affected: to , pd encoding: 0000 0000 0000 0100 description: clrwdt instruction resets the watch- dog timer. it also resets the postscaler of the wdt. status bits to and pd are set. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode no operation process data no operation example : clrwdt before instruction wdt counter = ? after instruction wdt counter = 0x00 wdt postscaler = 0 to =1 pd =1 comf complement f syntax: [ label ] comf f,d operands: 0 f 255 d [0,1] operation: (dest) status affected: z encoding: 0001 001d ffff ffff description: the contents of register ? f ? are comple- mented. if ? d ? is 0 the result is stored in wreg. if ? d ? is 1 the result is stored back in register ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example : comf reg1,0 before instruction reg1 = 0x13 after instruction reg1 = 0x13 wreg = 0xec (f)
? 2000 microchip technology inc. ds30289b-page 209 pic17c7xx cpfseq compare f with wreg, skip if f = wreg syntax: [ label ] cpfseq f operands: 0 f 255 operation: (f) ? (wreg), skip if (f) = (wreg) (unsigned comparison) status affected: none encoding: 0011 0001 ffff ffff description: compares the contents of data memory location ? f ? to the contents of wreg by performing an unsigned subtraction. if ? f ? = wreg, then the fetched instruc- tion is discarded and a nop is executed instead, making this a two-cycle instruction. words: 1 cycles: 1 (2) q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data no operation if skip: q1 q2 q3 q4 no operation no operation no operation no operation example : here cpfseq reg nequal : equal : before instruction pc address = here wreg = ? reg = ? after instruction if reg = wreg; pc = address (equal) if reg wreg; pc = address (nequal) cpfsgt compare f with wreg, skip if f > wreg syntax: [ label ] cpfsgt f operands: 0 f 255 operation: (f) ? ( wreg), skip if (f) > (wreg) (unsigned comparison) status affected: none encoding: 0011 0010 ffff ffff description: compares the contents of data memory location ? f ? to the contents of the wreg by performing an unsigned subtraction. if the contents of ? f ? are greater than the contents of wreg, then the fetched instruction is discarded and a nop is executed instead, making this a two-cycle instruction. words: 1 cycles: 1 (2) q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data no operation if skip: q1 q2 q3 q4 no operation no operation no operation no operation example : here cpfsgt reg ngreater : greater : before instruction pc = address (here) wreg = ? after instruction if reg > wreg; pc = address (greater) if reg wreg; pc = address (ngreater)
pic17c7xx ds30289b-page 210 ? 2000 microchip technology inc. cpfslt compare f with wreg, skip if f < wreg syntax: [ label ] cpfslt f operands: 0 f 255 operation: (f) ? ( wreg), skip if (f) < (wreg) (unsigned comparison) status affected: none encoding: 0011 0000 ffff ffff description: compares the contents of data memory location ? f ? to the contents of wreg by performing an unsigned subtraction. if the contents of ? f ? are less than the contents of wreg, then the fetched instruction is discarded and a nop is executed instead, making this a two-cycle instruction. words: 1 cycles: 1 (2) q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data no operation if skip: q1 q2 q3 q4 no operation no operation no operation no operation example : here cpfslt reg nless : less : before instruction pc = address (here) w= ? after instruction if reg < wreg; pc = address (less) if reg wreg; pc = address (nless) daw decimal adjust wreg register syntax: [ label ] daw f,s operands: 0 f 255 s [0,1] operation: if [ [wreg<7:4> > 9].or.[c = 1] ].and. [wreg<3:0> > 9] then wreg<7:4> + 7 f<7:4>, s<7:4>; if [wreg<7:4> > 9].or.[c = 1] then wreg<7:4> + 6 f<7:4>, s<7:4>; else wreg<7:4> f<7:4>, s<7:4>; if [wreg<3:0> > 9].or.[dc = 1] then wreg<3:0> + 6 f<3:0>, s<3:0>; else wreg<3:0> f<3:0>, s<3:0> status affected: c encoding: 0010 111s ffff ffff description: daw adjusts the eight-bit value in wreg, resulting from the earlier addi- tion of two variables (each in packed bcd format) and produces a correct packed bcd result. s = 0: result is placed in data memory location ? f ? and wreg. s = 1: result is placed in data memory location ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write register ? f ? and other specified register example : daw reg1, 0 before instruction wreg = 0xa5 reg1 = ?? c=0 dc = 0 after instruction wreg = 0x05 reg1 = 0x05 c=1 dc = 0
? 2000 microchip technology inc. ds30289b-page 211 pic17c7xx decf decrement f syntax: [ label ] decf f,d operands: 0 f 255 d [0,1] operation: (f) ? 1 (dest) status affected: ov, c, dc, z encoding: 0000 011d ffff ffff description: decrement register ? f ? . if ? d ? is 0, the result is stored in wreg. if ? d ? is 1, the result is stored back in register ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example : decf cnt, 1 before instruction cnt = 0x01 z=0 after instruction cnt = 0x00 z=1 decfsz decrement f, skip if 0 syntax: [ label ] decfsz f,d operands: 0 f 255 d [0,1] operation: (f) ? 1 (dest); skip if result = 0 status affected: none encoding: 0001 011d ffff ffff description: the contents of register ? f ? are decre- mented. if ? d ? is 0, the result is placed in wreg. if ? d ? is 1, the result is placed back in register ? f ? . if the result is 0, the next instruction, which is already fetched is discarded and a nop is executed instead, making it a two-cycle instruction. words: 1 cycles: 1(2) q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination if skip: q1 q2 q3 q4 no operation no operation no operation no operation example : here decfsz cnt, 1 goto here nzero zero before instruction pc = address (here) after instruction cnt = cnt - 1 if cnt = 0; pc = address (here) if cnt 0; pc = address (nzero)
pic17c7xx ds30289b-page 212 ? 2000 microchip technology inc. dcfsnz decrement f, skip if not 0 syntax: [ label ] dcfsnz f,d operands: 0 f 255 d [0,1] operation: (f) ? 1 (dest); skip if not 0 status affected: none encoding: 0010 011d ffff ffff description: the contents of register ? f ? are decre- mented. if ? d ? is 0, the result is placed in wreg. if ? d ? is 1, the result is placed back in register ? f ? . if the result is not 0, the next instruc- tion, which is already fetched is dis- carded and a nop is executed instead, making it a two-cycle instruction. words: 1 cycles: 1(2) q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination if skip: q1 q2 q3 q4 no operation no operation no operation no operation example : here dcfsnz temp, 1 zero : nzero : before instruction temp_value = ? after instruction temp_value = temp_value - 1, if temp_value = 0; pc = address (zero ) if temp_value 0; pc = address (nzero) goto unconditional branch syntax: [ label ] goto k operands: 0 k 8191 operation: k pc<12:0>; k<12:8> pclath<4:0>, pc <15 :13> pclath<7:5> status affected: none encoding: 110k kkkk kkkk kkkk description: goto allows an unconditional branch anywhere within an 8k page boundary. the thirteen-bit immediate value is loaded into pc bits <12:0>. then the upper eight bits of pc are loaded into pclath. goto is always a two-cycle instruction. words: 1 cycles: 2 q cycle activity: q1 q2 q3 q4 decode read literal ? k ? process data write to pc no operation no operation no operation no operation example : goto there after instruction pc = address (there)
? 2000 microchip technology inc. ds30289b-page 213 pic17c7xx incf increment f syntax: [ label ] incf f,d operands: 0 f 255 d [0,1] operation: (f) + 1 (dest) status affected: ov, c, dc, z encoding: 0001 010d ffff ffff description: the contents of register ? f ? are incre- mented. if ? d ? is 0, the result is placed in wreg. if ? d ? is 1, the result is placed back in register ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example : incf cnt, 1 before instruction cnt = 0xff z=0 c=? after instruction cnt = 0x00 z=1 c=1 incfsz increment f, skip if 0 syntax: [ label ] incfsz f,d operands: 0 f 255 d [0,1] operation: (f) + 1 (dest) skip if result = 0 status affected: none encoding: 0001 111d ffff ffff description: the contents of register ? f ? are incre- mented. if ? d ? is 0, the result is placed in wreg. if ? d ? is 1, the result is placed back in register ? f ? . if the result is 0, the next instruction, which is already fetched is discarded and a nop is executed instead, making it a two-cycle instruction. words: 1 cycles: 1(2) q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination if skip: q1 q2 q3 q4 no operation no operation no operation no operation example : here incfsz cnt, 1 nzero : zero : before instruction pc = address (here) after instruction cnt = cnt + 1 if cnt = 0; pc = address (zero) if cnt 0; pc = address (nzero)
pic17c7xx ds30289b-page 214 ? 2000 microchip technology inc. infsnz increment f, skip if not 0 syntax: [ label ] infsnz f,d operands: 0 f 255 d [0,1] operation: (f) + 1 (dest), skip if not 0 status affected: none encoding: 0010 010d ffff ffff description: the contents of register ? f ? are incre- mented. if ? d ? is 0, the result is placed in wreg. if ? d ? is 1, the result is placed back in register ? f ? . if the result is not 0, the next instruction, which is already fetched is discarded and a nop is executed instead, making it a two-cycle instruction. words: 1 cycles: 1(2) q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination if skip: q1 q2 q3 q4 no operation no operation no operation no operation example : here infsnz reg, 1 zero nzero before instruction reg = reg after instruction reg = reg + 1 if reg = 1; pc = address (zero) if reg = 0; pc = address (nzero) iorlw inclusive or literal with wreg syntax: [ label ] iorlw k operands: 0 k 255 operation: (wreg) .or. (k) (wreg) status affected: z encoding: 1011 0011 kkkk kkkk description: the contents of wreg are or ? ed with the eight-bit literal 'k'. the result is placed in wreg. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read literal 'k' process data write to wreg example : iorlw 0x35 before instruction wreg = 0x9a after instruction wreg = 0xbf
? 2000 microchip technology inc. ds30289b-page 215 pic17c7xx iorwf inclusive or wreg with f syntax: [ label ] iorwf f,d operands: 0 f 255 d [0,1] operation: (wreg) .or. (f) (dest) status affected: z encoding: 0000 100d ffff ffff description: inclusive or wreg with register ? f ? . if ? d ? is 0, the result is placed in wreg. if ? d ? is 1, the result is placed back in register ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example : iorwf result, 0 before instruction result = 0x13 wreg = 0x91 after instruction result = 0x13 wreg = 0x93 lcall long call syntax: [ label ] lcall k operands: 0 k 255 operation: pc + 1 tos; k pcl, (pclath) pch status affected: none encoding: 1011 0111 kkkk kkkk description: lcall allows an unconditional subrou- tine call to anywhere within the 64k program memory space. first, the return address (pc + 1) is pushed onto the stack. a 16-bit desti- nation address is then loaded into the program counter. the lower 8-bits of the destination address are embedded in the instruction. the upper 8-bits of pc are loaded from pc high holding latch, pclath. words: 1 cycles: 2 q cycle activity: q1 q2 q3 q4 decode read literal ? k ? process data write register pcl no operation no operation no operation no operation example : movlw high(subroutine) movpf wreg, pclath lcall low(subroutine) before instruction subroutine = 16-bit address pc = ? after instruction pc = address (subroutine)
pic17c7xx ds30289b-page 216 ? 2000 microchip technology inc. movfp move f to p syntax: [ label ] movfp f,p operands: 0 f 255 0 p 31 operation: (f) (p) status affected: none encoding: 011p pppp ffff ffff description: move data from data memory location ? f ? to data memory location ? p ? . location ? f ? can be anywhere in the 256 byte data space (00h to ffh), while ? p ? can be 00h to 1fh. either ? p' or 'f' can be wreg (a useful, special situation). movfp is particularly useful for transfer- ring a data memory location to a periph- eral register (such as the transmit buffer or an i/o port). both 'f' and 'p' can be indirectly addressed. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register 'f' process data write register 'p' example : movfp reg1, reg2 before instruction reg1 = 0x33, reg2 = 0x11 after instruction reg1 = 0x33, reg2 = 0x33 movlb move literal to low nibble in bsr syntax: [ label ] movlb k operands: 0 k 15 operation: k (bsr<3:0>) status affected: none encoding: 1011 1000 uuuu kkkk description: the four-bit literal ? k ? is loaded in the bank select register (bsr). only the low 4-bits of the bank select register are affected. the upper half of the bsr is unchanged. the assembler will encode the ? u ? fields as '0'. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read literal 'k' process data write literal 'k' to bsr<3:0> example : movlb 5 before instruction bsr register = 0x22 after instruction bsr register = 0x25 (bank 5)
? 2000 microchip technology inc. ds30289b-page 217 pic17c7xx movlr move literal to high nibble in bsr syntax: [ label ] movlr k operands: 0 k 15 operation: k (bsr<7:4>) status affected: none encoding: 1011 101x kkkk uuuu description: the 4-bit literal ? k ? is loaded into the most significant 4-bits of the bank select register (bsr). only the high 4-bits of the bank select register are affected. the lower half of the bsr is unchanged. the assembler will encode the ? u ? fields as 0. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read literal 'k' process data write literal 'k' to bsr<7:4> example : movlr 5 before instruction bsr register = 0x22 after instruction bsr register = 0x52 movlw move literal to wreg syntax: [ label ] movlw k operands: 0 k 255 operation: k (wreg) status affected: none encoding: 1011 0000 kkkk kkkk description: the eight-bit literal 'k' is loaded into wreg. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read literal 'k' process data write to wreg example : movlw 0x5a after instruction wreg = 0x5a
pic17c7xx ds30289b-page 218 ? 2000 microchip technology inc. movpf move p to f syntax: [ label ] movpf p,f operands: 0 f 255 0 p 31 operation: (p) (f) status affected: z encoding: 010p pppp ffff ffff description: move data from data memory location ? p ? to data memory location ? f ? . location ? f ? can be anywhere in the 256 byte data space (00h to ffh), while ? p ? can be 00h to 1fh. either ? p ? or ? f ? can be wreg (a useful, special situation). movpf is particularly useful for transfer- ring a peripheral register (e.g. the timer or an i/o port) to a data memory loca- tion. both ? f ? and ? p ? can be indirectly addressed. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? p ? process data write register ? f ? example : movpf reg1, reg2 before instruction reg1 = 0x11 reg2 = 0x33 after instruction reg1 = 0x11 reg2 = 0x11 movwf move wreg to f syntax: [ label ] movwf f operands: 0 f 255 operation: (wreg) (f) status affected: none encoding: 0000 0001 ffff ffff description: move data from wreg to register ? f ? . location ? f ? can be anywhere in the 256 byte data space. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write register ? f ? example : movwf reg before instruction wreg = 0x4f reg = 0xff after instruction wreg = 0x4f reg = 0x4f
? 2000 microchip technology inc. ds30289b-page 219 pic17c7xx mullw multiply literal with wreg syntax: [ label ] mullw k operands: 0 k 255 operation: (k x wreg) prodh:prodl status affected: none encoding: 1011 1100 kkkk kkkk description: an unsigned multiplication is carried out between the contents of wreg and the 8-bit literal ? k ? . the 16-bit result is placed in prodh:prodl register pair. prodh contains the high byte. wreg is unchanged. none of the status flags are affected. note that neither overflow, nor carry is possible in this operation. a zero result is possible, but not detected. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read literal ? k ? process data write registers prodh: prodl example : mullw 0xc4 before instruction wreg = 0xe2 prodh = ? prodl = ? after instruction wreg = 0xc4 prodh = 0xad prodl = 0x08 mulwf multiply wreg with f syntax: [ label ] mulwf f operands: 0 f 255 operation: (wreg x f) prodh:prodl status affected: none encoding: 0011 0100 ffff ffff description: an unsigned multiplication is carried out between the contents of wreg and the register file location ? f ? . the 16-bit result is stored in the prodh:prodl register pair. prodh contains the high byte. both wreg and ? f ? are unchanged. none of the status flags are affected. note that neither overflow, nor carry is possible in this operation. a zero result is possible, but not detected. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write registers prodh: prodl example : mulwf reg before instruction wreg = 0xc4 reg = 0xb5 prodh = ? prodl = ? after instruction wreg = 0xc4 reg = 0xb5 prodh = 0x8a prodl = 0x94
pic17c7xx ds30289b-page 220 ? 2000 microchip technology inc. negw negate w syntax: [ label ] negw f,s operands: 0 f 255 s [0,1] operation: wreg + 1 (f); wreg + 1 s status affected: ov, c, dc, z encoding: 0010 110s ffff ffff description: wreg is negated using two ? s comple- ment. if 's' is 0, the result is placed in wreg and data memory location 'f'. if 's' is 1, the result is placed only in data memory location 'f'. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register 'f' process data write register 'f' and other specified register example : negw reg,0 before instruction wreg = 0011 1010 [0x3a], reg = 1010 1011 [0xab] after instruction wreg = 1100 0110 [0xc6] reg = 1100 0110 [0xc6] nop no operation syntax: [ label ] nop operands: none operation: no operation status affected: none encoding: 0000 0000 0000 0000 description: no operation. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode no operation no operation no operation example : none.
? 2000 microchip technology inc. ds30289b-page 221 pic17c7xx retfie return from interrupt syntax: [ label ] retfie operands: none operation: tos (pc); 0 glintd; pclath is unchanged. status affected: glintd encoding: 0000 0000 0000 0101 description: return from interrupt. stack is pop ? ed and top-of-stack (tos) is loaded in the pc. interrupts are enabled by clearing the glintd bit. glintd is the global interrupt disable bit (cpusta<4>). words: 1 cycles: 2 q cycle activity: q1 q2 q3 q4 decode no operation clear glintd pop pc from stack no operation no operation no operation no operation example : retfie after interrupt pc = tos glintd = 0 retlw return literal to wreg syntax: [ label ] retlw k operands: 0 k 255 operation: k (wreg); tos (pc); pclath is unchanged status affected: none encoding: 1011 0110 kkkk kkkk description: wreg is loaded with the eight-bit literal 'k'. the program counter is loaded from the top of the stack (the return address). the high address latch (pclath) remains unchanged. words: 1 cycles: 2 q cycle activity: q1 q2 q3 q4 decode read literal 'k' process data pop pc from stack, write to wreg no operation no operation no operation no operation example : call table ; wreg contains table ; offset value ; wreg now has ; table value : table addwf pc ; wreg = offset retlw k0 ; begin table retlw k1 ; : : retlw kn ; end of table before instruction wreg = 0x07 after instruction wreg = value of k7
pic17c7xx ds30289b-page 222 ? 2000 microchip technology inc. return return from subroutine syntax: [ label ] return operands: none operation: tos pc; status affected: none encoding: 0000 0000 0000 0010 description: return from subroutine. the stack is popped and the top of the stack (tos) is loaded into the program counter. words: 1 cycles: 2 q cycle activity: q1 q2 q3 q4 decode no operation process data pop pc from stack no operation no operation no operation no operation example : return after interrupt pc = tos rlcf rotate left f through carry syntax: [ label ] rlcf f,d operands: 0 f 255 d [0,1] operation: f d; f<7> c; c d<0> status affected: c encoding: 0001 101d ffff ffff 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 wreg. if ? d ? is 1, the result is stored back in register ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example : rlcf reg,0 before instruction reg = 1110 0110 c= 0 after instruction reg = 1110 0110 wreg = 1100 1100 c= 1 c register f
? 2000 microchip technology inc. ds30289b-page 223 pic17c7xx rlncf rotate left f (no carry) syntax: [ label ] rlncf f,d operands: 0 f 255 d [0,1] operation: f d; f<7> d<0> status affected: none encoding: 0010 001d ffff ffff description: the contents of register ? f ? are rotated one bit to the left. if ? d ? is 0, the result is placed in wreg. if ? d ? is 1, the result is stored back in register ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example : rlncf reg, 1 before instruction c= 0 reg = 1110 1011 after instruction c= reg = 1101 0111 register f rrcf rotate right f through carry syntax: [ label ] rrcf f,d operands: 0 f 255 d [0,1] operation: f d; f<0> c; c d<7> status affected: c encoding: 0001 100d ffff ffff 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 wreg. if ? d ? is 1, the result is placed back in register ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example : rrcf reg1,0 before instruction reg1 = 1110 0110 c= 0 after instruction reg1 = 1110 0110 wreg = 0111 0011 c= 0 c register f
pic17c7xx ds30289b-page 224 ? 2000 microchip technology inc. rrncf rotate right f (no carry) syntax: [ label ] rrncf f,d operands: 0 f 255 d [0,1] operation: f d; f<0> d<7> status affected: none encoding: 0010 000d ffff ffff description: the contents of register ? f ? are rotated one bit to the right. if ? d ? is 0, the result is placed in wreg. if ? d ? is 1, the result is placed back in register ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example 1 : rrncf reg, 1 before instruction wreg = ? reg = 1101 0111 after instruction wreg = 0 reg = 1110 1011 example 2 : rrncf reg, 0 before instruction wreg = ? reg = 1101 0111 after instruction wreg = 1110 1011 reg = 1101 0111 register f setf set f syntax: [ label ] setf f,s operands: 0 f 255 s [0,1] operation: ffh f; ffh d status affected: none encoding: 0010 101s ffff ffff description: if ? s ? is 0, both the data memory location ? f ? and wreg are set to ffh. if ? s ? is 1, only the data memory location ? f ? is set to ffh. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write register ? f ? and other specified register example1 : setf reg, 0 before instruction reg = 0xda wreg = 0x05 after instruction reg = 0xff wreg = 0xff example2 : setf reg, 1 before instruction reg = 0xda wreg = 0x05 after instruction reg = 0xff wreg = 0x05
? 2000 microchip technology inc. ds30289b-page 225 pic17c7xx sleep enter sleep mode syntax: [ label ] sleep operands: none operation: 00h wdt; 0 wdt postscaler; 1 to ; 0 pd status affected: to , pd encoding: 0000 0000 0000 0011 description: the power-down status bit (pd ) is cleared. the time-out status bit (to ) is set. watchdog timer and its postscaler are cleared. the processor is put into sleep mode with the oscillator stopped. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode no operation process data go to sleep example : sleep before instruction to =? pd =? after instruction to =1 ? pd =0 ? if wdt causes wake-up, this bit is cleared sublw subtract wreg from literal syntax: [ label ]sublw k operands: 0 k 255 operation: k ? (wreg) ( wreg) status affected: ov, c, dc, z encoding: 1011 0010 kkkk kkkk description: wreg is subtracted from the eight-bit literal ? k ? . the result is placed in wreg. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read literal ? k ? process data write to wreg example 1 : sublw 0x02 before instruction wreg = 1 c=? after instruction wreg = 1 c = 1 ; result is positive z=0 example 2 : before instruction wreg = 2 c=? after instruction wreg = 0 c = 1 ; result is zero z=1 example 3 : before instruction wreg = 3 c=? after instruction wreg = ff ; (2 ? s complement) c = 0 ; result is negative z=0
pic17c7xx ds30289b-page 226 ? 2000 microchip technology inc. subwf subtract wreg from f syntax: [ label ] subwf f,d operands: 0 f 255 d [0,1] operation: (f) ? (w) ( dest) status affected: ov, c, dc, z encoding: 0000 010d ffff ffff description: subtract wreg from register 'f' (2 ? s complement method). if 'd' is 0, the result is stored in wreg. if 'd' is 1, the result is stored back in register 'f'. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register 'f' process data write to destination example 1 : subwf reg1, 1 before instruction reg1 = 3 wreg = 2 c=? after instruction reg1 = 1 wreg = 2 c = 1 ; result is positive z=0 example 2 : before instruction reg1 = 2 wreg = 2 c=? after instruction reg1 = 0 wreg = 2 c = 1 ; result is zero z=1 example 3 : before instruction reg1 = 1 wreg = 2 c=? after instruction reg1 = ff wreg = 2 c = 0 ; result is negative z=0 subwfb subtract wreg from f with borrow syntax: [ label ] subwfb f,d operands: 0 f 255 d [0,1] operation: (f) ? (w) ? c ( dest) status affected: ov, c, dc, z encoding: 0000 001d ffff ffff description: subtract wreg and the carry flag (borrow) from register 'f' (2 ? s comple- ment method). if 'd' is 0, the result is stored in wreg. if 'd' is 1, the result is stored back in register 'f'. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register 'f' process data write to destination example 1 : subwfb reg1, 1 before instruction reg1 = 0x19 ( 0001 1001 ) wreg = 0x0d ( 0000 1101 ) c=1 after instruction reg1 = 0x0c ( 0000 1011 ) wreg = 0x0d ( 0000 1101 ) c = 1 ; result is positive z=0 example2 : subwfb reg1,0 before instruction reg1 = 0x1b ( 0001 1011 ) wreg = 0x1a ( 0001 1010 ) c=0 after instruction reg1 = 0x1b ( 0001 1011 ) wreg = 0x00 c = 1 ; result is zero z=1 example3 : subwfb reg1,1 before instruction reg1 = 0x03 ( 0000 0011 ) wreg = 0x0e ( 0000 1101 ) c=1 after instruction reg1 = 0xf5 ( 1111 0100 ) [2 ? s comp] wreg = 0x0e ( 0000 1101 ) c = 0 ; result is negative z=0
? 2000 microchip technology inc. ds30289b-page 227 pic17c7xx swapf swap f syntax: [ label ] swapf f,d operands: 0 f 255 d [0,1] operation: f<3:0> dest<7:4>; f<7:4> dest<3:0> status affected: none encoding: 0001 110d ffff ffff description: the upper and lower nibbles of register ? f ? are exchanged. if ? d ? is 0, the result is placed in wreg. if ? d ? is 1, the result is placed in register ? f ? . words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write to destination example : swapf reg, 0 before instruction reg = 0x53 after instruction reg = 0x35 tablrd table read syntax: [ label ] tablrd t,i,f operands: 0 f 255 i [0,1] t [0,1] operation: if t = 1, tblath f; if t = 0, tblatl f; prog mem (tblptr) tblat; if i = 1, tblptr + 1 tblptr if i = 0, tblptr is unchanged status affected: none encoding: 1010 10ti ffff ffff description: 1. a byte of the table latch (tblat) is moved to register file ? f ? . if t = 1: the high byte is moved; if t = 0: the low byte is moved. 2. then, the contents of the pro- gram memory location pointed to by the 16-bit table pointer (tblptr) are loaded into the 16-bit table latch (tblat). 3. if i = 1: tblptr is incremented; if i = 0: tblptr is not incremented. words: 1 cycles: 2 (3-cycle if f = pcl) q cycle activity: q1 q2 q3 q4 decode read register tblath or tblatl process data write register ? f ? no operation no operation (table pointer on address bus) no operation no operation (oe goes low)
pic17c7xx ds30289b-page 228 ? 2000 microchip technology inc. tablrd table read example1 : tablrd 1, 1, reg ; before instruction reg = 0x53 tblath = 0xaa tblatl = 0x55 tblptr = 0xa356 memory(tblptr) = 0x1234 after instruction (table write completion) reg = 0xaa tblath = 0x12 tblatl = 0x34 tblptr = 0xa357 memory(tblptr) = 0x5678 example2 : tablrd 0, 0, reg ; before instruction reg = 0x53 tblath = 0xaa tblatl = 0x55 tblptr = 0xa356 memory(tblptr) = 0x1234 after instruction (table write completion) reg = 0x55 tblath = 0x12 tblatl = 0x34 tblptr = 0xa356 memory(tblptr) = 0x1234 tablwt table write syntax: [ label ] tablwt t,i,f operands: 0 f 255 i [0,1] t [0,1] operation: if t = 0, f tblatl; if t = 1, f tblath; tblat prog mem (tblptr); if i = 1, tblptr + 1 tblptr if i = 0, tblptr is unchanged status affected: none encoding: 1010 11ti ffff ffff description: 1. load value in ? f ? into 16-bit table latch (tblat) if t = 1: load into high byte; if t = 0: load into low byte 2. the contents of tblat are writ- ten to the program memory location pointed to by tblptr. if tblptr points to external program memory location, then the instruction takes two-cycle. if tblptr points to an internal eprom location, then the instruction is terminated when an interrupt is received. note: the mclr /v pp pin must be at the programming voltage for successful programming of internal memory. if mclr /v pp = v dd the programming sequence of internal memory will be interrupted. a short write will occur (2 t cy ). the internal memory location will not be affected. 3. the tblptr can be automati- cally incremented if i = 1; tblptr is not incremented if i = 0; tblptr is incremented words: 1 cycles: 2 (many if write is to on-chip eprom program memory) q cycle activity: q1 q2 q3 q4 decode read register 'f' process data write register tblath or tblatl no operation no operation (table pointer on address bus) no operation no operation (table latch on address bus, wr goes low)
? 2000 microchip technology inc. ds30289b-page 229 pic17c7xx tablwt table write example1 : tablwt 1, 1, reg before instruction reg = 0x53 tblath = 0xaa tblatl = 0x55 tblptr = 0xa356 memory(tblptr) = 0xffff after instruction (table write completion) reg = 0x53 tblath = 0x53 tblatl = 0x55 tblptr = 0xa357 memory(tblptr - 1) = 0x5355 example 2 : tablwt 0, 0, reg before instruction reg = 0x53 tblath = 0xaa tblatl = 0x55 tblptr = 0xa356 memory(tblptr) = 0xffff after instruction (table write completion) reg = 0x53 tblath = 0xaa tblatl = 0x53 tblptr = 0xa356 memory(tblptr) = 0xaa53 program memory 16 bits 15 0 tblptr tblat data memory 8 bits 15 8 70 tlrd table latch read syntax: [ label ] tlrd t,f operands: 0 f 255 t [0,1] operation: if t = 0, tblatl f; if t = 1, tblath f status affected: none encoding: 1010 00tx ffff ffff description: read data from 16-bit table latch (tblat) into file register ? f ? . table latch is unaffected. if t = 1; high byte is read if t = 0; low byte is read this instruction is used in conjunction with tablrd to transfer data from pro- gram memory to data memory. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register tblath or tblatl process data write register ? f ? example : tlrd t, ram before instruction t=0 ram = ? tblat = 0x00af (tblath = 0x00) (tblatl = 0xaf) after instruction ram = 0xaf tblat = 0x00af (tblath = 0x00) (tblatl = 0xaf) before instruction t=1 ram = ? tblat = 0x00af (tblath = 0x00) (tblatl = 0xaf) after instruction ram = 0x00 tblat = 0x00af (tblath = 0x00) (tblatl = 0xaf) program memory 16 bits 15 0 tblptr tblat data memory 8 bits 15 8 70
pic17c7xx ds30289b-page 230 ? 2000 microchip technology inc. tlwt table latch write syntax: [ label ] tlwt t,f operands: 0 f 255 t [0,1] operation: if t = 0, f tblatl; if t = 1, f tblath status affected: none encoding: 1010 01tx ffff ffff description: data from file register ? f ? is written into the 16-bit table latch (tblat). if t = 1; high byte is written if t = 0; low byte is written this instruction is used in conjunction with tablwt to transfer data from data memory to program memory. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data write register tblath or tblatl example : tlwt t, ram before instruction t=0 ram = 0xb7 tblat = 0x0000 (tblath = 0x00) (tblatl = 0x00) after instruction ram = 0xb7 tblat = 0x00b7 (tblath = 0x00) (tblatl = 0xb7) before instruction t=1 ram = 0xb7 tblat = 0x0000 (tblath = 0x00) (tblatl = 0x00) after instruction ram = 0xb7 tblat = 0xb700 (tblath = 0xb7) (tblatl = 0x00) tstfsz test f, skip if 0 syntax: [ label ] tstfsz f operands: 0 f 255 operation: skip if f = 0 status affected: none encoding: 0011 0011 ffff ffff description: if ? f ? = 0, the next instruction, fetched during the current instruction execution, is discarded and a nop is executed, making this a two-cycle instruction. words: 1 cycles: 1 (2) q cycle activity: q1 q2 q3 q4 decode read register ? f ? process data no operation if skip: q1 q2 q3 q4 no operation no operation no operation no operation example : here tstfsz cnt nzero : zero : before instruction pc = address ( here ) after instruction if cnt = 0x00, pc = address (zero) if cnt ? 0x00, pc = address (nzero)
? 2000 microchip technology inc. ds30289b-page 231 pic17c7xx xorlw exclusive or literal with wreg syntax: [ label ] xorlw k operands: 0 k 255 operation: (wreg) .xor. k ( wreg) status affected: z encoding: 1011 0100 kkkk kkkk description: the contents of wreg are xor ? ed with the 8-bit literal 'k'. the result is placed in wreg. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read literal 'k' process data write to wreg example : xorlw 0xaf before instruction wreg = 0xb5 after instruction wreg = 0x1a xorwf exclusive or wreg with f syntax: [ label ] xorwf f,d operands: 0 f 255 d [0,1] operation: (wreg) .xor. (f) ( dest) status affected: z encoding: 0000 110d ffff ffff description: exclusive or the contents of wreg with register 'f'. if 'd' is 0, the result is stored in wreg. if 'd' is 1, the result is stored back in the register 'f'. words: 1 cycles: 1 q cycle activity: q1 q2 q3 q4 decode read register 'f' process data write to destination example : xorwf reg, 1 before instruction reg = 0xaf 1010 1111 wreg = 0xb5 1011 0101 after instruction reg = 0x1a 0001 1010 wreg = 0xb5
pic17c7xx ds30289b-page 232 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 233 pic17c7xx 19.0 development support the picmicro ? 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 c17 and mplab c18 c compilers -mplink tm object linker/ mplib tm object librarian  simulators - mplab sim software simulator  emulators - mplab ice 2000 in-circuit emulator - icepic ? in-circuit emulator  in-circuit debugger - mplab icd for pic16f87x  device programmers -pro mate ? ii universal device programmer - picstart ? plus entry-level development programmer  low cost demonstration boards - picdem tm 1 demonstration board - picdem 2 demonstration board - picdem 3 demonstration board - picdem 17 demonstration board -k ee l oq ? demonstration board 19.1 mplab integrated development environment software the mplab ide software brings an ease of software development previously unseen in the 8-bit microcon- troller market. the mplab ide is a windows ? -based application that contains:  an interface to debugging tools - simulator - programmer (sold separately) - emulator (sold separately) - in-circuit debugger (sold separately)  a full-featured editor  a project manager  customizable toolbar and key mapping  a status bar  on-line help the mplab ide allows you to:  edit your source files (either assembly or ? c ? )  one touch assemble (or compile) and download to picmicro emulator and simulator tools (auto- matically updates all project information)  debug using: - source files - absolute listing file - machine code the ability to use mplab ide with multiple debugging tools allows users to easily switch from the cost- effective simulator to a full-featured emulator with minimal retraining. 19.2 mpasm assembler the mpasm assembler is a full-featured universal macro assembler for all picmicro mcu ? s. the mpasm assembler has a command line interface and a windows shell. it can be used as a stand-alone application on a windows 3.x or greater system, or it can be used through mplab ide. the mpasm assem- bler generates relocatable object files for the mplink object linker, intel ? standard hex files, map files to detail memory usage and symbol reference, an abso- lute lst file that contains source lines and generated machine code, and a cod file 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. 19.3 mplab c17 and mplab c18 c compilers the mplab c17 and mplab c18 code development systems are complete ansi ? c ? compilers for microchip ? s pic17cxxx and pic18cxxx family of microcontrollers, respectively. these compilers provide powerful integration capabilities and ease of use not found with other compilers. for easier source level debugging, the compilers pro- vide symbol information that is compatible with the mplab ide memory display.
pic17c7xx ds30289b-page 234 ? 2000 microchip technology inc. 19.4 mplink object linker/ mplib object librarian the mplink object linker combines relocatable objects created by the mpasm assembler and the mplab c17 and mplab c18 c compilers. it can also link relocatable objects from pre-compiled libraries, using directives from a linker script. the mplib object librarian is a librarian for pre- compiled code to be used with the mplink object linker. when a routine from a library is called from another 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 mplib object librarian manages the creation and modification of library files. the mplink object linker features include:  integration with mpasm assembler and mplab c17 and mplab c18 c compilers.  allows all memory areas to be defined as sections to provide link-time flexibility. the mplib object librarian features include:  easier linking because single libraries can be included instead of many smaller files.  helps keep code maintainable by grouping related modules together.  allows libraries to be created and modules to be added, listed, replaced, deleted or extracted. 19.5 mplab sim software simulator the mplab sim software simulator allows code devel- opment in a pc-hosted environment by simulating the picmicro series microcontrollers on an instruction level. on any given instruction, the data areas can be examined or modified and stimuli can be applied from a file, or user-defined key press, to any of the pins. the execution can be performed in single step, execute until break, or trace mode. the mplab sim simulator fully supports symbolic debug- ging using the mplab c17 and the mplab c18 c com- pilers and the mpasm assembler. the software simulator offers the flexibility to develop and debug code outside of the laboratory environment, making it an excellent multi- project software development tool. 19.6 mplab ice high performance universal in-circuit emulator with mplab ide the mplab ice universal in-circuit emulator is intended to provide the product development engineer with a complete microcontroller design tool set for picmicro microcontrollers (mcus). software control of the mplab ice in-circuit emulator is provided by the mplab integrated development environment (ide), which allows editing, building, downloading and source debugging from a single environment. the mplab ice 2000 is a full-featured emulator sys- tem with enhanced trace, trigger and data monitoring features. interchangeable processor modules allow the system to be easily reconfigured for emulation of differ- ent processors. the universal architecture of the mplab ice in-circuit emulator allows expansion to support new picmicro microcontrollers. the mplab ice in-circuit emulator system has been designed as a real-time emulation system, with advanced features that are generally found on more expensive development tools. the pc platform and microsoft ? windows environment were chosen to best make these features available to you, the end user. 19.7 icepic in-circuit emulator the icepic low cost, in-circuit emulator is a solution for the microchip technology pic16c5x, pic16c6x, pic16c7x and pic16cxxx families of 8-bit one- time-programmable (otp) microcontrollers. the mod- ular system can support different subsets of pic16c5x or pic16cxxx products through the use of inter- changeable personality modules, or daughter boards. the emulator is capable of emulating without target application circuitry being present.
? 2000 microchip technology inc. ds30289b-page 235 pic17c7xx 19.8 mplab icd in-circuit debugger microchip ? s in-circuit debugger, mplab icd, is a pow- erful, low cost, run-time development tool. this tool is based on the flash pic16f87x and can be used to develop for this and other picmicro microcontrollers from the pic16cxxx family. the mplab icd utilizes the in-circuit debugging capability built into the pic16f87x. this feature, along with microchip ? s in-circuit serial programming 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 watching variables, single- stepping and setting break points. running at full speed enables testing hardware in real-time. 19.9 pro mate ii universal device programmer the pro mate ii universal device programmer is a full-featured programmer, capable of operating in stand-alone mode, as well as pc-hosted mode. the pro mate ii device programmer is ce compliant. the pro mate ii device programmer has program- mable v dd and v pp supplies, which allow it to verify programmed memory at v dd min and v dd max for max- imum reliability. it has an lcd display for instructions and error messages, keys to enter commands and a modular detachable socket assembly to support various package types. in stand-alone mode, the pro mate ii device programmer can read, verify, or program picmicro devices. it can also set code protection in this mode. 19.10 picstart plus entry level development programmer the picstart plus development programmer is an easy-to-use, low cost, prototype programmer. it con- nects 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 sup- ports all picmicro devices with 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. 19.11 picdem 1 low cost picmicro demonstration board the picdem 1 demonstration board is a simple board which demonstrates the capabilities of several of microchip ? s microcontrollers. the microcontrollers sup- ported are: pic16c5x (pic16c54 to pic16c58a), pic16c61, pic16c62x, pic16c71, pic16c8x, pic17c42, pic17c43 and pic17c44. all necessary hardware and software is included to run basic demo programs. the user can program the sample microcon- trollers provided with the picdem 1 demonstration board on a pro mate ii device programmer, or a picstart plus development programmer, and easily test firmware. the user can also connect the picdem 1 demonstration board to the mplab ice in- circuit emulator and download the firmware to the emu- lator for testing. a prototype area is available for the user to build some additional hardware and connect it to the microcontroller socket(s). some of the features include an rs-232 interface, a potentiometer for simu- lated analog input, push button switches and eight leds connected to portb. 19.12 picdem 2 low cost pic16cxx demonstration board the picdem 2 demonstration board is a simple dem- onstration board that supports the pic16c62, pic16c64, pic16c65, pic16c73 and pic16c74 microcontrollers. all the necessary hardware and soft- ware is included to run the basic demonstration pro- grams. the user can program the sample microcontrollers provided with the picdem 2 demon- stration board on a pro mate ii device programmer, or a picstart plus development programmer, and easily test firmware. the mplab ice in-circuit emula- tor may also be used with the picdem 2 demonstration board to test firmware. a prototype area has been pro- vided to the user for adding additional hardware and connecting it to the microcontroller socket(s). some of the features include a rs-232 interface, push button switches, a potentiometer for simulated analog input, a serial eeprom to demonstrate usage of the i 2 c tm bus and separate headers for connection to an lcd module and a keypad.
pic17c7xx ds30289b-page 236 ? 2000 microchip technology inc. 19.13 picdem 3 low cost pic16cxxx demonstration board the picdem 3 demonstration board is a simple dem- onstration board that supports the pic16c923 and pic16c924 in the plcc package. it will also support future 44-pin plcc microcontrollers with an lcd mod- ule. all the necessary hardware and software is included to run the basic demonstration programs. the user can program the sample microcontrollers pro- vided with the picdem 3 demonstration board on a pro mate ii device programmer, or a picstart plus development programmer with an adapter socket, and easily test firmware. the mplab ice in-circuit emula- tor may also be used with the picdem 3 demonstration board to test firmware. a prototype area has been pro- vided to the user for adding hardware and connecting it to the microcontroller socket(s). some of the features include a rs-232 interface, push button switches, a potentiometer for simulated analog input, a thermistor and separate headers for connection to an external lcd module and a keypad. also provided on the picdem 3 demonstration board is a lcd panel, with 4 commons and 12 segments, that is capable of display- ing time, temperature and day of the week. the picdem 3 demonstration board provides an additional rs-232 interface and windows software for showing the demultiplexed lcd signals on a pc. a simple serial interface allows the user to construct a hardware demultiplexer for the lcd signals. 19.14 picdem 17 demonstration board the picdem 17 demonstration board is an evaluation board that demonstrates the capabilities of several microchip microcontrollers, including pic17c752, pic17c756a, pic17c762 and pic17c766. all neces- sary hardware is included to run basic demo programs, which are supplied on a 3.5-inch disk. a programmed sample is included and the user may erase it and program it with the other sample programs using the pro mate ii device programmer, or the picstart plus development programmer, and easily debug and test the sample code. in addition, the picdem 17 dem- onstration board supports downloading of programs to and executing out of external flash memory on board. the picdem 17 demonstration board is also usable with the mplab ice in-circuit emulator, or the picmaster emulator and all of the sample programs can be run and modified using either emulator. addition- ally, a generous prototype area is available for user hardware. 19.15 k ee l oq evaluation and programming tools k ee l oq evaluation and programming tools support microchip ? s hcs secure data products. the hcs eval- uation kit includes a lcd display to show changing codes, a decoder to decode transmissions and a pro- gramming interface to program test transmitters.
? 2000 microchip technology inc. ds30289b-page 237 pic17c7xx table 19-1: development tools from microchip pic12cxxx pic14000 pic16c5x pic16c6x pic16cxxx pic16f62x pic16c7x pic16c7xx pic16c8x pic16f8xx pic16c9xx pic17c4x pic17c7xx pic18cxx2 24cxx/ 25cxx/ 93cxx hcsxxx mcrfxxx mcp2510 software tools mplab ? integrated development environment mplab ? c17 c compiler mplab ? c18 c compiler mpasm tm assembler/ mplink tm object linker emulators mplab ? ice in-circuit emulator ** icepic tm in-circuit emulator debugger mplab ? icd in-circuit debugger * * programmers picstart ? plus entry level development programmer ** pro mate ? ii universal device programmer ** demo boards and eval kits picdem tm 1 demonstration board ? picdem tm 2 demonstration board ? ? picdem tm 3 demonstration board picdem tm 14a demonstration board picdem tm 17 demonstration board k ee l oq ? evaluation kit k ee l oq ? transponder kit microid tm programmer ? s kit 125 khz microid tm developer ? s kit 125 khz anticollision microid tm developer ? s kit 13.56 mhz anticollision microid tm developer ? s kit mcp2510 can developer ? s kit * contact the microchip technology inc. web site at www.microchip.com for information on how to use the mplab ? icd in-circuit debugger (dv164001) with pic16c62, 63, 64, 65, 72, 73, 74, 76, 77. ** contact microchip technology inc. for availability date. ? development tool is available on select devices.
pic17c7xx ds30289b-page 238 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 239 pic17c7xx 20.0 pic17c7xx electrical characteristics absolute maximum ratings ? ambient temperature under bias................................................................................................. ............-55 c to +125 c storage temperature ............................................................................................................ .................. -65 c to +150 c voltage on v dd with respect to v ss ........................................................................................................... 0 v to +7.5 v voltage on mclr with respect to v ss (note 2) ....................................................................................... -0.3 v to +14 v voltage on ra2 and ra3 with respect to v ss .......................................................................................... -0.3 v to +8.5 v voltage on all other pins with respect to v ss ...................................................................................-0.3 v to v dd + 0.3 v total power dissipation (note 1) ..............................................................................................................................1 .0 w maximum current out of v ss pin(s) - total (@ 70 c) ............................................................................................500 ma maximum current into v dd pin(s) - total (@ 70 c) ...............................................................................................500 ma input clamp current, i ik (v i < 0 or v i > v dd ) .......................................................................................................... 20 ma output clamp current, i ok (v o < 0 or v o > v dd ) ...................................................................................................20 ma maximum output current sunk by any i/o pin (except ra2 and ra3)................................................................ .....35 ma maximum output current sunk by ra2 or ra3 pins ................................................................................. ...............60 ma maximum output current sourced by any i/o pin .................................................................................. ..................20 ma maximum current sunk by porta and portb (combined)............................................................................. ....150 ma maximum current sourced by porta and portb (combined) .......................................................................... .100 ma maximum current sunk by portc, portd and porte (combined)..................................................................150 ma maximum current sourced by portc, portd and porte (combined) ............................................................100 ma maximum current sunk by portf and portg (combined) ............................................................................. ...150 ma maximum current sourced by portf and portg (combined).......................................................................... .100 ma maximum current sunk by porth and portj (combined)............................................................................. ....150 ma maximum current sourced by porth and portj (combined) .......................................................................... .100 ma note 1: power dissipation is calculated as follows: pdis = v dd x {i dd - i oh } + {(v dd -v oh ) x i oh } + (v ol x i ol ) 2: voltage spikes below v ss at the mclr pin, inducing currents greater than 80 ma, may cause latch-up. thus, a series resistor of 50-100 ? should be used when applying a "low" level to the mclr pin, rather than pulling this pin directly to v ss . ? notice: stresses above those listed under "absolute maximum ratings" may cause permanent dam- age 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 to maximum rating conditions for extended periods may affect device reliability.
pic17c7xx ds30289b-page 240 ? 2000 microchip technology inc. figure 20-1: pic17c7xx-33 voltage-frequency graph figure 20-2: pic17c7xx-16 voltage-frequency graph frequency voltage 6.0 v 5.5 v 4.5 v 4.0 v 2.0 v 33 mhz 5.0 v 3.5 v 3.0 v 2.5 v pic17c7xx-33 frequency voltage 6.0 v 5.5 v 4.5 v 4.0 v 2.0 v 16 mhz 5.0 v 3.5 v 3.0 v 2.5 v pic17c7xx-16
? 2000 microchip technology inc. ds30289b-page 241 pic17c7xx figure 20-3: pic17lc7xx-08 voltage-frequency graph figure 20-4: pic17c7xx/cl voltage-frequency graph frequency voltage 6.0 v 5.5 v 4.5 v 4.0 v 2.0 v 8 mhz 5.0 v 3.5 v 3.0 v 2.5 v pic17lc7xx-08 frequency voltage 6.0 v 5.5 v 4.5 v 4.0 v 2.0 v 8 mhz 5.0 v 3.5 v 3.0 v 2.5 v 33 mhz pic17c7xx/cl
pic17c7xx ds30289b-page 242 ? 2000 microchip technology inc. 20.1 dc characteristics pic17lc7xx-08 (commercial, industrial) standard operating conditions (unless otherwise stated) operating temperature -40 c t a +85 c for industrial and 0 c t a +70 c for commercial pic17c7xx-16 (commercial, industrial, extended) pic17c7xx-33 (commercial, industrial, extended) standard operating conditions (unless otherwise stated) operating temperature -40 c t a +125 c for extended -40 c t a +85 c for industrial 0 c t a +70 c for commercial param. no. sym characteristic min typ ? max units conditions d001 v dd supply voltage pic17lc7xx 3.0 ? 5.5 v d001 pic17c7xx-33 pic17c7xx-16 4.5 v bor ? ? 5.5 5.5 v v (bor enabled) (note 5) d002 v dr ram data retention voltage (note 1) 1.5 ?? v device in sleep mode d003 v por v dd start voltage to ensure internal power-on reset signal ? vss ? v see section on power-on reset for details d004 s vdd v dd rise rate to ensure proper operation pic17lcxx 0.010 ?? v/ms see section on power-on reset for details d004 pic17cxx 0.085 ? ? v/ms see section on power-on reset for details d005 v bor brown-out reset voltage trip point 3.65 ? 4.35 v d006 v portp power-on reset trip point ? 2.2 ? vv dd = v portp ? data in "typ" column is at 5v, 25 c unless otherwise stated. note 1: this is the limit to which v dd can be lowered in sleep mode without losing ram data. 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 pattern and temperature also have an impact on the current consumption. 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 or v ss , t0cki = v dd , mclr = v dd ; wdt disabled. current consumed from the oscillator and i/o ? s driving external capacitive or resistive loads needs to be considered. for the rc oscillator, the current through the external pull-up resistor (r) can be estimated as: v dd /(2 ? r). for capacitive loads, the current can be estimated (for an individual i/o pin) as (c l ? v dd ) ? f c l = total capacitive load on the i/o pin; f = average frequency the i/o pin switches. the capacitive currents are most significant when the device is configured for external execution (includes extended microcontroller mode). 3: 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 hi-impedance state and tied to v dd or v ss . 4: for rc osc configuration, current through r ext is not included. the current through the resistor can be esti- mated by the formula i r = v dd /2r ext (ma) with r ext in kohm. 5: this is the voltage where the device enters the brown-out reset. when bor is enabled, the device (-16) will operate correctly to this trip point.
? 2000 microchip technology inc. ds30289b-page 243 pic17c7xx d010 i dd supply current (note 2) pic17lc7xx ? 36maf osc = 4 mhz (note 4) d010 pic17c7xx ? 3 6 ma f osc = 4 mhz (note 4) d011 pic17lc7xx ? 510maf osc = 8 mhz d011 d012 pic17c7xx ? ? 5 9 10 18 ma ma f osc = 8 mhz f osc = 16 mhz d014 pic17lc7xx ? 85 150 af osc = 32 khz, (ec osc configuration) d015 pic17c7xx ? 15 30 ma f osc = 33 mhz d021 i pd power-down current (note 3) pic17lc7xx ? <1 5 av dd = 3.0v, wdt disabled d021 (commercial, industrial) pic17c7xx ? <1 20 a v dd = 5.5v, wdt disabled d021a (extended) ? 2 20 a v dd = 5.5v, wdt disabled module differential current d023 ? i bor bor circuitry ? 75 150 av dd = 4.5v, boden enabled d024 ? i wdt watchdog timer ? 10 35 av dd = 5.5v d026 ? i ad a/d converter ? 1 ? av dd = 5.5v, a/d not converting pic17lc7xx-08 (commercial, industrial) standard operating conditions (unless otherwise stated) operating temperature -40 c t a +85 c for industrial and 0 c t a +70 c for commercial pic17c7xx-16 (commercial, industrial, extended) pic17c7xx-33 (commercial, industrial, extended) standard operating conditions (unless otherwise stated) operating temperature -40 c t a +125 c for extended -40 c t a +85 c for industrial 0 c t a +70 c for commercial param. no. sym characteristic min typ ? max units conditions ? data in "typ" column is at 5v, 25 c unless otherwise stated. note 1: this is the limit to which v dd can be lowered in sleep mode without losing ram data. 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 pattern and temperature also have an impact on the current consumption. 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 or v ss , t0cki = v dd , mclr = v dd ; wdt disabled. current consumed from the oscillator and i/o ? s driving external capacitive or resistive loads needs to be considered. for the rc oscillator, the current through the external pull-up resistor (r) can be estimated as: v dd /(2 ? r). for capacitive loads, the current can be estimated (for an individual i/o pin) as (c l ? v dd ) ? f c l = total capacitive load on the i/o pin; f = average frequency the i/o pin switches. the capacitive currents are most significant when the device is configured for external execution (includes extended microcontroller mode). 3: 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 hi-impedance state and tied to v dd or v ss . 4: for rc osc configuration, current through r ext is not included. the current through the resistor can be esti- mated by the formula i r = v dd /2r ext (ma) with r ext in kohm. 5: this is the voltage where the device enters the brown-out reset. when bor is enabled, the device (-16) will operate correctly to this trip point.
pic17c7xx ds30289b-page 244 ? 2000 microchip technology inc. 20.2 dc characteristics: pic17c7xx-16 (commercial, industrial, extended) pic17c7xx-33 (commercial, industrial, extended) pic17lc7xx-08 (commercial, industrial) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40 c t a +125 c for extended -40 c t a +85 c for industrial 0 c t a +70 c for commercial operating voltage v dd range as described in section 20.1 param. no. sym characteristic min typ ? max units conditions input low voltage v il i/o ports d030 with ttl buffer (note 6) vss vss ? ? 0.8 0.2v dd v v 4.5v v dd 5.5v 3.0v v dd 4.5v d031 with schmitt trigger buffer ra2, ra3 all others vss vss ? ? 0.3v dd 0.2v dd v v i 2 c compliant d032 mclr , osc1 (in ec and rc mode) vss ? 0.2v dd v (note 1) d033 osc1 (in xt, and lf mode) ? 0.5v dd ? v input high voltage v ih i/o ports d040 with ttl buffer (note 6) 2.0 1 + 0.2v dd ? ? v dd v dd v v 4.5v v dd 5.5v 3.0v v dd 4.5v d041 with schmitt trigger buffer ra2, ra3 all others 0.7v dd 0.8v dd ? ? v dd v dd v v i 2 c compliant d042 mclr 0.8v dd ? v dd v (note 1) d043 osc1 (xt, and lf mode) ? 0.5v dd ? v d050 v hys hysteresis of schmitt trigger inputs 0.15v dd ?? v ? data in ? typ ? column is at 5v, 25 c unless otherwise stated. note 1: in rc oscillator configuration, the osc1/clkin pin is a schmitt trigger input. it is not recommended that the pic17cxxx devices be driven with external clock in rc mode. 2: the leakage current on the mclr pin is strongly dependent on the applied voltage level. higher leakage current may be measured at different input voltages. 3: negative current is defined as current sourced by the pin. 4: these specifications are for the programming of the on-chip program memory eprom through the use of the table write instructions. the complete programming specifications can be found in: pic17c7xx programming specifications (literature number ds tbd). 5: the mclr /v pp pin may be kept in this range at times other than programming, but is not recommended. 6: for ttl buffers, the better of the two specifications may be used.
? 2000 microchip technology inc. ds30289b-page 245 pic17c7xx input leakage current (notes 2, 3) d060 i il i/o ports (except ra2, ra3) ?? 1 avss v pin v dd , i/o pin (in digital mode) at hi-impedance portb weak pull-ups disabled d061 mclr , test ?? 2 av pin = vss or v pin = v dd d062 ra2, ra3 2 avss v ra 2, v ra 3 12v d063 osc1 (ec, rc modes) ?? 1 avss v pin v dd d063b osc1 (xt, lf modes) ?? v pin ar f 1 m ? d064 mclr , test ?? 25 av mclr = v pp = 12v (when not programming) d070 i purb portb weak pull-up current 85 130 260 a v pin = v ss , rbpu = 0 4.5v v dd 5.5v output low voltage d080 d081 v ol i/o ports with ttl buffer ? ? ? ? ? ? 0.1v dd 0.1v dd 0.4 v v v i ol = v dd /1.250 ma 4.5v v dd 5.5v v dd = 3.0v i ol = 6 ma, v dd = 4.5v (note 6) d082 ra2 and ra3 ? ? ? ? 3.0 0.6 v v i ol = 60.0 ma, v dd = 5.5v i ol = 60.0 ma, v dd = 4.5v d083 d084 osc2/clkout (rc and ec osc modes) ? ? ? ? 0.4 0.1v dd v v i ol = 1 ma, v dd = 4.5v i ol = v dd /5 ma (pic17lc7xx only) output high voltage (note 3) d090 d091 v oh i/o ports (except ra2 and ra3) with ttl buffer 0.9v dd 0.9v dd 2.4 ? ? ? ? ? ? v v v i oh = -v dd /2.5 ma 4.5v v dd 5.5v v dd = 3.0v i oh = -6.0 ma, v dd =4.5v (note 6) d093 d094 osc2/clkout (rc and ec osc modes) 2.4 0.9v dd ? ? ? ? v v i oh = -5 ma, v dd = 4.5v i oh = -v dd /5 ma (pic17lc7xx only) dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40 c t a +125 c for extended -40 c t a +85 c for industrial 0 c t a +70 c for commercial operating voltage v dd range as described in section 20.1 param. no. sym characteristic min typ ? max units conditions ? data in ? typ ? column is at 5v, 25 c unless otherwise stated. note 1: in rc oscillator configuration, the osc1/clkin pin is a schmitt trigger input. it is not recommended that the pic17cxxx devices be driven with external clock in rc mode. 2: the leakage current on the mclr pin is strongly dependent on the applied voltage level. higher leakage current may be measured at different input voltages. 3: negative current is defined as current sourced by the pin. 4: these specifications are for the programming of the on-chip program memory eprom through the use of the table write instructions. the complete programming specifications can be found in: pic17c7xx programming specifications (literature number ds tbd). 5: the mclr /v pp pin may be kept in this range at times other than programming, but is not recommended. 6: for ttl buffers, the better of the two specifications may be used.
pic17c7xx ds30289b-page 246 ? 2000 microchip technology inc. d150 v od open drain high voltage ?? 8.5 v ra2 and ra3 pins only pulled up to externally applied voltage capacitive loading specs on output pins d100 c osc 2 osc2/clkout pin ?? 25 pf in ec or rc osc modes, when osc2 pin is outputting clkout. external clock is used to drive osc1. d101 c io all i/o pins and osc2 (in rc mode) ?? 50 pf d102 c ad system interface bus (portc, portd and porte) ?? 50 pf in microprocessor or extended microcontroller mode internal program memory programming specs (note 4) d110 d111 d112 d113 d114 v pp v ddp i pp i ddp t prog voltage on mclr /v pp pin supply voltage during programming current into mclr /v pp pin supply current during programming programming pulse width 12.75 4.75 ? ? 100 ? 5.0 25 ? ? 13.25 5.25 50 30 1000 v v ma ma ms (note 5) terminated via internal/ external interrupt or a reset dc characteristics standard operating conditions (unless otherwise stated) operating temperature -40 c t a +125 c for extended -40 c t a +85 c for industrial 0 c t a +70 c for commercial operating voltage v dd range as described in section 20.1 param. no. sym characteristic min typ ? max units conditions ? data in ? typ ? column is at 5v, 25 c unless otherwise stated. note 1: in rc oscillator configuration, the osc1/clkin pin is a schmitt trigger input. it is not recommended that the pic17cxxx devices be driven with external clock in rc mode. 2: the leakage current on the mclr pin is strongly dependent on the applied voltage level. higher leakage current may be measured at different input voltages. 3: negative current is defined as current sourced by the pin. 4: these specifications are for the programming of the on-chip program memory eprom through the use of the table write instructions. the complete programming specifications can be found in: pic17c7xx programming specifications (literature number ds tbd). 5: the mclr /v pp pin may be kept in this range at times other than programming, but is not recommended. 6: for ttl buffers, the better of the two specifications may be used. note 1: when using the table write for internal programming, the device temperature must be less than 40 c. 2: for in-circuit serial programming (icsp ? ), refer to the device programming specification.
? 2000 microchip technology inc. ds30289b-page 247 pic17c7xx 20.3 timing parameter symbology the timing parameter symbols have been created following one of the following formats: 1. tpps2pps 3. t cc : st (i 2 c specifications only) 2. tpps 4. ts (i 2 c specifications only) t f frequency t time lowercase symbols (pp) and their meanings: pp ad address/data ost oscillator start-up timer al ale pwrt power-up timer cc capture1 and capture2 rb portb ck clkout or clock rd rd dt data in rw rd or wr in int pin t0 t0cki io i/o port t123 tclk12 and tclk3 mc mclr wdt watchdog timer oe oe wr wr os osc1 uppercase symbols and their meanings: s ddriven l low eedge pperiod ffall rrise h high v valid i invalid (hi-impedance) z hi-impedance
pic17c7xx ds30289b-page 248 ? 2000 microchip technology inc. figure 20-5: parameter measurement information 0.9 v dd 0.1 v dd rise time fall time v oh = 0.7v dd v dd /2 v ol = 0.3v dd data out valid data out invalid output hi-impedance output driven 0.25v 0.25v 0.25v 0.25v output level conditions portc, d, e, f, g, h and j pins all other input pins v ih = 2.4v v il = 0.4v data in valid data in invalid v ih = 0.9v dd v il = 0.1v dd data in valid data in invalid input level conditions load conditions load condition 1 pin c l v ss 50 pf c l all timings are measured between high and low measurement points as indicated below.
? 2000 microchip technology inc. ds30289b-page 249 pic17c7xx 20.4 timing diagrams and specifications figure 20-6: external clock timing table 20-1: external clock timing requirements osc1 osc2 ? q4 q1 q2 q3 q4 q1 1 3 3 4 4 2 ? in ec and rc modes only. param no. sym characteristic min typ ? max units conditions f osc external clkin frequency (note 1) dc dc dc ? ? ? 8 16 33 mhz mhz mhz ec osc mode - 08 devices (8 mhz devices) - 16 devices (16 mhz devices) - 33 devices (33 mhz devices) oscillator frequency (note 1) dc 2 2 2 dc ? ? ? ? ? 4 8 16 33 2 mhz mhz mhz mhz mhz rc osc mode xt osc mode - 08 devices (8 mhz devices) - 16 devices (16 mhz devices) - 33 devices (33 mhz devices) lf osc mode 1t osc external clkin period (note 1) 125 62.5 30.3 ? ? ? ? ? ? ns ns ns ec osc mode - 08 devices (8 mhz devices) - 16 devices (16 mhz devices) - 33 devices (33 mhz devices) oscillator period (note 1) 250 125 62.5 30.3 500 ? ? ? ? ? ? 1,000 1,000 1,000 ? ns ns ns ns ns rc osc mode xt osc mode - 08 devices (8 mhz devices) - 16 devices (16 mhz devices) - 33 devices (33 mhz devices) lf osc mode 2t cy instruction cycle time (note 1) 121.2 4/f osc dc ns 3tosl, to s h clock in (osc1) high or low time 10 ?? ns ec oscillator 4tosr, to sf clock in (osc1) rise or fall time ?? 5 ns ec oscillator ? data in ? typ ? column is at 5v, 25 c unless otherwise stated. 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 are tested to operate at ? min. ? values with an external clock applied to the osc1/clkin pin. when an external clock input is used, the ? max. ? cycle time limit is ? dc ? (no clock) for all devices.
pic17c7xx ds30289b-page 250 ? 2000 microchip technology inc. figure 20-7: clkout and i/o timing table 20-2: clkout and i/o timing requirements osc1 osc2 ? i/o pin (input) i/o pin (output) q4 q1 q2 q3 10 13 14 17 20, 21 22 23 19 18 15 11 12 16 old value new value ? in ec and rc modes only. param no. sym characteristic min typ? max units conditions 10 tosl2ckl osc1 to clkout ? 15 30 ns (note 1) 11 tosl2ckh osc1 to clkout ? 15 30 ns (note 1) 12 tckr clkout rise time ? 5 15 ns (note 1) 13 tckf clkout fall time ? 5 15 ns (note 1) 14 tckh2iov clkout to port out valid ?? 0.5t cy + 20 ns (note 1) 15 tiov2ckh port in valid before clkout 0.25t cy + 25 ?? ns (note 1) 16 tckh2ioi port in hold after clkout 0 ?? ns (note 1) 17 tosl2iov osc1 (q1 cycle) to port out valid ?? 100 ns 18 tosl2ioi osc1 (q2 cycle) to port input invalid (i/o in hold time) 0 ?? ns 19 tiov2osl port input valid to osc1 (i/o in setup time) 30 ?? ns 20 tior port output rise time ? 10 35 ns 21 tiof port output fall time ? 10 35 ns 22 tinhl int pin high or low time 25 ?? ns 23 trbhl rb7:rb0 change int high or low time 25 ?? ns ? data in ? typ ? column is at 5v, 25 c unless otherwise stated. these parameters are for design guidance only and are not tested. note 1: measurements are taken in ec mode, where clkout output is 4 x t osc .
? 2000 microchip technology inc. ds30289b-page 251 pic17c7xx figure 20-8: reset, watchdog timer, oscillator start-up timer, power-up timer, and brown-out reset timing table 20-3: reset, watchdog timer, oscillator start-up timer, power-up timer, and brown-out reset requirements v dd mclr internal por /bor pwrt time-out osc time-out internal reset watchdog timer reset 33 32 30 31 address/ data 35 param. no. sym characteristic min typ ? max units conditions 30 tmcl mclr pulse width (low) 100 ?? ns v dd = 5v 31 t wdt watchdog timer time-out period (postscale = 1) 5 12 25 ms v dd = 5v 32 t ost oscillation start-up timer period ? 1024t osc ? ms t osc = osc1 period 33 t pwrt power-up timer period 40 96 200 ms v dd = 5v 34 t ioz mclr to i/o hi-impedance 100 ?? ns depends on pin load 35 tmcl2adi mclr to system interface bus (ad15:ad0>) invalid pic17 c 7xx ?? 100 ns pic17 lc 7xx ?? 120 ns 36 t bor brown-out reset pulse width (low) 100 ?? ns v dd within v bor limits (parameter d005) ? data in ? typ ? column is at 5v, 25 c unless otherwise stated. .
pic17c7xx ds30289b-page 252 ? 2000 microchip technology inc. figure 20-9: timer0 external clock timings table 20-4: timer0 external clock requirements figure 20-10: timer1, timer2 and timer3 external clock timings table 20-5: timer1, timer2 and timer3 external clock requirements ra1/t0cki 40 41 42 param no. sym characteristic min typ ? max units conditions 40 tt0h t0cki high pulse width no prescaler 0.5t cy + 20 ?? ns with prescaler 10 ?? ns 41 tt0l t0cki low pulse width no prescaler 0.5t cy + 20 ?? ns with prescaler 10 ?? ns 42 tt0p t0cki period greater of: 20 ns or t cy + 40 n ?? ns n = prescale value (1, 2, 4, ..., 256) ? data in "typ" column is at 5v, 25 c unless otherwise stated. tclk12 45 46 or tclk3 tmrx 48 48 47 param no. sym characteristic min typ ? max units conditions 45 tt123h tclk12 and tclk3 high time 0.5t cy + 20 ?? ns 46 tt123l tclk12 and tclk3 low time 0.5t cy + 20 ?? ns 47 tt123p tclk12 and tclk3 input period t cy + 40 n ?? ns n = prescale value (1, 2, 4, 8) 48 tcke2tmri delay from selected external clock edge to timer increment 2t osc ? 6tosc ? ? data in ? typ ? column is at 5v, 25 c unless otherwise stated.
? 2000 microchip technology inc. ds30289b-page 253 pic17c7xx figure 20-11: capture timings table 20-6: capture requirements figure 20-12: pwm timings table 20-7: pwm requirements cap pin (capture mode) 50 51 52 param no. sym characteristic min typ ? max unit s conditions 50 tccl capture pin input low time 10 ?? ns 51 tcch capture pin input high time 10 ?? ns 52 tccp capture pin input period 2t cy n ?? ns n = prescale value (4 or 16) ? data in ? typ ? column is at 5v, 25 c unless otherwise stated. pwm pin (pwm mode) 53 54 param no. sym characteristic min typ ? max units conditions 53 tccr pwm pin output rise time ? 10 35 ns 54 tccf pwm pin output fall time ? 10 35 ns ? data in ? typ ? column is at 5v, 25 c unless otherwise stated.
pic17c7xx ds30289b-page 254 ? 2000 microchip technology inc. figure 20-13: spi master mode timing (cke = 0) table 20-8: spi mode requirements (master mode, cke = 0) ss sck (ckp = 0) sck (ckp = 1) sdo sdi 70 71 72 73 74 75, 76 78 79 80 79 78 msb lsb bit6 - - - - - -1 msb in lsb in bit6 - - - -1 note: refer to figure 20-5 for load conditions. param. no. symbol characteristic min typ ? max units conditions 70 tssl2sch, tssl2scl ss to sck or sck input tcy ?? ns 71 tsch sck input high time (slave mode) continuous 1.25t cy + 30 ?? ns 71a single byte 40 ?? ns (note 1) 72 tscl sck input low time (slave mode) continuous 1.25t cy + 30 ?? ns 72a single byte 40 ?? ns (note 1) 73 tdiv2sch, tdiv2scl setup time of sdi data input to sck edge 100 ?? ns 73a t b 2 b last clock edge of byte1 to the 1st clock edge of byte2 1.5t cy + 40 ?? ns (note 1) 74 tsch2dil, tscl2dil hold time of sdi data input to sck edge 100 ?? ns 75 tdor sdo data output rise time ? 10 25 ns 76 tdof sdo data output fall time ? 10 25 ns 78 tscr sck output rise time (master mode) ? 10 25 ns 79 tscf sck output fall time (master mode) ? 10 25 ns 80 tsch2dov, tscl2dov sdo data output valid after sck edge ?? 50 ns ? data in "typ" column is at 5v, 25 c unless otherwise stated. note 1: specification 73a is only required if specifications 71a and 72a are used.
? 2000 microchip technology inc. ds30289b-page 255 pic17c7xx figure 20-14: spi master mode timing (cke = 1) table 20-9: spi mode requirements (master mode, cke = 1) ss sck (ckp = 0) sck (ckp = 1) sdo sdi 81 71 72 74 75, 76 78 80 msb 79 73 msb in bit6 - - - - - -1 lsb in bit6 - - - -1 lsb note: refer to figure 20-5 for load conditions. param. no. symbol characteristic min typ ? max units conditions 71 tsch sck input high time (slave mode) continuous 1.25t cy + 30 ?? ns 71a single byte 40 ?? ns (note 1) 72 tscl sck input low time (slave mode) continuous 1.25 t cy + 30 ?? ns 72a single byte 40 ?? ns (note 1) 73 tdiv2sch, tdiv2scl setup time of sdi data input to sck edge 100 ?? ns 73a t b 2 b last clock edge of byte1 to the 1st clock edge of byte2 1.5t cy + 40 ?? ns (note 1) 74 tsch2dil, tscl2dil hold time of sdi data input to sck edge 100 ?? ns 75 tdor sdo data output rise time ? 10 25 ns 76 tdof sdo data output fall time ? 10 25 ns 78 tscr sck output rise time (master mode) ? 10 25 ns 79 tscf sck output fall time (master mode) ? 10 25 ns 80 tsch2dov, tscl2dov sdo data output valid after sck edge ?? 50 ns 81 tdov2sch, tdov2scl sdo data output setup to sck edge tcy ?? ns ? data in "typ" column is at 5v, 25 c unless otherwise stated. note 1: specification 73a is only required if specifications 71a and 72a are used.
pic17c7xx ds30289b-page 256 ? 2000 microchip technology inc. figure 20-15: spi slave mode timing (cke = 0) table 20-10: spi mode requirements (slave mode timing, cke = 0) ss sck (ckp = 0) sck (ckp = 1) sdo sdi 70 71 72 73 74 75, 76 77 78 79 80 79 78 sdi msb lsb bit6 - - - - - -1 msb in bit6 - - - -1 lsb in 83 note: refer to figure 20-5 for load conditions. param. no. symbol characteristic min typ ? max units conditions 70 tssl2sch, tssl2scl ss to sck or sck input tcy ?? ns 71 tsch sck input high time (slave mode) continuous 1.25t cy + 30 ?? ns 71a single byte 40 ?? ns (note 1) 72 tscl sck input low time (slave mode) continuous 1.25t cy + 30 ?? ns 72a single byte 40 ?? ns (note 1) 73 tdiv2sch, tdiv2scl setup time of sdi data input to sck edge 100 ?? ns 73a t b 2 b last clock edge of byte1 to the 1st clock edge of byte2 1.5t cy + 40 ?? ns (note 1) 74 tsch2dil, tscl2dil hold time of sdi data input to sck edge 100 ?? ns 75 tdor sdo data output rise time ? 10 25 ns 76 tdof sdo data output fall time ? 10 25 ns 77 tssh2doz ss to sdo output hi-impedance 10 ? 50 ns 78 tscr sck output rise time (master mode) ? 10 25 ns 79 tscf sck output fall time (master mode) ? 10 25 ns 80 tsch2dov, tscl2dov sdo data output valid after sck edge ?? 50 ns 83 tsch2ssh, tscl2ssh ss after sck edge 1.5t cy + 40 ?? ns ? data in "typ" column is at 5v, 25 c unless otherwise stated. note 1: specification 73a is only required if specifications 71a and 72a are used.
? 2000 microchip technology inc. ds30289b-page 257 pic17c7xx figure 20-16: spi slave mode timing (cke = 1) table 20-11: spi mode requirements (slave mode, cke = 1) ss sck (ckp = 0) sck (ckp = 1) sdo sdi 70 71 72 82 sdi 74 75, 76 msb bit6 - - - - - -1 lsb 77 msb in bit6 - - - -1 lsb in 80 83 note: refer to figure 20-5 for load conditions. param. no. symbol characteristic min typ ? max units conditions 70 tssl2sch, tssl2scl ss to sck or sck input tcy ?? ns 71 tsch sck input high time (slave mode) continuous 1.25t cy + 30 ?? ns 71a single byte 40 ?? ns (note 1) 72 tscl sck input low time (slave mode) continuous 1.25t cy + 30 ?? ns 72a single byte 40 ?? ns (note 1) 73a t b 2 b last clock edge of byte1 to the 1st clock edge of byte2 1.5t cy + 40 ?? ns (note 1) 74 tsch2dil, tscl2dil hold time of sdi data input to sck edge 100 ?? ns 75 tdor sdo data output rise time ? 10 25 ns 76 tdof sdo data output fall time ? 10 25 ns 77 tssh2doz ss to sdo output hi-impedance 10 ? 50 ns 80 tsch2dov, tscl2dov sdo data output valid after sck edge ?? 50 ns 82 tssl2dov sdo data output valid after ss edge ?? 50 ns 83 tsch2ssh, tscl2ssh ss after sck edge 1.5t cy + 40 ?? ns ? data in "typ" column is at 5v, 25 c unless otherwise stated. note 1: specification 73a is only required if specifications 71a and 72a are used.
pic17c7xx ds30289b-page 258 ? 2000 microchip technology inc. figure 20-17: i 2 c bus start/stop bits timing table 20-12: i 2 c bus start/stop bits requirements note: refer to figure 20-5 for load conditions. 91 93 scl sda start condition stop condition 90 92 param. no. sym characteristic min ty p max units conditions 90 tsu:sta start condition 100 khz mode 2(t osc )(brg + 1) ?? ns only relevant for repeated start condition setup time 400 khz mode 2(t osc )(brg + 1) ?? 1 mhz mode (1) 2(t osc )(brg + 1) ?? 91 thd:sta start condition 100 khz mode 2(t osc )(brg + 1) ?? ns after this period, the first clock pulse is generated hold time 400 khz mode 2(t osc )(brg + 1) ?? 1 mhz mode (1) 2(t osc )(brg + 1) ?? 92 tsu:sto stop condition 100 khz mode 2(t osc )(brg + 1) ?? ns setup time 400 khz mode 2(t osc )(brg + 1) ?? 1 mhz mode (1) 2(t osc )(brg + 1) ?? 93 thd:sto stop condition 100 khz mode 2(t osc )(brg + 1) ?? ns hold time 400 khz mode 2(t osc )(brg + 1) ?? 1 mhz mode (1) 2(t osc )(brg + 1) ?? note 1: maximum pin capacitance = 10 pf for all i 2 c pins.
? 2000 microchip technology inc. ds30289b-page 259 pic17c7xx figure 20-18: i 2 c bus data timing table 20-13: i 2 c bus data requirements param no. sym characteristic min max units conditions 100 thigh clock high time 100 khz mode 2(t osc )(brg + 1) ? ms 400 khz mode 2(t osc )(brg + 1) ? ms 1 mhz mode (1) 2(t osc )(brg + 1) ? ms 101 tlow clock low time 100 khz mode 2(t osc )(brg + 1) ? ms 400 khz mode 2(t osc )(brg + 1) ? ms 1 mhz mode (1) 2(t osc )(brg + 1) ? ms 102 tr sda and scl rise time 100 khz mode ? 1000 ns cb is specified to be from 10 to 400 pf 400 khz mode 20 + 0.1cb 300 ns 1 mhz mode (1) ? 300 ns 103 tf sda and scl fall time 100 khz mode ? 300 ns cb is specified to be from 10 to 400 pf 400 khz mode 20 + 0.1cb 300 ns 1 mhz mode (1) ? 10 ns 90 tsu:sta start condition setup time 100 khz mode 2(t osc )(brg + 1) ? ms only relevant for repeated start condition 400 khz mode 2(t osc )(brg + 1) ? ms 1 mhz mode (1) 2(t osc )(brg + 1) ? ms 91 thd:sta start condition hold time 100 khz mode 2(t osc )(brg + 1) ? ms after this period, the first clock pulse is generated 400 khz mode 2(t osc )(brg + 1) ? ms 1 mhz mode (1) 2(t osc )(brg + 1) ? ms 106 thd:dat data input hold time 100 khz mode 0 ? ns 400 khz mode 0 0.9 ms 1 mhz mode (1) 0 ? ns 107 tsu:dat data input setup time 100 khz mode 250 ? ns (note 2) 400 khz mode 100 ? ns 1 mhz mode (1) 100 ? ns 92 tsu:sto stop condition setup time 100 khz mode 2(t osc )(brg + 1) ? ms 400 khz mode 2(t osc )(brg + 1) ? ms 1 mhz mode (1) 2(t osc )(brg + 1) ? ms 109 taa output valid from clock 100 khz mode ? 3500 ns 400 khz mode ? 1000 ns 1 mhz mode (1) ? 400 ns note 1: maximum pin capacitance = 10 pf for all i 2 c pins. 2: a fast mode (400 khz) i 2 c bus device can be used in a standard mode i 2 c bus system, but the parameter # 107 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. parameter #102 + #107 = 1000 + 250 = 1250 ns (for 100 khz mode) before the scl line is released. 3: c b is specified to be from 10-400pf. the minimum specifications are characterized with c b =10pf. the rise time spec (t r ) is characterized with r p =r p min. the minimum fall time specification (t f ) is characterized with c b =10pf,and r p =r p max. these are only valid for fast mode operation (v dd =4.5-5.5v) and where the spm bit (sspstat<7>) =1.) 4: max specifications for these parameters are valid for falling edge only. specs are characterized with r p =r p min and c b =400pf for standard mode, 200pf for fast mode, and 10pf for 1mhz mode. note: refer to figure 20-5 for load conditions. 90 91 92 100 101 103 106 107 109 109 110 102 scl sda in sda out
pic17c7xx ds30289b-page 260 ? 2000 microchip technology inc. figure 20-19: usart synchronous transmission (master/slave) timing table 20-14: usart synchronous transmission requirements 110 tbuf bus free time 100 khz mode 4.7 ? ms time the bus must be free before a new transmission can start 400 khz mode 1.3 ? ms 1 mhz mode (1) 0.5 ? ms d102 cb bus capacitive loading ? 400 pf param no. sym characteristic min max units conditions note 1: maximum pin capacitance = 10 pf for all i 2 c pins. 2: a fast mode (400 khz) i 2 c bus device can be used in a standard mode i 2 c bus system, but the parameter # 107 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. parameter #102 + #107 = 1000 + 250 = 1250 ns (for 100 khz mode) before the scl line is released. 3: c b is specified to be from 10-400pf. the minimum specifications are characterized with c b =10pf. the rise time spec (t r ) is characterized with r p =r p min. the minimum fall time specification (t f ) is characterized with c b =10pf,and r p =r p max. these are only valid for fast mode operation (v dd =4.5-5.5v) and where the spm bit (sspstat<7>) =1.) 4: max specifications for these parameters are valid for falling edge only. specs are characterized with r p =r p min and c b =400pf for standard mode, 200pf for fast mode, and 10pf for 1mhz mode. 121 121 120 122 tx/ck rx/dt pin pin param no. sym characteristic min typ ? max units conditions 120 tckh2dtv sync xmit (master & slave) clock high to data out valid pic17 c xxx ?? 50 ns pic17 lc xxx ?? 75 ns 121 tckrf clock out rise time and fall time (master mode) pic17 c xxx ?? 25 ns pic17 lc xxx ?? 40 ns 122 tdtrf data out rise time and fall time pic17 c xxx ?? 25 ns pic17 lc xxx ?? 40 ns ? data in ? typ ? column is at 5v, 25 c unless otherwise stated.
? 2000 microchip technology inc. ds30289b-page 261 pic17c7xx figure 20-20: usart synchronous receive (master/slave) timing table 20-15: usart synchronous receive requirements 125 126 tx/ck rx/dt pin pin param no. sym characteristic min typ ? max unit s conditions 125 tdtv2ckl sync rcv (master & slave) data setup before ck (dt setup time) 15 ?? ns 126 tckl2dtl data hold after ck (dt hold time) 15 ?? ns ? data in ? typ ? column is at 5v, 25 c unless otherwise stated.
pic17c7xx ds30289b-page 262 ? 2000 microchip technology inc. figure 20-21: usart asynchronous mode start bit detect table 20-16: usart asynchronous mode start bit detect requirements figure 20-22: usart asynchronous receive sampling waveform table 20-17: usart asynchronous receive sampling requirements rx x16 clk q2, q4 clk start bit (rx/dt pin) 121a 120a 123a param no. sym characteristic min typ max unit s conditions 120a tdtl2ckh time to ensure that the rx pin is sampled low ?? t cy ns 121a tdtrf data rise time and fall time receive ?? (note 1) ns transmit ?? 40 ns 123a tckh2bckl time from rx pin sampled low to first rising edge of x16 clock ?? t cy ns note 1: schmitt trigger will determine logic level. rx baud clk x16 clk start bit bit0 samples 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 baud clk for all but start bit (rx/dt pin) 125a 126a param no. sym characteristic min typ max unit s conditions 125a tdtl2ckh setup time of rx pin to first data sampled t cy ?? ns 126a tdtl2ckh hold time of rx pin from last data sam- pled t cy ?? ns
? 2000 microchip technology inc. ds30289b-page 263 pic17c7xx table 20-18: a/d converter characteristics param. no. sym characteristic min typ ? max units conditions a01 n r resolution ?? 10 bit v ref + = v dd = 5.12v, v ss v ain v ref + ?? 10 bit (v ref + ? v ref -) 3.0v, v ref - v ain v ref + a02 e abs absolute error ?? < 1lsbv ref + = v dd = 5.12v, v ss v ain v ref + ?? < 1lsb(v ref + ? v ref -) 3.0v, v ref - v ain v ref + a03 e il integral linearity error ?? < 1lsbv ref + = v dd = 5.12v, v ss v ain v ref + ?? < 1lsb(v ref + ? v ref -) 3.0v, v ref - v ain v ref + a04 e dl differential linearity error ?? < 1lsbv ref + = v dd = 5.12v, v ss v ain v ref + ?? < 1lsb(v ref + ? v ref -) 3.0v, v ref - v ain v ref + a05 e fs full scale error ?? < 1lsbv ref + = v dd = 5.12v, v ss v ain v ref + ?? < 1lsb(v ref + ? v ref -) 3.0v, v ref - v ain v ref + a06 e off offset error ?? < 1lsbv ref + = v dd = 5.12v, v ss v ain v ref + ?? < 1lsb(v ref + ? v ref -) 3.0v, v ref - v ain v ref + a10 ? monotonicity ? guaranteed (3) ?? v ss v ain v ref a20 v ref reference voltage (v ref + ? v ref -) 0v ?? vv ref delta when changing voltage levels on v ref inputs a20a 3v ?? v absolute minimum electrical spec. to ensure 10-bit accuracy a21 v ref + reference voltage high a vss + 3.0v ? a vdd + 0.3v v a22 v ref - reference voltage low avss - 0.3v ? a vdd - 3.0v v a25 v ain analog input voltage a vss - 0.3v ? vref + 0.3v v a30 z ain recommended impedance of analog voltage source ?? 10.0 k ? a40 i ad a/d conversion current (v dd ) pic17 c xxx ? 180 ? a average current consumption when a/d is on (note 1) pic17 lc xxx ? 90 ? a a50 i ref v ref input current (note 2) 10 ? 1000 a during v ain acquisition. based on differential of v hold to v ain ?? 10 a during a/d conversion cycle ? data in ? typ ? column is at 5v, 25 c unless otherwise stated. note 1: when a/d is off, it will not consume any current other than minor leakage current. the power-down current spec includes any such leakage from the a/d module. 2: v ref current is from rg0 and rg1 pins or av dd and av ss pins, whichever is selected as reference input. 3: the a/d conversion result never decreases with an increase in the input voltage and has no missing codes.
pic17c7xx ds30289b-page 264 ? 2000 microchip technology inc. figure 20-23: a/d conversion timing table 20-19: a/d conversion requirements param. no. sym characteristic min typ ? max units conditions 130 t ad a/d clock period pic17 c xxx 1.6 ?? st osc based, v ref 3.0v pic17 lc xxx 3.0 ?? st osc based, v ref full range pic17 c xxx 2.0 4.0 6.0 s a/d rc mode pic17 lc xxx 3.0 6.0 9.0 s a/d rc mode 131 t cnv conversion time (not including acquisition time) (note 1) 11 ? 12 tad 132 t acq acquisition time (note 2) 10 20 ? ? ? s s the minimum time is the amplifier settling time. this may be used if the ? new ? input voltage has not changed by more than 1lsb (i.e., 5 mv @ 5.12v) from the last sampled voltage (as stated on c hold ). 134 t go q4 to adclk start ? tosc/2 ? ? 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. ? data in ? typ ? column is at 5v, 25 c unless otherwise stated. note 1: adres register may be read on the following t cy cycle. 2: see section 16.1 for minimum conditions when input voltage has changed more than 1 lsb . 131 130 132 bsf adcon0, go q4 a/d clk a/d data adres adif go sample old_data sampling stopped done new_data (t osc /2) (1) 987 210 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 . . . . . .
? 2000 microchip technology inc. ds30289b-page 265 pic17c7xx figure 20-24: memory interface write timing table 20-20: memory interface write requirements osc1 ale oe wr ad<15:0> q1 q2 q3 q4 q1 q2 150 151 152 153 154 addr out data out addr out q1 param. no. sym characteristic min typ ? max unit s conditions 150 tadv2all ad<15:0> (address) valid to pic17 c xxx 0.25t cy - 10 ?? ns ale (address setup time) pic17 lc xxx 0.25t cy - 10 ?? 151 tall2adi ale to address out invalid pic17 c xxx 0 ?? ns (address hold time) pic17 lc xxx 0 ?? 152 tadv2wrl data out valid to wr pic17 c xxx 0.25t cy - 40 ?? ns (data setup time) pic17 lc xxx 0.25t cy - 40 ?? 153 twrh2adi wr to data out invalid pic17 c xxx ? 0.25t cy ? ns (data hold time) pic17 lc xxx ? 0.25t cy ? 154 twrl wr pulse width pic17 c xxx ? 0.25t cy ? ns pic17 lc xxx ? 0.25t cy ? ? data in ? typ ? column is at 5v, 25 c unless otherwise stated.
pic17c7xx ds30289b-page 266 ? 2000 microchip technology inc. figure 20-25: memory interface read timing table 20-21: memory interface read requirements osc1 ale oe ad<15:0> wr q1 q2 q3 data in addr out 150 151 160 166 165 162 163 161 ? 1 ? ? 1 ? q4 q1 q2 addr out 164 168 167 param. no. sym characteristic min typ ? max unit s conditions 150 tadv2all ad15:ad0 (address) valid to pic17 c xxx 0.25t cy - 10 ?? ns ale (address setup time) pic17 lc xxx 0.25t cy - 10 ?? 151 tall2adi ale to address out invalid pic17 c xxx 5 ?? ns (address hold time) pic17 lc xxx 5 ?? 160 tadz2oel ad15:ad0 hi-impedance to pic17 c xxx 0 ?? ns oe pic17 lc xxx 0 ?? 161 toeh2ad d oe to ad15:ad0 driven pic17 c xxx 0.25t cy - 15 ?? ns pic17 lc xxx 0.25t cy - 15 ?? 162 tadv2oeh data in valid before oe pic17 c xxx 35 ?? ns (data setup time) pic17 lc xxx 45 ?? 163 toeh2adi oe to data in invalid pic17 c xxx 0 ?? ns (data hold time) pic17 lc xxx 0 ?? 164 talh ale pulse width pic17 c xxx ? 0.25t cy ? ns pic17 lc xxx ? 0.25t cy ? 165 toel oe pulse width pic17 c xxx 0.5t cy - 35 ?? ns pic17 lc xxx 0.5t cy - 35 ?? 166 talh2alh ale to ale (cycle time) pic17 c xxx ? t cy ? ns pic17 lc xxx ? t cy ? 167 tacc address access time pic17 c xxx ?? 0.75t cy - 30 ns pic17 lc xxx ?? 0.75t cy - 45 168 toe output enable access time pic17 c xxx ?? 0.5t cy - 45 ns (oe low to data valid) pic17 lc xxx ?? 0.5t cy - 75 ? data in ? typ ? column is at 5v, 25 c unless otherwise stated.
? 2000 microchip technology inc. ds30289b-page 267 pic17c7xx 21.0 pic17c7xx dc and ac characteristics the graphs and tables provided in this section are for design guidance and are not tested nor guaranteed. in some graphs or tables the data presented is outside specified operating range (e.g., outside specified v dd range). this is for information only and devices are ensured to operate properly only within the specified range. the data presented in this section is a statistical summary of data collected on units from different lots over a period of time.  typ or typical represents the mean of the distribution at 25 c.  max or maximum represents (mean + 3 ) over the temperature range of -40 c to 85 c.  min or minimum represents (mean - 3 ) over the temperature range of -40 c to 85 c. note: standard deviation is denoted by sigma ( ). table 21-1: pin capacitance per package type figure 21-1: typical rc oscillator frequency vs. temperature pin name typical capacitance (pf) 68-pin plcc 64-pin tqfp all pins, except mclr , v dd , and v ss 10 10 mclr pin 20 20 fosc fosc (25 c) 1.10 1.08 1.06 1.04 1.02 1.00 0.98 0.96 0.94 0.92 0.90 010 20253040506070 t( c) frequency normalized to +25 c v dd = 5.5v v dd = 3.5v r ext 10 k ? c ext = 100 pf
pic17c7xx ds30289b-page 268 ? 2000 microchip technology inc. figure 21-2: typical rc oscillator frequency vs. v dd figure 21-3: typical rc oscillator frequency vs. v dd 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 0.0 4.0 4.5 5.0 5.5 6.0 6.5 f osc (mhz) v dd (volts) r = 10k c ext = 22 pf, t = +25 c r = 100k 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0.5 0.0 4.0 4.5 5.0 5.5 6.0 6.5 f osc (mhz) v dd (volts) r = 10k c ext = 100 pf, t = +25 c r = 100k r = 3.3k r = 5.1k
? 2000 microchip technology inc. ds30289b-page 269 pic17c7xx figure 21-4: typical rc oscillator frequency vs. v dd table 21-2: rc oscillator frequencies 2.0 1.8 1.6 1.4 1.2 1.0 0.8 0.6 0.4 4.0 4.5 5.0 5.5 6.0 6.5 f osc (mhz) v dd (volts) r = 10k c ext = 300 pf, t = +25 c r = 160k r = 3.3k r = 5.1k 0.2 0.0 c ext r ext average f osc @ 5v, +25 c 22 pf 10k 3.33 mhz 12% 100k 353 khz 13% 100 pf 3.3k 3.54 mhz 10% 5.1k 2.43 mhz 14% 10k 1.30 mhz 17% 100k 129 khz 10% 300 pf 3.3k 1.54 mhz 14% 5.1k 980 khz 12% 10k 564 khz 16% 160k 35 khz 18%
pic17c7xx ds30289b-page 270 ? 2000 microchip technology inc. figure 21-5: transconductance (gm) of lf oscillator vs. v dd figure 21-6: transconductance (gm) of xt oscillator vs. v dd 500 450 400 350 300 250 200 150 100 2.5 3.0 3.5 4.0 4.5 5.0 gm( a/v) v dd (volts) min @ +85 c 50 0 5.5 6.0 max @ -40 c typ @ +25 c 20 18 16 14 12 10 8 6 4 2.5 3.0 3.5 4.0 4.5 5.0 gm(ma/v) v dd (volts) min @ +85 c 2 0 5.5 6.0 max @ -40 c typ @ +25 c
? 2000 microchip technology inc. ds30289b-page 271 pic17c7xx figure 21-7: typical i dd vs. f osc over v dd (lf mode) figure 21-8: maximum i dd vs. f osc over v dd (lf mode) 0.0 0.2 0.4 0.6 0.8 1.0 1.2 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 f osc (mhz) i dd (ma) 3.0v 3.5v 4.0v 5.5v 5.0v 4.5v typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c) 0.0 0.2 0.4 0.6 0.8 1.0 1.2 0.00.20.40.60.81.01.21.41.61.82.0 f osc (m hz) i dd (ma) 3.0v 3.5v 4.0v 5.5v 5.0v 4.5v typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c)
pic17c7xx ds30289b-page 272 ? 2000 microchip technology inc. figure 21-9: typical i dd vs. f osc over v dd (xt mode) figure 21-10: maximum i dd vs. f osc over v dd (xt mode) 0 2 4 6 8 10 12 14 16 0 5 10 15 20 25 30 35 f osc (mhz) i dd (ma) 5.5v 5.0v 4.5v 4.0v 3.5v 3.0v typical: statistical mean @ 25 c max imum: mean + 3 (-40 c to 125 c) minimum: mean ? 3 (-40 c to 125 c) typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c) 0 2 4 6 8 10 12 14 16 18 0 5 10 15 20 25 30 35 f osc (mhz) i dd (ma) 5.5v 5.0v 4.5v 4.0v 3.5v 3.0v typical: statistical mean @ 25 c max imum: mean + 3 (-40 c to 125 c) minimum: mean ? 3 (-40 c to 125 c) typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c)
? 2000 microchip technology inc. ds30289b-page 273 pic17c7xx figure 21-11: typical and maximum i pd vs. v dd (sleep mode, all peripherals disabled, -40 c to +125 c) figure 21-12: typical and maximum i pd vs. v dd (sleep mode, bor enabled, -40 c to +125 c) 0.0 1.0 2.0 3.0 4.0 5.0 6.0 3.03.54.04.55.05.5 v dd (v ) i pd (ua) max typ typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c) 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v ) i dd (ma) max reset typ reset (25c) max sleep typ sleep (25c) device in sleep device in reset indeterminate state typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c)
pic17c7xx ds30289b-page 274 ? 2000 microchip technology inc. figure 21-13: typical and maximum ? i pd vs. v dd (sleep mode, wdt enabled, -40 c to +125 c) figure 21-14: typical and maximum ? i rbpu vs. v dd (measured per input pin, -40 c to +125 c) 0 2 4 6 8 10 12 14 16 18 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v ) i pd (ua) max ty p 0 50 100 150 200 250 300 2.5 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) ? i (ua) typical (25c) maximum typical: statistical mean @ 25 c ma x imu m: mea n + 3 (-40 c to 125 c) minimu m: mea n ? 3 (-40 c to 125 c) typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c)
? 2000 microchip technology inc. ds30289b-page 275 pic17c7xx figure 21-15: typical, minimum and maximum wdt period vs. v dd (-40 c to +125 c) figure 21-16: typical wdt period vs. v dd over temperature (-40 c to +125 c) 0 5 10 15 20 25 30 35 40 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) wdt period (ms) max (125c) typ (25c) min (-40c) typical: statistical mean @ 25 c max imum: mean + 3 (-40 c to 125 c) minimum: mean ? 3 (-40 c to 125 c) typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c) 0 5 10 15 20 25 30 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) wdt period (ms) 125c 85c 25c -40c
pic17c7xx ds30289b-page 276 ? 2000 microchip technology inc. figure 21-17: typical, minimum and maximum v oh vs. i oh (v dd = 5v, -40 c to +125 c) figure 21-18: typical, minimum and maximum v ol vs. i ol (v dd = 5v, -40 c to +125 c) 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 0 5 10 15 20 25 i oh (-m a) v oh (v) max typ (25c) min typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c) 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 0 5 10 15 20 25 i ol (ma) v ol (v) max (125c) typ (25c) min (-40c ) typical: statistical mean @ 25 c maximum: mean + 3 (-40 c to 12 5 c) minimum: mean ? 3 (-40 c to 125 c) typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c)
? 2000 microchip technology inc. ds30289b-page 277 pic17c7xx figure 21-19: typical, minimum and maximum v oh vs. i oh (v dd = 3v, -40 c to +125 c) figure 21-20: typical, minimum and maximum v ol vs. i ol (v dd = 3v, -40 c to +125 c) 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0 5 10 15 20 25 i oh (-m a) v oh (v) max typ (25c) min typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c) 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 0 5 10 15 20 25 i ol (m a) v ol (v) max (125c ) typ (25c) min (-40c) typical: statistical mean @ 25 c max imum: mean + 3 (-40 c to 125 c) minimum: mean ? 3 (-40 c to 125 c) typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c)
pic17c7xx ds30289b-page 278 ? 2000 microchip technology inc. figure 21-21: typical, maximum and minimum v in vs. v dd (ttl input, -40 c to 125 c) figure 21-22: maximum and minimum v in vs. v dd (st input, -40 c to +125 c) 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 3.0 3.5 4.0 4.5 5.0 5.5 v dd (v) v in (v) min max typ (25c) typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c) 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 3 .0 3 .5 4 .0 4 .5 5 .0 5 .5 v dd (v) v in (v) max r is ing min r is ing max falling min falling typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c)
? 2000 microchip technology inc. ds30289b-page 279 pic17c7xx figure 21-23: maximum and minimum v in vs. v dd (i 2 c input, -40 c to +125 c) 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 3.03.54.04.55.05.5 v dd (v) v in (v) max r is ing min r is ing max falling min falling typical: statistical mean @ 25 c maximum: mean + 3s (-40 c to 125 c) minimum: mean ? 3s (-40 c to 125 c)
pic17c7xx ds30289b-page 280 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 281 pic17c7xx 22.0 packaging information 22.1 package marking information 64-lead tqfp xxxxxxxxxx yywwnnn xxxxxxxxxx example xxxxxxxxxx -08i/pt 0017cae pic17c752 legend: xx...x customer specific information* yy year code (last 2 digits of calendar year) ww week code (week of january 1 is week ? 01 ? ) nnn alphanumeric traceability code 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. 68-lead plcc yywwnnn xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx example 0048cae pic17c756a-08/l 80-lead tqfp yywwnnn xxxxxxxxxxxx xxxxxxxxxxxx example 0017cae pic17c762 -08i/pt * standard otp marking consists of microchip part number, year code, week code, facility code, mask rev#, and assembly code. for otp 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.
pic17c7xx ds30289b-page 282 ? 2000 microchip technology inc. package marking information (cont.) 84-lead plcc yywwnnn xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx example 0048cae pic17c766-08/l
? 2000 microchip technology inc. ds30289b-page 283 pic17c7xx 64-lead plastic thin quad flatpack (pt) 10x10x1 mm body, 1.0/0.10 mm lead form (tqfp) * controlling parameter notes: dimensions d1 and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010 ? (0.254mm) per side. jedec equivalent: ms-026 drawing no. c04-085 15 10 5 15 10 5 mold draft angle bottom 15 10 5 15 10 5 mold draft angle top 0.27 0.22 0.17 .011 .009 .007 b lead width 0.23 0.18 0.13 .009 .007 .005 c lead thickness 16 16 n1 pins per side 10.10 10.00 9.90 .398 .394 .390 d1 molded package length 10.10 10.00 9.90 .398 .394 .390 e1 molded package width 12.25 12.00 11.75 .482 .472 .463 d overall length 12.25 12.00 11.75 .482 .472 .463 e overall width 7 3.5 0 7 3.5 0 foot angle 0.75 0.60 0.45 .030 .024 .018 l foot length 0.25 0.15 0.05 .010 .006 .002 a1 standoff 1.05 1.00 0.95 .041 .039 .037 a2 molded package thickness 1.20 1.10 1.00 .047 .043 .039 a overall height 0.50 .020 p pitch 64 64 n number of pins max nom min max nom min dimension limits millimeters* inches units c 2 1 n d d1 b p #leads=n1 e1 e a2 a1 a l ch x 45 (f) footprint (reference) (f) .039 1.00 pin 1 corner chamfer ch .025 .035 .045 0.64 0.89 1.14 significant characteristic
pic17c7xx ds30289b-page 284 ? 2000 microchip technology inc. 68-lead plastic leaded chip carrier (l) ? square (plcc) 10 5 0 10 5 0 mold draft angle bottom 10 5 0 10 5 0 mold draft angle top 0.53 0.51 0.33 .021 .020 .013 b lower lead width 0.81 0.74 0.66 .032 .029 .026 b1 upper lead width 0.33 0.27 0.20 .013 .011 .008 c lead thickness 17 17 n1 pins per side 23.62 23.37 22.61 .930 .920 .890 d2 footprint length 23.62 23.37 22.61 .930 .920 .890 e2 footprint width 24.33 24.23 24.13 .958 .954 .950 d1 molded package length 24.33 24.23 24.13 .958 .954 .950 e1 molded package width 25.27 25.15 25.02 .995 .990 .985 d overall length 25.27 25.15 25.02 .995 .990 .985 e overall width 0.25 0.13 0.00 .010 .005 .000 ch2 corner chamfer (others) 1.27 1.14 1.02 .050 .045 .040 ch1 corner chamfer 1 0.86 0.74 0.61 .034 .029 .024 a3 side 1 chamfer height 0.51 .020 a1 standoff a2 molded package thickness 4.57 4.39 4.19 .180 .173 .165 a overall height 1.27 .050 p pitch 68 n number of pins max nom min max nom min dimension limits millimeters inches* units a2 c e2 2 d d1 n #leads=n1 e e1 1 p b a3 a b1 32 d2 68 a1 .145 .153 .160 3.68 3.87 4.06 .028 .035 0.71 0.89 ch1 x 45 ch2 x 45 * controlling parameter notes: dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010 ? (0.254mm) per side. jedec equivalent: mo-047 drawing no. c04-049 significant characteristic
? 2000 microchip technology inc. ds30289b-page 285 pic17c7xx 80-lead plastic thin quad flatpack (pt) 12x12x1 mm body, 1.0/0.10 mm lead form (tqfp) * controlling parameter notes: dimensions d1 and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010 ? (0.254mm) per side. jedec equivalent: ms-026 drawing no. c04-092 1.10 1.00 .043 .039 1.14 0.89 0.64 .045 .035 .025 ch pin 1 corner chamfer 1.00 .039 (f) footprint (reference) (f) e e1 #leads=n1 p b d1 d n 1 2 c l a a1 a2 units inches millimeters* dimension limits min nom max min nom max number of pins n 80 80 pitch p .020 0.50 overall height a .047 1.20 molded package thickness a2 .037 .039 .041 0.95 1.00 1.05 standoff a1 .002 .004 .006 0.05 0.10 0.15 foot length l .018 .024 .030 0.45 0.60 0.75 foot angle 03.5 7 03.5 7 overall width e .541 .551 .561 13.75 14.00 14.25 overall length d .541 .551 .561 13.75 14.00 14.25 molded package width e1 .463 .472 .482 11.75 12.00 12.25 molded package length d1 .463 .472 .482 11.75 12.00 12.25 pins per side n1 20 20 lead thickness c .004 .006 .008 0.09 0.15 0.20 lead width b .007 .009 .011 0.17 0.22 0.27 mold draft angle top 5 10 15 5 10 15 mold draft angle bottom 5 10 15 5 10 15 ch x 45 significant characteristic
pic17c7xx ds30289b-page 286 ? 2000 microchip technology inc. 84-lead plastic leaded chip carrier (l) ? square (plcc) 10 5 0 10 5 0 mold draft angle bottom 10 5 0 10 5 0 mold draft angle top 0.53 0.51 0.33 .021 .020 .013 b lower lead width 0.81 0.74 0.66 .032 .029 .026 b1 upper lead width 0.33 0.27 0.20 .013 .011 .008 c lead thickness 17 17 n1 pins per side 23.62 23.37 22.61 .930 .920 .890 d2 footprint length 23.62 23.37 22.61 .930 .920 .890 e2 footprint width 24.33 24.23 24.13 .958 .954 .950 d1 molded package length 24.33 24.23 24.13 .958 .954 .950 e1 molded package width 25.27 25.15 25.02 .995 .990 .985 d overall length 25.27 25.15 25.02 .995 .990 .985 e overall width 0.25 0.13 0.00 .010 .005 .000 ch2 corner chamfer (others) 1.27 1.14 1.02 .050 .045 .040 ch1 corner chamfer 1 0.86 0.74 0.61 .034 .029 .024 a3 side 1 chamfer height 0.51 .020 a1 standoff a2 molded package thickness 4.57 4.39 4.19 .180 .173 .165 a overall height 1.27 .050 p pitch 68 n number of pins max nom min max nom min dimension limits millimeters inches* units a2 c e2 2 d d1 n #leads=n1 e e1 1 p b a3 a b1 32 d2 68 a1 .145 .153 .160 3.68 3.87 4.06 .028 .035 0.71 0.89 ch1 x 45 ch2 x 45 * controlling parameter notes: dimensions d and e1 do not include mold flash or protrusions. mold flash or protrusions shall not exceed .010 ? (0.254mm) per side. jedec equivalent: mo-047 drawing no. c04-093 significant characteristic
? 2000 microchip technology inc. ds30289b-page 287 pic17c7xx appendix a: modifications the following is the list of modifications over the pic16cxx microcontroller family: 1. instruction word length is increased to 16-bit. this allows larger page sizes, both in program memory (8 kwords verses 2 kwords) and regis- ter file (256 bytes versus 128 bytes). 2. four modes of operation: microcontroller, protected microcontroller, extended micro- controller, and microprocessor. 3. 22 new instructions. the movf , tris and option instructions are no longer supported. 4. four new instructions ( tlrd , tlwt , tablrd , tablwt ) for transferring data between data memory and program memory. they can be used to ? self program ? the eprom program memory. 5. single cycle data memory to data memory trans- fers possible ( movpf and movfp instructions). these instructions do not affect the working register (wreg). 6. w register (wreg) is now directly addressable. 7. a pc high latch register (pclath) is extended to 8-bits. the pclatch register is now both readable and writable. 8. data memory paging is redefined slightly. 9. ddr registers replace function of tris regis- ters. 10. multiple interrupt vectors added. this can decrease the latency for servicing interrupts. 11. stack size is increased to 16 deep. 12. bsr register for data memory paging. 13. wake-up from sleep operates slightly differently. 14. the oscillator start-up timer (ost) and power- up timer (pwrt) operate in parallel and not in series. 15. portb interrupt-on-change feature works on all eight port pins. 16. tmr0 is 16-bit, plus 8-bit prescaler. 17. second indirect addressing register added (fsr1 and fsr2). control bits can select the fsr registers to auto-increment, auto-decre- ment, remain unchanged after an indirect address. 18. hardware multiplier added (8 x 8 16-bit). 19. peripheral modules operate slightly differently. 20. a/d has both v ref + and v ref - inputs. 21. usarts do not implement brgh feature. 22. oscillator modes slightly redefined. 23. control/status bits and registers have been placed in different registers and the control bit for globally enabling interrupts has inverse polarity. 24. in-circuit serial programming is implemented differently. appendix b: compatibility to convert code written for pic16cxxx to pic17cxxx, the user should take the following steps: 1. remove any tris and option instructions, and implement the equivalent code. 2. separate the interrupt service routine into its four vectors. 3. replace: movf reg1, w with: movfp reg1, wreg 4. replace: movf reg1, w movwf reg2 with: movpf reg1, reg2 ; addr(reg1)<20h or movfp reg1, reg2 ; addr(reg2)<20h 5. ensure that all bit names and register names are updated to new data memory map locations. 6. verify data memory banking. 7. verify mode of operation for indirect addressing. 8. verify peripheral routines for compatibility. 9. weak pull-ups are enabled on reset. 10. wdt time-outs always reset the device (in run or sleep mode). b.1 upgrading from pic17c42 devices to convert code from the pic17c42 to all the other pic17cxxx devices, the user should take the follow- ing steps. 1. if the hardware multiply is to be used, ensure that any variables at address 18h and 19h are moved to another address. 2. ensure that the upper nibble of the bsr was not written with a non-zero value. this may cause unexpected operation since the ram bank is no longer 0. 3. the disabling of global interrupts has been enhanced, so there is no additional testing of the glintd bit after a bsf cpusta, glintd instruction. note: if reg1 and reg2 are both at addresses greater then 20h, two instructions are required. movfp reg1, wreg ; movpf wreg, reg2 ;
pic17c7xx ds30289b-page 288 ? 2000 microchip technology inc. appendix c: what?s new this is a new data sheet for the following devices: ? pic17c752  pic17c756a  pic17c762  pic17c766 this data sheet is based on the pic17c75x data sheet (ds30246a). appendix d: what ? s changed clarified the t ad vs. device maximum operating fre- quency tables in section 16.2. added device characteristic graphs and charts in section 21. removed the ? preliminary ? status from the entire document.
? 2000 microchip technology inc. ds30289b-page 289 pic17c7xx index a a/d accuracy/error .......................................................... 189 adcon0 register..................................................... 179 adcon1 register..................................................... 180 adif bit ..................................................................... 181 analog input model block diagram........................... 184 analog-to-digital converter....................................... 179 block diagram........................................................... 181 configuring analog port pins.................................... 186 configuring the interrupt ........................................... 181 configuring the module............................................. 181 connection considerations....................................... 189 conversion clock...................................................... 185 conversions .............................................................. 186 converter characteristics ......................................... 263 delays ....................................................................... 183 effects of a reset ................................................... 188 equations .................................................................. 183 flow chart of a/d operation..................................... 187 go/done bit ............................................................ 181 internal sampling switch (rss) impedence .............. 183 operation during sleep .......................................... 188 sampling requirements............................................ 183 sampling time .......................................................... 183 source impedence.................................................... 183 time delays .............................................................. 183 transfer function...................................................... 189 a/d interrupt........................................................................ 38 a/d interrupt flag bit, adif................................................. 38 a/d module interrupt enable, adie .................................... 36 ack ................................................................................... 144 acknowledge data bit, akd .............................................. 136 acknowledge pulse........................................................... 144 acknowledge sequence enable bit, ake ......................... 136 acknowledge status bit, aks ........................................... 136 adcon0 ............................................................................. 49 adcon1 ............................................................................. 49 addlw ............................................................................. 202 addwf ............................................................................. 202 addwfc .......................................................................... 203 adie.................................................................................... 36 adif.................................................................................... 38 adres register ............................................................... 179 adresh ............................................................................. 49 adresl.............................................................................. 49 akd................................................................................... 136 ake................................................................................... 136 aks ........................................................................... 136, 159 alu ..................................................................................... 11 alusta ............................................................................ 198 alusta register................................................................ 51 andlw ............................................................................. 203 andwf ............................................................................. 204 application note an552, ? implementing wake-up on keystroke. ? ..................................................................... 74 application note an578, "use of the ssp module in the i 2 c multi-master environment."............................... 143 assembler mpasm assembler................................................... 233 asynchronous master transmission ................................. 123 asynchronous transmitter ................................................ 123 b bank select register (bsr) ............................................... 57 banking......................................................................... 46, 57 baud rate formula........................................................... 120 baud rate generator ....................................................... 153 baud rate generator (brg) ............................................ 120 baud rates asynchronous mode................................................. 122 synchronous mode................................................... 121 bcf .................................................................................. 204 bclie ................................................................................. 36 bclif ................................................................................. 38 bf ............................................................. 134, 144, 159, 162 bit manipulation ................................................................ 198 block diagrams a/d............................................................................ 181 analog input model................................................... 184 baud rate generator ............................................... 153 bsr operation ........................................................... 57 external brown-out protection circuit (case1)........... 31 external power-on reset circuit ................................ 24 external program memory connection ...................... 45 i 2 c master mode ...................................................... 151 i 2 c module................................................................ 143 indirect addressing..................................................... 54 on-chip reset circuit ................................................. 23 portd ....................................................................... 80 porte ........................................................... 82, 90, 91 program counter operation ....................................... 56 pwm......................................................................... 107 ra0 and ra1.............................................................. 72 ra2............................................................................. 72 ra3............................................................................. 73 ra4 and ra5.............................................................. 73 rb3:rb2 port pins ..................................................... 75 rb7:rb4 and rb1:rb0 port pins .............................. 74 rc7:rc0 port pins..................................................... 78 ssp (i 2 c mode)........................................................ 143 ssp (spi mode) ....................................................... 137 ssp module (i 2 c master mode) ............................... 133 ssp module (i 2 c slave mode) ................................. 133 ssp module (spi mode) .......................................... 133 timer3 with one capture and one period register. 110 tmr1 and tmr2 in 16-bit timer/counter mode ...... 105 tmr1 and tmr2 in two 8-bit timer/counter mode 104 tmr3 with two capture registers........................... 112 using call, goto.................................................... 56 wdt ......................................................................... 193 boden ............................................................................... 31 borrow ................................................................................ 11 brg .......................................................................... 120, 153 brown-out protection .......................................................... 31 brown-out reset (bor)...................................................... 31 bsf................................................................................... 205 bsr .................................................................................... 57 bsr operation ................................................................... 57 btfsc .............................................................................. 205 btfss .............................................................................. 206 btg .................................................................................. 206 buffer full bit, bf .............................................................. 144 buffer full status bit, bf................................................... 134 bus arbitration .................................................................. 170 bus collision section...................................................................... 170
pic17c7xx ds30289b-page 290 ? 2000 microchip technology inc. bus collision during a restart condition..................... 173 bus collision during a start condition.......................... 171 bus collision during a stop condition............................ 174 bus collision interrupt enable, bclie ................................ 36 bus collision interrupt flag bit, bclif ................................ 38 c c.................................................................................... 11, 51 ca1/pr3 ........................................................................... 102 ca1ed0 ............................................................................ 101 ca1ed1 ............................................................................ 101 ca1ie.................................................................................. 35 ca1if .................................................................................. 37 ca1ovf............................................................................ 102 ca2ed0 ............................................................................ 101 ca2ed1 ............................................................................ 101 ca2h............................................................................. 28, 49 ca2ie.......................................................................... 35, 111 ca2if .......................................................................... 37, 111 ca2l ............................................................................. 28, 49 ca2ovf............................................................................ 102 ca3h................................................................................... 50 ca3ie.................................................................................. 36 ca3if .................................................................................. 38 ca3l ................................................................................... 50 ca4h................................................................................... 50 ca4ie.................................................................................. 36 ca4if .................................................................................. 38 calculating baud rate error ............................................. 120 call ........................................................................... 54, 207 capacitor selection ceramic resonators ................................................... 18 crystal oscillator......................................................... 18 capture ..................................................................... 101, 110 capture sequence to read example................................ 113 capture1 mode ......................................................................... 101 overflow ............................................................ 102, 103 capture1 interrupt ............................................................... 37 capture2 mode ......................................................................... 101 overflow ............................................................ 102, 103 capture2 interrupt ............................................................... 37 capture3 interrupt enable, ca3ie ...................................... 36 capture3 interrupt flag bit, ca3if ...................................... 38 capture4 interrupt enable, ca4ie ...................................... 36 capture4 interrupt flag bit, ca4if ...................................... 38 carry (c) ............................................................................. 11 ceramic resonators ........................................................... 17 circular buffer ..................................................................... 54 cke................................................................................... 134 ckp................................................................................... 135 clearing the prescaler....................................................... 193 clock polarity select bit, ckp ........................................... 135 clock/instruction cycle (figure) .......................................... 21 clocking scheme/instruction cycle..................................... 21 clrf................................................................................. 207 clrwdt........................................................................... 208 code examples indirect addressing ..................................................... 55 loading the sspbuf register ................................... 138 saving status and wreg in ram .............................. 42 table read ................................................................. 64 table write.................................................................. 62 code protection ................................................................ 195 comf................................................................................ 208 configuration bits............................................................................ 192 locations .................................................................. 192 oscillator............................................................. 17, 192 word ......................................................................... 191 cpfseq ........................................................................... 209 cpfsgt ........................................................................... 209 cpfslt ............................................................................ 210 cpusta ..................................................................... 52, 194 crystal operation, overtone crystals ................................. 18 crystal or ceramic resonator operation............................ 18 crystal oscillator................................................................. 17 d d/a .................................................................................... 134 data memory gpr ...................................................................... 43, 46 indirect addressing ..................................................... 54 organization ............................................................... 46 sfr ............................................................................ 43 data memory banking ........................................................ 46 data/address bit, d/a ....................................................... 134 daw ................................................................................. 210 dc................................................................................. 11, 51 ddrb...................................................................... 27, 48, 74 ddrc ..................................................................... 28, 48, 78 ddrd ..................................................................... 28, 48, 80 ddre...................................................................... 28, 48, 82 ddrf.................................................................................. 49 ddrg ................................................................................. 49 decf ................................................................................ 211 decfsnz......................................................................... 212 decfsz ........................................................................... 211 delay from external clock edge........................................ 98 digit borrow ........................................................................ 11 digit carry (dc) .................................................................. 11 duty cycle ........................................................................ 107 e electrical characteristics pic17c752/756 absolute maximum ratings .............................. 239 capture timing ................................................. 253 clkout and i/o timing .................................. 250 dc characteristics............................................ 242 external clock timing....................................... 249 memory interface read timing ........................ 266 memory interface write timing ........................ 265 parameter measurement information............... 248 reset, watchdog timer, oscillator start-up timer and power-up timer timing ................... 251 timer0 clock timing......................................... 252 timer1, timer2 and timer3 clock timing ........ 252 timing parameter symbology .......................... 247 usart module synchronous receive timing. 261 usart module synchronous transmission timing............................................................... 260 eprom memory access time order suffix....................... 45 errata .................................................................................... 5 extended microcontroller .................................................... 43 extended microcontroller mode .......................................... 45 external memory interface.................................................. 45 external program memory waveforms............................... 45
? 2000 microchip technology inc. ds30289b-page 291 pic17c7xx f family of devices pic17c75x ................................................................... 8 ferr ................................................................................ 125 flowcharts acknowledge............................................................. 166 master receiver........................................................ 163 master transmit ........................................................ 160 restart condition ................................................. 157 start condition .......................................................... 155 stop condition ........................................................ 168 fosc0 .............................................................................. 191 fosc1 .............................................................................. 191 fs0 ..................................................................................... 51 fs1 ..................................................................................... 51 fs2 ..................................................................................... 51 fs3 ..................................................................................... 51 fsr0 ................................................................................... 54 fsr1 ................................................................................... 54 g gce .................................................................................. 136 general call address sequence....................................... 149 general call address support .......................................... 149 general call enable bit, gce ........................................... 136 general format for instructions ........................................ 198 general purpose ram ........................................................ 43 general purpose ram bank............................................... 57 general purpose register (gpr) ....................................... 46 glintd ......................................................... 39, 52, 111, 194 global interrupt disable bit, glintd .................................. 39 goto ............................................................................... 212 gpr (general purpose register) ....................................... 46 gpr banks ......................................................................... 57 graphs rc oscillator frequency vs. v dd (c ext = 100 pf)... 268 rc oscillator frequency vs. v dd (c ext = 22 pf)..... 268 rc oscillator frequency vs. v dd (c ext = 300 pf)... 269 transconductance of lf oscillator vs.v dd ............... 270 transconductance of xt oscillator vs. v dd .............. 270 typical rc oscillator vs. temperature ..................... 267 h hardware multiplier ............................................................. 67 i i/o ports bi-directional ............................................................... 93 i/o ports...................................................................... 71 programming considerations ..................................... 93 read-modify-write instructions................................... 93 successive operations ............................................... 94 i 2 c ..................................................................................... 143 i2c input ........................................................................... 279 i 2 c master mode receiver flow chart ............................. 163 i 2 c master mode reception.............................................. 162 i 2 c master mode restart condition ............................. 156 i 2 c mode selection ........................................................... 143 i 2 c module acknowledge flow chart .......................................... 166 acknowledge sequence timing................................ 165 addressing ................................................................ 145 baud rate generator................................................ 153 block diagram........................................................... 151 brg block diagram.................................................. 153 brg reset due to sda collision.............................. 172 brg timing .............................................................. 153 bus arbitration .......................................................... 170 bus collision............................................................. 170 acknowledge .................................................... 170 restart condition......................................... 173 restart condition timing (case1) ............... 173 restart condition timing (case2) ............... 173 start condition.............................................. 171 start condition timing.......................... 171, 172 stop condition................................................ 174 stop condition timing (case1) ...................... 174 stop condition timing (case2) ...................... 174 transmit timing................................................ 170 bus collision timing ................................................. 170 clock arbitration ....................................................... 169 clock arbitration timing (master transmit) .............. 169 conditions to not give ack pulse............................. 144 general call address support.................................. 149 master mode............................................................. 151 master mode 7-bit reception timing ......................... 164 master mode operation............................................ 152 master mode start condition.................................... 154 master mode transmission ...................................... 159 master mode transmit sequence ............................ 152 master transmit flowchart ....................................... 160 multi-master communication.................................... 170 multi-master mode.................................................... 152 operation.................................................................. 143 repeat start condition timing................................... 156 restart condition flowchart ................................ 157 slave mode............................................................... 144 slave reception ....................................................... 145 slave transmission .................................................. 146 sspbuf ................................................................... 144 start condition flowchart ......................................... 155 stop condition flowchart ......................................... 168 stop condition receive or transmit timing .............. 167 stop condition timing ............................................... 167 waveforms for 7-bit reception ................................. 146 waveforms for 7-bit transmission............................ 146 i 2 c module address register, sspadd .......................... 144 i 2 c slave mode ................................................................ 144 incf ................................................................................. 213 incfsnz .......................................................................... 214 incfsz............................................................................. 213 in-circuit serial programming........................................... 196 indf0 ................................................................................. 54 indf1 ................................................................................. 54 indirect addressing indirect addressing..................................................... 54 operation.................................................................... 55 registers .................................................................... 54 initializing portb............................................................... 75 initializing portc .............................................................. 78 initializing portd .............................................................. 80 initializing porte................................................... 82, 84, 86 insta ................................................................................. 48 instruction flow/pipelining .................................................. 21 instruction set addlw..................................................................... 202 addwf .................................................................... 202 addwfc.................................................................. 203 andlw..................................................................... 203 andwf .................................................................... 204 bcf .......................................................................... 204 bsf........................................................................... 205 btfsc...................................................................... 205 btfss ...................................................................... 206
pic17c7xx ds30289b-page 292 ? 2000 microchip technology inc. btg........................................................................... 206 call ......................................................................... 207 clrf......................................................................... 207 clrwdt................................................................... 208 comf ....................................................................... 208 cpfseq ................................................................... 209 cpfsgt ................................................................... 209 cpfslt .................................................................... 210 daw.......................................................................... 210 decf ........................................................................ 211 decfsnz ................................................................. 212 decfsz.................................................................... 211 goto ....................................................................... 212 incf.......................................................................... 213 incfsnz .................................................................. 214 incfsz ..................................................................... 213 iorlw ...................................................................... 214 iorwf ...................................................................... 215 lcall ....................................................................... 215 movfp ..................................................................... 216 movlb ..................................................................... 216 movlr ..................................................................... 217 movlw .................................................................... 217 movpf ..................................................................... 218 movwf .................................................................... 218 mullw ..................................................................... 219 mulwf ..................................................................... 219 negw ....................................................................... 220 nop .......................................................................... 220 retfie ..................................................................... 221 retlw ..................................................................... 221 return ................................................................... 222 rlcf......................................................................... 222 rlncf ...................................................................... 223 rrcf ........................................................................ 223 rrncf ..................................................................... 224 setf ......................................................................... 224 sleep ...................................................................... 225 sublw ..................................................................... 225 subwf ..................................................................... 226 subwfb................................................................... 226 swapf ..................................................................... 227 tablrd ............................................................ 227, 228 tablwt ........................................................... 228, 229 tlrd......................................................................... 229 tlwt ........................................................................ 230 tstfsz .................................................................... 230 xorlw ..................................................................... 231 xorwf..................................................................... 231 instruction set summary................................................... 197 instructions tablrd ...................................................................... 64 tlrd........................................................................... 64 int pin ................................................................................ 40 inte .................................................................................... 34 intedg......................................................................... 53, 97 inter-integrated circuit (i 2 c).............................................. 133 internal sampling switch (rss) impedence ...................... 183 interrupt on change feature............................................... 74 interrupt status register (intsta) ..................................... 34 interrupts a/d interrupt................................................................ 38 bus collision interrupt ................................................. 38 capture1 interrupt....................................................... 37 capture2 interrupt....................................................... 37 capture3 interrupt....................................................... 38 capture4 interrupt ...................................................... 38 context saving ........................................................... 39 flag bits tmr1ie .............................................................. 33 tmr1if............................................................... 33 tmr2ie .............................................................. 33 tmr2if............................................................... 33 tmr3ie .............................................................. 33 tmr3if............................................................... 33 global interrupt disable .............................................. 39 interrupts .................................................................... 33 logic ........................................................................... 33 operation .................................................................... 39 peripheral interrupt enable......................................... 35 peripheral interrupt request....................................... 37 pie2 register ............................................................. 36 pir1 register ............................................................. 37 pir2 register ............................................................. 38 portb interrupt on change ...................................... 37 pwm ......................................................................... 108 ra0/int ...................................................................... 39 status register ........................................................... 34 synchronous serial port interrupt............................... 38 t0cki interrupt ........................................................... 39 timing ......................................................................... 40 tmr1 overflow interrupt ............................................ 37 tmr2 overflow interrupt ............................................ 37 tmr3 overflow interrupt ............................................ 37 usart1 receive interrupt ......................................... 37 usart1 transmit interrupt ........................................ 37 usart2 receive interrupt ......................................... 38 vectors peripheral interrupt............................................. 39 program memory locations ............................... 43 ra0/int interrupt ............................................... 39 t0cki interrupt ................................................... 39 vectors/priorities......................................................... 39 wake-up from sleep............................................... 194 intf.................................................................................... 34 intsta register................................................................. 34 iorlw .............................................................................. 214 iorwf.............................................................................. 215 i rbpu vs . v dd ................................................................... 274 k keeloq evaluation and programming tools .................... 236 l lcall......................................................................... 54, 215 m maps register file map........................................................ 47 memory external interface ....................................................... 45 external memory waveforms ..................................... 45 memory map (different modes) .................................. 44 mode memory access ................................................ 44 organization ............................................................... 43 program memory ........................................................ 43 program memory map ................................................ 43 microcontroller .................................................................... 43 microprocessor ................................................................... 43 minimizing current consumption...................................... 195 movfp ....................................................................... 46, 216 moving data between data and program memories ......... 46 movlb ....................................................................... 46, 216 movlr ............................................................................. 217 movlw ............................................................................ 217
? 2000 microchip technology inc. ds30289b-page 293 pic17c7xx movpf ....................................................................... 46, 218 movwf ............................................................................ 218 mplab integrated development environment software .. 233 mullw ............................................................................. 219 multi-master communication ............................................ 170 multi-master mode ............................................................ 152 multiply examples 16 x 16 routine........................................................... 68 16 x 16 signed routine............................................... 69 8 x 8 routine............................................................... 67 8 x 8 signed routine................................................... 67 mulwf ............................................................................. 219 n negw ............................................................................... 220 nop .................................................................................. 220 o opcode field descriptions ................................................ 197 opcodes.............................................................................. 56 oscillator configuration....................................................... 17, 192 crystal......................................................................... 17 external clock............................................................. 19 external crystal circuit ............................................... 19 external parallel resonant crystal circuit .................. 19 external series resonant crystal circuit.................... 19 rc............................................................................... 20 rc frequencies ........................................................ 269 oscillator start-up time (figure)......................................... 24 oscillator start-up timer (ost) .......................................... 24 ost..................................................................................... 24 ov................................................................................. 11, 51 overflow (ov) ..................................................................... 11 p p........................................................................................ 134 packaging information ...................................................... 281 pc (program counter) ........................................................ 56 pcfg0 bit ......................................................................... 180 pcfg1 bit ......................................................................... 180 pcfg2 bit ......................................................................... 180 pch .................................................................................... 56 pcl ............................................................................. 56, 198 pclath .............................................................................. 56 pd ............................................................................... 52, 194 peie............................................................................ 34, 111 peif .................................................................................... 34 peripheral bank .................................................................. 57 peripheral banks................................................................. 57 peripheral interrupt enable ................................................. 35 peripheral interrupt request (pir1) ................................... 37 peripheral register banks .................................................. 46 picdem-1 low-cost picmicro demo board.................... 235 picdem-2 low-cost pic16cxx demo board ................. 235 picdem-3 low-cost pic16cxxx demo board............... 236 picstart ? plus entry level development system ......... 235 pie .................................................................... 126, 130, 132 pie1 .............................................................................. 28, 48 pie2 ........................................................................ 28, 36, 49 pir .................................................................... 126, 130, 132 pir1 .............................................................................. 28, 48 pir2 .............................................................................. 28, 49 pm0........................................................................... 191, 195 pm1........................................................................... 191, 195 pop .............................................................................. 39, 54 por .................................................................................... 24 porta.................................................................... 27, 48, 72 portb ................................................................... 27, 48, 74 portb interrupt on change .............................................. 37 portc ................................................................... 28, 48, 78 portd ................................................................... 28, 48, 80 porte ................................................................... 28, 48, 82 portf ............................................................................... 49 portg ............................................................................... 49 power-down mode............................................................ 194 power-on reset (por)....................................................... 24 power-up timer (pwrt) .................................................... 24 pr1............................................................................... 28, 49 pr2............................................................................... 28, 49 pr3/ca1h .......................................................................... 28 pr3/ca1l........................................................................... 28 pr3h/ca1h........................................................................ 49 pr3l/ca1l......................................................................... 49 prescaler assignments ....................................................... 99 pro mate ? ii universal programmer.............................. 235 prodh......................................................................... 30, 50 prodl ......................................................................... 30, 50 program counter (pc)........................................................ 56 program memory external access waveforms....................................... 45 external connection diagram..................................... 45 map............................................................................. 43 modes extended microcontroller.................................... 43 microcontroller.................................................... 43 microprocessor ................................................... 43 protected microcontroller.................................... 43 operation.................................................................... 43 organization ............................................................... 43 protected microcontroller.................................................... 43 ps0 ............................................................................... 53, 97 ps1 ............................................................................... 53, 97 ps2 ............................................................................... 53, 97 ps3 ............................................................................... 53, 97 push............................................................................ 39, 54 pw1dch ...................................................................... 28, 49 pw1dcl....................................................................... 28, 49 pw2dch ...................................................................... 28, 49 pw2dcl....................................................................... 28, 49 pw3dch ...................................................................... 30, 50 pw3dcl....................................................................... 30, 50 pwm ......................................................................... 101, 107 duty cycle ................................................................ 108 external clock source .............................................. 109 frequency vs. resolution ......................................... 108 interrupts .................................................................. 108 max resolution/frequency for external clock input 109 output....................................................................... 107 periods ..................................................................... 108 pwm1 ....................................................................... 102, 103 pwm1on.................................................................. 102, 107 pwm2 ....................................................................... 102, 103 pwm2on.................................................................. 102, 107 pwm3on.......................................................................... 103 pwrt ................................................................................. 24
pic17c7xx ds30289b-page 294 ? 2000 microchip technology inc. r r/w ................................................................................... 134 r/w bit .............................................................................. 145 r/w bit .............................................................................. 145 ra1/t0cki pin .................................................................... 97 rbie.................................................................................... 35 rbif .................................................................................... 37 rbpu .................................................................................. 74 rc oscillator ....................................................................... 20 rc oscillator frequencies ................................................ 269 rc1ie.................................................................................. 35 rc1if.................................................................................. 37 rc2ie.................................................................................. 36 rc2if.................................................................................. 38 rce, receive enable bit, rce ......................................... 136 rcreg ..................................................... 125, 126, 130, 131 rcreg1 ....................................................................... 27, 48 rcreg2 ....................................................................... 27, 49 rcsta .............................................................. 126, 130, 132 rcsta1 ........................................................................ 27, 48 rcsta2 ........................................................................ 27, 49 read/write bit, r/w .......................................................... 134 reading 16-bit value........................................................... 99 receive overflow indicator bit, sspov ............................ 135 receive status and control register ................................ 117 register file map ................................................................ 47 registers adcon0 ..................................................................... 49 adcon1 ..................................................................... 49 adresh ..................................................................... 49 adresl...................................................................... 49 alusta .......................................................... 39, 48, 51 brg .......................................................................... 120 bsr....................................................................... 39, 48 ca2h .......................................................................... 49 ca2l ........................................................................... 49 ca3h .......................................................................... 50 ca3l ........................................................................... 50 ca4h .......................................................................... 50 ca4l ........................................................................... 50 cpusta ............................................................... 48, 52 ddrb .......................................................................... 48 ddrc.......................................................................... 48 ddrd.......................................................................... 48 ddre .......................................................................... 48 ddrf .......................................................................... 49 ddrg ......................................................................... 49 fsr0 ..................................................................... 48, 54 fsr1 ..................................................................... 48, 54 indf0.................................................................... 48, 54 indf1.................................................................... 48, 54 insta ......................................................................... 48 intsta ....................................................................... 34 pcl ............................................................................. 48 pclath ...................................................................... 48 pie1 ...................................................................... 35, 48 pie2 ...................................................................... 36, 49 pir1 ...................................................................... 37, 48 pir2 ...................................................................... 38, 49 porta........................................................................ 48 portb........................................................................ 48 portc ....................................................................... 48 portd ....................................................................... 48 porte........................................................................ 48 portf ........................................................................ 49 portg ....................................................................... 49 pr1............................................................................. 49 pr2............................................................................. 49 pr3h/ca1h................................................................ 49 pr3l/ca1l................................................................. 49 prodh....................................................................... 50 prodl ....................................................................... 50 pw1dch .................................................................... 49 pw1dcl..................................................................... 49 pw2/dcl.................................................................... 49 pw2dch .................................................................... 49 pw3dch .................................................................... 50 pw3dcl..................................................................... 50 rcreg1..................................................................... 48 rcreg2..................................................................... 49 rcsta1 ..................................................................... 48 rcsta2 ..................................................................... 49 spbrg1 ..................................................................... 48 spbrg2 ..................................................................... 49 sspadd ..................................................................... 50 sspbuf ..................................................................... 50 sspcon1 .................................................................. 50 sspcon2 .................................................................. 50 sspstat ........................................................... 50, 134 t0sta ............................................................ 48, 53, 97 tblptrh ................................................................... 48 tblptrl .................................................................... 48 tcon1 ............................................................... 49, 101 tcon2 ............................................................... 49, 102 tcon3 ............................................................... 50, 103 tmr0h ....................................................................... 48 tmr1 .......................................................................... 49 tmr2 .......................................................................... 49 tmr3h ....................................................................... 49 tmr3l ........................................................................ 49 txreg1 ..................................................................... 48 txreg2 ..................................................................... 49 txsta1 ...................................................................... 48 txsta2 ...................................................................... 49 wreg .................................................................. 39, 48 regsters tmr0l ........................................................................ 48 reset section........................................................................ 23 status bits and their significance .............................. 25 time-out in various situations ................................... 25 time-out sequence.................................................... 25 restart condition enabled bit, rse.................................. 136 retfie ............................................................................. 221 retlw ............................................................................. 221 return........................................................................... 222 rlcf ................................................................................ 222 rlncf.............................................................................. 223 rrcf................................................................................ 223 rrncf ............................................................................. 224 rse .................................................................................. 136 rx pin sampling scheme ................................................ 125 s s ....................................................................................... 134 sae................................................................................... 136 sampling........................................................................... 125 saving status and wreg in ram.................................. 42 sck .................................................................................. 137 scl................................................................................... 144 sda .................................................................................. 144 sdi.................................................................................... 137 sdo .................................................................................. 137
? 2000 microchip technology inc. ds30289b-page 295 pic17c7xx seeval evaluation and programming system................ 236 serial clock, sck ............................................................. 137 serial clock, scl .............................................................. 144 serial data address, sda................................................. 144 serial data in, sdi ............................................................ 137 serial data out, sdo........................................................ 137 setf ................................................................................. 224 sfr ................................................................................... 198 sfr (special function registers)....................................... 43 sfr as source/destination .............................................. 198 signed math ........................................................................ 11 slave select synchronization ........................................... 140 slave select, ss ............................................................... 137 sleep ...................................................................... 194, 225 sleep mode, all peripherals disabled ............................ 273 sleep mode, bor enabled ............................................ 273 smp .................................................................................. 134 software simulator (mplab sim)..................................... 234 spbrg ............................................................. 126, 130, 132 spbrg1 ....................................................................... 27, 48 spbrg2 ....................................................................... 27, 49 spe................................................................................... 136 special features of the cpu ............................................ 191 special function registers ......................................... 43, 198 summary..................................................................... 48 special function registers, file map ................................. 47 spi master mode ............................................................. 139 serial clock............................................................... 137 serial data in ............................................................ 137 serial data out ......................................................... 137 serial peripheral interface (spi) ............................... 133 slave select .............................................................. 137 spi clock ................................................................... 139 spi mode .................................................................. 137 spi clock edge select, cke ............................................ 134 spi data input sample phase select, smp ..................... 134 spi master/slave connection ........................................... 138 spi module master/slave connection.......................................... 138 slave mode ............................................................... 140 slave select synchronization ................................... 140 slave synch timing .................................................. 140 ss ..................................................................................... 137 ssp................................................................................... 133 block diagram (spi mode) ....................................... 137 spi mode .................................................................. 137 sspadd ........................................................... 144, 145 sspbuf............................................................ 139, 144 sspcon1................................................................. 135 sspcon2................................................................. 136 sspsr.............................................................. 139, 144 sspstat.......................................................... 134, 144 ssp i 2 c ssp i 2 c operation.................................................... 143 ssp module spi master mode ...................................................... 139 spi master/slave connection ................................... 138 spi slave mode ........................................................ 140 sspcon1 register .................................................. 143 ssp overflow detect bit, sspov ..................................... 144 sspadd ............................................................................. 50 sspbuf...................................................................... 50, 144 sspcon1 ........................................................... 50, 135, 143 sspcon2 ................................................................... 50, 136 sspen .............................................................................. 135 sspie ................................................................................. 36 sspif ......................................................................... 38, 145 sspm3:sspm0 ................................................................ 135 sspov ............................................................. 135, 144, 162 sspstat ........................................................... 50, 134, 144 st input ............................................................................ 278 stack operation.................................................................... 54 pointer ........................................................................ 54 stack........................................................................... 43 start bit (s) ................................................................... 134 start condition enabled bit, sae.................................. 136 stkav .......................................................................... 52, 54 stop bit (p) ..................................................................... 134 stop condition enable bit............................................... 136 sublw ............................................................................. 225 subwf............................................................................. 226 subwfb .......................................................................... 226 swapf ............................................................................. 227 synchronous master mode............................................... 127 synchronous master reception........................................ 129 synchronous master transmission .................................. 127 synchronous serial port ................................................... 133 synchronous serial port enable bit, sspen.................... 135 synchronous serial port interrupt....................................... 38 synchronous serial port interrupt enable, sspie.............. 36 synchronous serial port mode select bits, sspm3:sspm0 ................................................................ 135 synchronous slave mode................................................. 131 t t0cki ................................................................................. 39 t0cki pin ........................................................................... 40 t0ckie ............................................................................... 34 t0ckif ............................................................................... 34 t0cs ............................................................................ 53, 97 t0ie .................................................................................... 34 t0if .................................................................................... 34 t0se............................................................................. 53, 97 t0sta ................................................................................ 53 t16 ................................................................................... 101 table latch ......................................................................... 55 table pointer ...................................................................... 55 table read example...................................................................... 64 table reads section .................................................. 64 tlrd .......................................................................... 64 table write code ........................................................................... 62 timing......................................................................... 62 to external memory ................................................... 62 tablrd ................................................................... 227, 228 tablwt ................................................................... 228, 229 t ad ................................................................................... 185 tblath .............................................................................. 55 tblatl .............................................................................. 55 tblptrh ........................................................................... 55 tblptrl ............................................................................ 55 tclk12 ............................................................................ 101 tclk3 .............................................................................. 101 tcon1 ......................................................................... 28, 49 tcon2 ............................................................................... 49 tcon2,tcon3 .................................................................. 28 tcon3 ....................................................................... 50, 103 time-out sequence............................................................ 25 timer resources ................................................................ 95
pic17c7xx ds30289b-page 296 ? 2000 microchip technology inc. timer0 ................................................................................. 97 timer1 16-bit mode ............................................................... 105 clock source select.................................................. 101 on bit ................................................................ 102, 103 section .............................................................. 101, 104 timer2 16-bit mode ............................................................... 105 clock source select.................................................. 101 on bit ................................................................ 102, 103 section .............................................................. 101, 104 timer3 clock source select.................................................. 101 on bit ................................................................ 102, 103 section .............................................................. 101, 110 timers tcon3 ...................................................................... 103 timing diagrams a/d conversion ......................................................... 264 acknowledge sequence timing................................ 165 asynchronous master transmission ......................... 123 asynchronous reception .......................................... 126 back to back asynchronous master transmission ... 124 baud rate generator with clock arbitration ............. 153 brg reset due to sda collision ............................. 172 bus collision start condition timing .................................. 171 bus collision during a restart condition (case 1) .................................................................... 173 bus collision during a restart condition (case 2) .................................................................... 173 bus collision during a start condition (scl = 0)................................................................... 172 bus collision during a stop condition ........................................................ 174 bus collision for transmit and acknowledge............ 170 external parallel resonant crystal oscillator circuit .. 19 external program memory access ............................. 45 i 2 c bus data ............................................................. 259 i 2 c bus start/stop bits ....................................... 258 i 2 c master mode first start bit timing ................. 154 i 2 c master mode reception timing .......................... 164 i 2 c master mode transmission timing..................... 161 interrupt (int, tmr0 pins).......................................... 40 master mode transmit clock arbitration................... 169 oscillator start-up time .............................................. 24 pic17c752/756 capture timing ............................... 253 pic17c752/756 clkout and i/o ............................ 250 pic17c752/756 external clock ................................ 249 pic17c752/756 memory interface read .................. 266 pic17c752/756 memory interface write .................. 265 pic17c752/756 pwm timing ................................... 253 pic17c752/756 reset, watchdog timer, oscillator start-up timer and power-up timer ......................... 251 pic17c752/756 timer0 clock .................................. 252 pic17c752/756 timer1, timer2 and timer3 clock .. 252 pic17c752/756 usart module synchronous receive ..................................................................... 261 pic17c752/756 usart module synchronous transmission....................................... 260 repeat start condition ......................................... 156 slave synchronization .............................................. 140 stop condition receive or transmit ....................... 167 synchronous reception ............................................ 129 synchronous transmission....................................... 128 table write.................................................................. 62 tmr0 .................................................................... 98, 99 tmr0 read/write in timer mode ............................. 100 tmr1, tmr2, and tmr3 in timer mode ................. 115 wake-up from sleep .............................................. 194 tlrd ................................................................................ 229 tlwt ................................................................................ 230 tmr0 16-bit read ................................................................. 99 16-bit write ................................................................. 99 module ........................................................................ 98 operation .................................................................... 98 overview..................................................................... 95 prescaler assignments ............................................... 99 read/write considerations......................................... 99 read/write in timer mode........................................ 100 timing ................................................................... 98, 99 tmr0 status/control register (t0sta) ............................. 53 tmr1 ............................................................................ 28, 49 8-bit mode................................................................. 104 external clock input.................................................. 104 overview..................................................................... 95 timer mode............................................................... 115 two 8-bit timer/counter mode ................................. 104 using with pwm ....................................................... 107 tmr1 overflow interrupt .................................................... 37 tmr1cs ........................................................................... 101 tmr1ie............................................................................... 35 tmr1if............................................................................... 37 tmr1on........................................................................... 102 tmr2 ............................................................................ 28, 49 8-bit mode................................................................. 104 external clock input.................................................. 104 in timer mode........................................................... 115 two 8-bit timer/counter mode ................................. 104 using with pwm ....................................................... 107 tmr2 overflow interrupt .................................................... 37 tmr2cs ........................................................................... 101 tmr2ie............................................................................... 35 tmr2if............................................................................... 37 tmr2on........................................................................... 102 tmr3 example, reading from ........................................... 114 example, writing to ................................................. 114 external clock input.................................................. 114 in timer mode........................................................... 115 one capture and one period register mode........... 110 overview..................................................................... 95 reading/writing ........................................................ 114 tmr3 interrupt flag bit, tmr3if........................................ 37 tmr3cs ................................................................... 101, 110 tmr3h ......................................................................... 28, 49 tmr3ie............................................................................... 35 tmr3if....................................................................... 37, 110 tmr3l .......................................................................... 28, 49 tmr3on................................................................... 102, 110 to ....................................................................... 52, 193, 194 transmit status and control register............................... 117 tstfsz ............................................................................ 230 ttl input........................................................................ 278 turning on 16-bit timer .................................................... 105 tx1ie.................................................................................. 35 tx1if .................................................................................. 37 tx2ie.................................................................................. 36 tx2if .................................................................................. 38 txreg ..................................................... 123, 127, 131, 132 txreg1 ....................................................................... 27, 48
? 2000 microchip technology inc. ds30289b-page 297 pic17c7xx txreg2........................................................................ 27, 49 txsta .............................................................. 126, 130, 132 txsta register txen bit ......................................... 34, 51, 97, 101, 117 txsta1 ........................................................................ 27, 48 txsta2 ........................................................................ 27, 49 u ua ..................................................................................... 134 update address, ua ......................................................... 134 upward compatibility ............................................................ 7 usart asynchronous master transmission......................... 123 asynchronous mode ................................................. 123 asynchronous receive ............................................. 125 asynchronous transmitter ........................................ 123 baud rate generator................................................ 120 synchronous master mode ....................................... 127 synchronous master reception................................ 129 synchronous master transmission........................... 127 synchronous slave mode ......................................... 131 synchronous slave transmit .................................... 131 transmit enable (txen bit)............ 34, 51, 97, 101, 117 usart1 receive interrupt ................................................. 37 usart1 transmit interrupt ................................................ 37 usart2 receive interrupt enable, rc2ie......................... 36 usart2 receive interrupt flag bit, rc2if ........................ 38 usart2 receive interrupt flag bit, tx2if ......................... 38 usart2 transmit interrupt enable, tx2ie ........................ 36 v v dd .................................................................................... 242 v oh vs . i oh ....................................................................... 276 v ol vs . i ol ........................................................................ 276 w wake-up from sleep....................................................... 194 wake-up from sleep through interrupt.......................... 194 watchdog timer ............................................................... 193 waveform for general call address sequence................ 149 waveforms external program memory access ............................. 45 wcol ....................................... 135, 154, 159, 162, 165, 167 wcol status flag............................................................ 154 wdt ................................................................................. 193 clearing the wdt ..................................................... 193 normal timer............................................................ 193 period ....................................................................... 193 programming considerations ................................... 193 wdt period................................................................... 275 wdtps0........................................................................... 191 wdtps1........................................................................... 191 write collision detect bit, wcol...................................... 135 www, on-line support ....................................................... 5 x xorlw ............................................................................ 231 xorwf ............................................................................ 231 z z ................................................................................... 11, 51 zero (z)............................................................................... 11
pic17c7xx ds30289b-page 298 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 299 pic17c7xx systems information and upgrade hot line the systems information and upgrade line provides system users a listing of the latest versions of all of microchip ? s development systems software products. plus, this line provides information on how customers can receive any currently available upgrade kits.the hot line numbers are: 1-800-755-2345 for u.s. and most of canada, and 1-480-792-7302 for the rest of the world. trademarks: the microchip name, logo, pic, picmicro, picmaster, picstart, pro mate, k ee l oq , seeval, mplab and the embedded control solutions company are registered trademarks of microchip technology incorporated in the u.s.a. and other countries. total endurance, icsp, in-circuit serial programming, filterlab, mxdev, microid, flex rom, fuzzy lab, mpasm, mplink, mplib, picdem, icepic and migratable memory are trademarks and sqtp is a service mark of microchip in the u.s.a. all other trademarks mentioned herein are the property of their respective companies. on-line support microchip provides on-line support on the microchip world wide web (www) site. the web site is used by microchip as a means to make files and information easily available to customers. to view the site, the user must have access to the internet and a web browser, such as netscape or microsoft explorer. files are also available for ftp download from our ftp site. connecting to the microchip internet web site the microchip web site is available by using your favorite internet browser to attach to: www.microchip.com the file transfer site is available by using an ftp ser- vice to connect to: ftp://ftp.microchip.com the web site and file transfer site provide a variety of services. users may download files for the latest development tools, data sheets, application notes, user ? s guides, articles and sample programs. a vari- ety of microchip specific business information is also available, including listings of microchip sales offices, distributors and factory representatives. other data available for consideration is:  latest microchip press releases  technical support section with frequently asked questions  design tips  device errata  job postings  microchip consultant program member listing  links to other useful web sites related to microchip products  conferences for products, development systems, technical information and more  listing of seminars and events 001024
pic17c7xx ds30289b-page 300 ? 2000 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 data sheet. 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 data sheet easy to follow? if not, why? 4. what additions to the data sheet do you think would enhance the structure and subject? 5. what deletions from the data sheet 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? 8. how would you improve our software, systems, and silicon products? 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: (______) _________ - _________ ds30289b pic17c7xx
? 2000 microchip technology inc. ds30289b-page 301 pic17c7xx product identification system to order or obtain information, e.g., on pricing or delivery, refer to the factory or the listed sales office. * jw devices are uv erasable and can be programmed to any device configuration. jw devices meet the electrical requirement of each oscillator type. sales and support data sheets products supported by a preliminary data sheet may have an errata sheet describing minor operational differences and recom- mended workarounds. to determine if an errata sheet exists for a particular device, please contact one of the following: 1. your local microchip sales office 2. the microchip corporate literature center u.s. fax: (480) 792-7277 3. the microchip worldwide site (www.microchip.com) please specify which device, revision of silicon and data sheet (include literature #) you are using. new customer notification system register on our web site (www.microchip.com/cn) to receive the most current information on our products. part no. x /xx xxx pattern package temperature range device device pic17c756: standard v dd range pic17c756t: (tape and reel) pic17lc756: extended v dd range temperature range - = 0 c to +70 c i= -40 c to +85 c package cl = windowed lcc pt = tqfp l=plcc pattern qtp, sqtp, rom code (factory specified) or special requirements . blamk for otp and windowed devices. examples: a) pic17c756 ? 16l commercial temp., plcc package, 16 mhz, normal v dd limits b) pic17lc756 ? 08/pt commercial temp., tqfp package, 8mhz, extended v dd limits c) pic17c756 ? 33i/pt industrial temp., tqfp package, 33 mhz, normal v dd limits
pic17c7xx ds30289b-page 302 ? 2000 microchip technology inc. notes:
? 2000 microchip technology inc. ds30289b-page 303 pic17c7xx notes:
information contained in this publication regarding device applications and the like is intended through suggestion only and ma y be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. no representation or warrant y is given and no liability is assumed by microchip technology incorporated with respect to the accuracy or use of such information, or infringement of patent s or other intellectual property rights arising from such use or otherwise. use of microchip ? s products as critical components in life support systems is not authorized except with express written approval by microchip. no licenses are conveyed, implicitly or otherwise, except as maybe explicitly expressed herein, under any intellec- tual property rights. the microchip logo and name are registered trademarks of microchip technology inc. in the u.s.a. and othe r countries. all rights reserved. all other trademarks mentioned herein are the property of their respective companies. ds30289b-page 304 ? 2000 microchip technology inc. all rights reserved. ? 2000 microchip technology incorporated. printed in the usa. 11/00 printed on recycled paper. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: 480-792-7627 web address: http://www.microchip.com rocky mountain 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7966 fax: 480-792-7456 atlanta 500 sugar mill road, suite 200b atlanta, ga 30350 tel: 770-640-0034 fax: 770-640-0307 boston 2 lan drive, suite 120 westford, ma 01886 tel: 978-692-3838 fax: 978-692-3821 chicago 333 pierce road, suite 180 itasca, il 60143 tel: 630-285-0071 fax: 630-285-0075 dallas 4570 westgrove drive, suite 160 addison, tx 75001 tel: 972-818-7423 fax: 972-818-2924 dayton two prestige place, suite 130 miamisburg, oh 45342 tel: 937-291-1654 fax: 937-291-9175 detroit tri-atria office building 32255 northwestern highway, suite 190 farmington hills, mi 48334 tel: 248-538-2250 fax: 248-538-2260 los angeles 18201 von karman, suite 1090 irvine, ca 92612 tel: 949-263-1888 fax: 949-263-1338 new york 150 motor parkway, suite 202 hauppauge, ny 11788 tel: 631-273-5305 fax: 631-273-5335 san jose microchip technology inc. 2107 north first street, suite 590 san jose, ca 95131 tel: 408-436-7950 fax: 408-436-7955 toronto 6285 northam drive, suite 108 mississauga, ontario l4v 1x5, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific china - beijing microchip technology beijing office unit 915 new china hong kong manhattan bldg. no. 6 chaoyangmen beidajie beijing, 100027, no. china tel: 86-10-85282100 fax: 86-10-85282104 china - shanghai microchip technology shanghai office room 701, bldg. b far east international plaza no. 317 xian xia road shanghai, 200051 tel: 86-21-6275-5700 fax: 86-21-6275-5060 hong kong microchip asia pacific rm 2101, tower 2, metroplaza 223 hing fong road kwai fong, n.t., hong kong tel: 852-2401-1200 fax: 852-2401-3431 india microchip technology inc. india liaison office divyasree chambers 1 floor, wing a (a3/a4) no. 11, o ? shaugnessey road bangalore, 560 025, india tel: 91-80-2290061 fax: 91-80-2290062 japan microchip technology intl. inc. benex s-1 6f 3-18-20, shinyokohama kohoku-ku, yokohama-shi kanagawa, 222-0033, japan tel: 81-45-471- 6166 fax: 81-45-471-6122 korea microchip technology korea 168-1, youngbo bldg. 3 floor samsung-dong, kangnam-ku seoul, korea tel: 82-2-554-7200 fax: 82-2-558-5934 asia/pacific (continued) singapore microchip technology singapore pte ltd. 200 middle road #07-02 prime centre singapore, 188980 tel: 65-334-8870 fax: 65-334-8850 taiwan microchip technology taiwan 11f-3, no. 207 tung hua north road taipei, 105, taiwan tel: 886-2-2717-7175 fax: 886-2-2545-0139 europe denmark microchip technology denmark aps regus business centre lautrup hoj 1-3 ballerup dk-2750 denmark tel: 45 4420 9895 fax: 45 4420 9910 france arizona microchip technology sarl parc d ? activite du moulin de massy 43 rue du saule trapu batiment a - ler etage 91300 massy, france tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany arizona microchip technology gmbh gustav-heinemann ring 125 d-81739 munich, germany tel: 49-89-627-144 0 fax: 49-89-627-144-44 italy arizona microchip technology srl centro direzionale colleoni palazzo taurus 1 v. le colleoni 1 20041 agrate brianza milan, italy tel: 39-039-65791-1 fax: 39-039-6899883 united kingdom arizona microchip technology ltd. 505 eskdale road winnersh triangle wokingham berkshire, england rg41 5tu tel: 44 118 921 5869 fax: 44-118 921-5820 10/01/00 w orldwide s ales and s ervice microchip received qs-9000 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona in july 1999. the company ? s quality system processes and procedures are qs-9000 compliant for its picmicro ? 8-bit mcus, k ee l oq ? code hopping devices, serial eeproms and microperipheral products. in addition, microchip ? s quality system for the design and manufacture of development systems is iso 9001 certified.


▲Up To Search▲   

 
Price & Availability of PIC17C752T-33PT

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