[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-562619-105":59,"doc-detail-562619-en":130,"doc-similar-562619":162},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","an556-implementing-a-table-read-application-note","AN556 - Implementing a Table Read - Application note","","AN556 explains how to implement a table look-up in Microchip PIC microcontrollers using table read operations in program memory. It presents the concept of building a lookup table from retlw K instructions and shows how computed gotos can branch to the appropriate constant. The note details PIC16CXXX PC/PCL/PCLATH loading behavior, CALL/GOTO high-bit handling, page boundary risks, and mitigation via 13-bit computed GOTO. It also summarizes necessary considerations and conversions for the PIC16C5X family.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/an556-implementing-a-table-read-application-note/562619/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/an556-implementing-a-table-read-application-note/562619.png","ImageObject",300,407,{"name":92,"@type":93},"OmBimo","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-26","2026-10-12",true,{"@type":102,"interactionType":103,"userInteractionCount":44},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What is a table read in program memory for PIC16CXXX devices?","Question",{"text":112,"@type":113},"A table read requires executing a computed control flow that returns constants from a sequence of retlw K instructions mapped to program memory literals. The first instruction calculates an offset and branches to the corresponding retlw K entry.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"Why must PCLATH be pre-loaded when using CALL/GOTO and computed GOTO for tables?",{"text":117,"@type":113},"Because the high bits of the program counter (PCH) for PIC16CXXX are not directly accessible and must be provided via PCLATH. If PCLATH is not set with the high byte of the table address, the computed goto may target the wrong page.",{"name":119,"@type":110,"acceptedAnswer":120},"How do you handle table look-ups that cross page boundaries?",{"text":121,"@type":113},"The ADDWF PCL step cannot compute beyond 8 bits, so offsets that roll over may branch unintentionally. The note recommends monitoring page roll-over or implementing a 13-bit computed GOTO (Example 5) to place and access the table anywhere in program memory.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},562619,1791908239,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":44,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":24,"language":139,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":67,"update_tm":143,"read_time":144,"preview_page_count":19,"preview_urls":145},962090893581,"https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c","AN556  \nImplementing a Table Read  \nAuthor: Stan D’Souza  \nMicrochip Technology Inc.  \nINTRODUCTION  \nThis application note shows how to implement a table look-up for the following devices:  \n• PIC12CXXX  \n• PIC12CEXXX  \n• PIC16CXXX  \n• PIC16CEXXX  \n• PIC16FXXX  \nThe examples shown are for the PIC16CXXX family. An explanation of differences for the PIC16C5X family is at the end of this application note.  \nTo access data in program memory, a table read operation must be performed. The table consists of a series of retlw K instructions where, the 8-bit table constants are assigned to the literal K. The first instruction in the table computes the offset to the table by using addwf PCL,F and consequently, the program branches to the appropriate retlw K instruction (Example 1) .  \nEXAMPLE 1:  \n.  \n.  \nmovlw offset ;load offset in w reg call Table  \n.  \n.  \n.  \nTable:  \naddwf PCL,F ;add offset to pc to ;generate a computed goto  \nretlw ’A’ ;return the ASCII char A  \nretlw ’B’ ;return the ASCII char B  \nretlw ’C’ ;return the ASCII char C  \n.  \n.  \n.  \nThe method is straight forward, however, certain precautions have to be exercised when doing a table read in the PIC16CXXX.  \nIMPLEMENTATION  \nProgram Counter Loading  \nThe Program Counter (PC) in the PIC16CXXX is 13-bits wide. The low 8-bits (PCL) are mapped in RAM at location 02h and are directly readable and writable. The high 5-bits are not accessible directly and can only be written through the PCLATH register (Figure 1) . The PCLATH register is a R/W register with only five of its bits implemented \u003C4:0>, all other bits read as '0' .  \nFIGURE 1: LOADING OF PC INDIFFERENT SITUATIONS  \n\n| PCH PCL\u003Cbr>12 8 7 0 |  |  | Instruction with PCL as  Destination\u003Cbr>ALU |\n| --- | --- | --- | --- |\n| PC | |  |  |\n| PCLATH |  |  |  |\n| PC | PCH PCL\u003Cbr>12 11 10 8 7 0\u003Cbr>\u003Cbr>\u003Cbr>PCLATH | GOTO, CALL\u003Cbr>Opcode \u003C10:0> |  |\n\n􀀁 2000 Microchip Technology Inc. DS00556E-page 1  \nAN556  \nSECTION 1  \nCALL and GOTO Instructions  \nWhen executing a CALL or GOTO , the low 11-bits are loaded directly from the instruction opcode. The high 2-bits are loaded from bits 3 and 4 of the PCLATH register. It is a good practice to pre-load PCLATH with the high byte of the routine’s address before executing the routine. This can be done as follows:  \nEXAMPLE 2:  \n.  \n.  \nmovlw HIGH Table ;load high 8-bit ;address of Table  \nmovwf PCLATH ;into PCLATH  \ncall Routine ;execute Call  \n;instruction  \n.  \n.  \nNote: If the program memory size is less than 2K-words, then the above precaution isnot necessary.  \nComputed GOTO Instruction  \nAny instruction with PCL as the destination, will load the PCH with the 5 low bits from the PCLATH (Figure 1) . In Example 3, if the address where the CALL was made was on Page 0 and the address of the actual table was on Page 3, then when executing the computed GOTO, the program will go to a location in Page 0 instead of a location on Page 3. To prevent the program from branching to an unintended location when doing a table read, the PCLATH register should be pre-loaded with the high byte of the \"Table\" address. Example 3A shows how this can be done.  \nEXAMPLE 3:  \n.  \norg 0x80 ;code location in page 0  \nmovlw offset ;load offset in w reg call Table  \n.  \n.  \norg 0x0320 ;Table located in page 3  \nTable:  \naddwf PCL,F ;add offset to pc to ;generate a computed goto  \nretlw ’A’ ;return the ASCII char A  \nretlw ’B’ ;return the ASCII char B  \nretlw ’C’ ;return the ASCII char C  \n.  \n.  \n.  \nEXAMPLE 3A:  \norg movlw  \nmovwf  \nmovlw call  \n.  \n.  \n.  \norg Table:  \naddwfretlw  \nretlw  \n.  \n.  \n.  \n0x80  \nHIGH Table PCLATH offset  \nTable  \n0x320  \nPCL,F  \n’A’  \n’B’  \nAN556  \nWhen doing a computed GOTO for a table read, care should be taken about page boundaries. The ADDWF PCL instruction will not compute a value greater than 8-bits. In Example 4, the result of the computed GOTO will result in a branch to an unintended portion of the code for a value in offset greater than zero. The user either has to be caut","cbCaijB3aOidaFDG","https://ap.wps.com/l/cbCaijB3aOidaFDG","pdf",81700,"English","# Introduction\n# Implementation\n## Program Counter Loading\n## CALL and GOTO Instructions\n## Computed GOTO Instruction\n## 13-bit computed GOTO for page boundaries\n# Implementation for the PIC16C5X Family","[{\"question\":\"What is a table read in program memory for PIC16CXXX devices?\",\"answer\":\"A table read requires executing a computed control flow that returns constants from a sequence of retlw K instructions mapped to program memory literals. The first instruction calculates an offset and branches to the corresponding retlw K entry.\"},{\"question\":\"Why must PCLATH be pre-loaded when using CALL/GOTO and computed GOTO for tables?\",\"answer\":\"Because the high bits of the program counter (PCH) for PIC16CXXX are not directly accessible and must be provided via PCLATH. If PCLATH is not set with the high byte of the table address, the computed goto may target the wrong page.\"},{\"question\":\"How do you handle table look-ups that cross page boundaries?\",\"answer\":\"The ADDWF PCL step cannot compute beyond 8 bits, so offsets that roll over may branch unintentionally. The note recommends monitoring page roll-over or implementing a 13-bit computed GOTO (Example 5) to place and access the table anywhere in program memory.\"}]","AN556 - Implementing a Table Read - Application note | PDF",1791809106,13,[146,150,154,158],{"page_no":8,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/4b38e6ffc95f3f5d176f9a2fd3754ce0.webp",983,1272,{"page_no":14,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/d42dda7bfc3cd5cdedae12a6ea84164f.webp",982,1270,{"page_no":81,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/f1b366cb5f06ac19b7b5eaee3dab66d8.webp",981,1269,{"page_no":19,"url":159,"width":160,"height":161},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/f87f5ac506c181a39a7cfbf92f386c4e.webp",980,1268,{"list":163,"token":66},[164,170,176,182,188,195,201,207,213,219],{"doc_id":165,"doc_title":166,"file_type":137,"home_preview_img_url":167,"slug":168,"view_count":19,"category_name":30,"create_tm":169},562618,"AN526 - PIC16C5X / PIC16CXXX Math Utility Routines","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229947819843/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212679&Signature=2yNYOi92brJ6cTXIQmFFfJF4JhM%3D","an526-pic16c5x-pic16cxxx-math-utility-routines",1791809101,{"doc_id":171,"doc_title":172,"file_type":137,"home_preview_img_url":173,"slug":174,"view_count":14,"category_name":30,"create_tm":175},700758,"Focus Product Selector Guide - Microcontrollers & Analog - Product Selection Overview","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230012035061/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212679&Signature=59RNl6k77FHMRFbAHl59QaLqefU%3D","focus-product-selector-guide-microcontrollers-analog-product-selection-overview",1794520592,{"doc_id":177,"doc_title":178,"file_type":137,"home_preview_img_url":179,"slug":180,"view_count":44,"category_name":30,"create_tm":181},559239,"A WILLEM programozó - PCB3 és PCB5 verzió","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229947577864/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212679&Signature=e3oBhllXKy2xYi4pBeB9rSI7EwY%3D","willem-programmer-pcb3-and-pcb5-version",1791800402,{"doc_id":183,"doc_title":184,"file_type":137,"home_preview_img_url":185,"slug":186,"view_count":19,"category_name":30,"create_tm":187},692139,"Corporate Focus Product Selector Guide - First Half 2011","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230002904637/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212679&Signature=zEOPq6Af8i3hCp6GX2He5%2FCmuRQ%3D","corporate-focus-product-selector-guide-first-half-2011",1794179603,{"doc_id":189,"doc_title":190,"file_type":137,"home_preview_img_url":191,"slug":192,"view_count":193,"category_name":30,"create_tm":194},562603,"PICBASIC PRO™ Compiler - Programmer's Manual - Table of Contents","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229947819259/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212679&Signature=4sPpBPvJ7tsb5RBo1JoV6G8AR9k%3D","picbasic-pro-compiler-programmers-manual-table-of-contents",12,1791809075,{"doc_id":196,"doc_title":197,"file_type":137,"home_preview_img_url":198,"slug":199,"view_count":19,"category_name":30,"create_tm":200},690225,"TC270 / TC275 / TC277 DC-Step - Data Sheet - V 1.0","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230002599360/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212679&Signature=E1k%2FLWi79AVuOnimABSKFNA1zWE%3D","tc270-tc275-tc277-dc-step-data-sheet-v-10",1794158938,{"doc_id":202,"doc_title":203,"file_type":137,"home_preview_img_url":204,"slug":205,"view_count":34,"category_name":30,"create_tm":206},690304,"AURIX™ TC3xx - User's Manual - Open Market Version 2.0 - V2.0.0 2021-02","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230002618367/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212679&Signature=Jbyt6RCQTVw0thYNIS5jo4Kfihs%3D","aurix-tc3xx-users-manual-open-market-version-20-v200-2021-02",1794162141,{"doc_id":208,"doc_title":209,"file_type":137,"home_preview_img_url":210,"slug":211,"view_count":34,"category_name":30,"create_tm":212},561490,"SN8P2501B 8-Bit Micro-Controller - User’s Manual - Preliminary Specification Version 0.5","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229947648710/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212679&Signature=u8uG%2BC0eXpk%2BfNpizbaynwkj974%3D","sn8p2501b-8-bit-micro-controller-users-manual-preliminary-specification-version-05",1791805991,{"doc_id":214,"doc_title":215,"file_type":137,"home_preview_img_url":216,"slug":217,"view_count":81,"category_name":30,"create_tm":218},690327,"Infineon TC290 / TC297 / TC298 / TC299 32-Bit Single-Chip Microcontroller - Data Sheet - Revision V 1.1 - 2019-03","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230002018592/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212679&Signature=L4YFkFYsIxC7%2FQLliOVVzLSm2KM%3D","infineon-tc290-tc297-tc298-tc299-32-bit-single-chip-microcontroller-data-sheet-revision-v-11-2019-03",1794163194,{"doc_id":220,"doc_title":221,"file_type":137,"home_preview_img_url":222,"slug":223,"view_count":52,"category_name":30,"create_tm":224},652822,"ROBOTICS - Technical reference manual - RAPID Instructions, Functions and Data types","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229973518316/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796212679&Signature=eUxMOXqwW9fQTxaZ5oCXCJqenhM%3D","robotics-technical-reference-manual-rapid-instructions-functions-and-data-types",1792883049]