tag 标签: pic18

相关博文
  • 热度 24
    2014-5-8 16:31
    1526 次阅读|
    0 个评论
    I have chum who is a senior software engineer and a columnist for the electronics and computing hobbyist magazine Everyday Practical Electronics in the UK. His name is Mike Hibbett.   Mike has a passion for developing highly reliable products, so I was very interested to hear about his Kickstarter campaign for a low-power, low-cost (LPLC) PIC18 development board .     As you are certainly aware, there are a plethora of microcontroller development boards available on the market, so why did Mike feel moved to create yet one more? "None of them quite hit the spot for me," he says on his Kickstarter page. "They were either too small, too power hungry, too expensive, or just too limiting." None had the "Goldilocks" combination of features and capabilities.   Mike wants to build circuits that run off a couple of coin cells for months or AA batteries for years. In the case of cost, he wants something affordable enough that he can deploy a new board in each project and not have to reuse a board from another project just because he can't afford an additional unit.   He also wants "lots of code space" and the ability to use "a proper, professional development environment. I write complex code, so I expect a decent debugger" Last, but certainly not least, he likes to make tiny projects. "Some of my stuff ends up in portable applications and even magic tricks."   The end result is the board shown above. This little beauty is based on a Microchip PIC18F27J13 processor, which is small yet powerful. The PIC18F is quite a powerful processor for its size and cost; it runs at 48 MHz, can process 12 million instructions per second, and provides 128KB of Flash program storage. Its architecture is designed to facilitate being programmed in C.   Though the LPLC board itself is tiny, it still offers access to more than 20 I/O pins that can be used to implement myriad cool projects. Consider the following example.     The above image shows an LPLC prototype board implementing a simple, battery-powered, single-channel oscilloscope driving an equally low-cost color LCD display -- all implemented on a standard breadboard. From Mike's Kickstarter project page, I see that there are only six days to go. If you are interested in laying your hands on one of these little LPLC beauties, now is the time to do so.
  • 热度 24
    2014-5-8 16:28
    1561 次阅读|
    0 个评论
    My firiend Mike Hibbett is a senior software engineer and a columnist for the electronics and computing hobbyist magazine Everyday Practical Electronics in the UK.   Mike has a passion for developing highly reliable products, so I was very interested to hear about his Kickstarter campaign for a low-power, low-cost (LPLC) PIC18 development board .     As you are certainly aware, there are a plethora of microcontroller development boards available on the market, so why did Mike feel moved to create yet one more? "None of them quite hit the spot for me," he says on his Kickstarter page. "They were either too small, too power hungry, too expensive, or just too limiting." None had the "Goldilocks" combination of features and capabilities.   Mike wants to build circuits that run off a couple of coin cells for months or AA batteries for years. In the case of cost, he wants something affordable enough that he can deploy a new board in each project and not have to reuse a board from another project just because he can't afford an additional unit.   He also wants "lots of code space" and the ability to use "a proper, professional development environment. I write complex code, so I expect a decent debugger" Last, but certainly not least, he likes to make tiny projects. "Some of my stuff ends up in portable applications and even magic tricks."   The end result is the board shown above. This little beauty is based on a Microchip PIC18F27J13 processor, which is small yet powerful. The PIC18F is quite a powerful processor for its size and cost; it runs at 48 MHz, can process 12 million instructions per second, and provides 128KB of Flash program storage. Its architecture is designed to facilitate being programmed in C.   Though the LPLC board itself is tiny, it still offers access to more than 20 I/O pins that can be used to implement myriad cool projects. Consider the following example.     The above image shows an LPLC prototype board implementing a simple, battery-powered, single-channel oscilloscope driving an equally low-cost color LCD display -- all implemented on a standard breadboard. From Mike's Kickstarter project page, I see that there are only six days to go. If you are interested in laying your hands on one of these little LPLC beauties, now is the time to do so.
  • 热度 22
    2013-2-20 11:17
    1612 次阅读|
    1 个评论
    PICC18(V9.80)的配置位的定义位置     编译环境: MPLAB IDE(V8.89) + PICC18(V9.80)  在 “Quick Start.pdf” 文档中, 我们读到第一个 hello world 代码, 我们略略调整如下:   #include   __CONFIG(1, FCMDIS IESODIS XT);   void main(void) { while(1); }   尽管编译顺利通过, 我们想知道的, 就是”配置宏”, 比方说 FCMDIS 在哪里定义?  似乎网络上, 曾提及在旧版本中可以到安装目录下的 include 文件夹中, 寻找类似"pic18Fxxxx.h” 头文件, 但是在我们安装的这个版本中, 却无法找到. 实际上, 即使用”文件查找”的方式, 都无法找到 FCMDIS 的定义.   尽管在 IDE 中, 允许我们在可视化操作下, 对配置位进行选择和配置, 但是当我们 uncheck Configuration Bits set in code, 也就是使用 Configuration Bits Window 进行配置时, 我们发现最终生成的 hex 文件, 却不不包含该配置位. 实际上, 在 IDE 的 output window, 也充分说明了该现象: 虽然, 我们在配置位窗口, 选择各项设定, 但是在 hex file 上, 却没有发现配置位. 一个合理的假设是, 当我们使用 IDE 使用 programmer 时, IDE 在帮我们做这个 job``` 这令人烦恼, 试试看出货时, 在生产的电脑上, 安装 IDE, 开启 project, 某个生产工程师或产线MM做 program````  ; (   因此, 我们应该使用 do set configuration bits with code, 也就是 章节中, 我们提到的: __CONFIG(1, FCMDIS IESODIS XT);   在屏蔽了 configuration bits windows 的 enable checkbox 后, 我们回到了代码实现的工作, rebuile后,  通过对 HEX 文件的分析, 我们也可以证实上述现象.     我们在 HICC18 安装目录中, 找到了 \dat\cfgmap 目录下的 .cfgmap 文件(比如说 18f45k20.cfmap). 这里可能是”配置宏”被定义的地方.   要提及的是, 我们也找到了有着同样疑问的帖子,  http://forum.htsoft.com/all/showflat.php/Cat/0/Number/233812/page/0/fpart/2/vc/1 这里的讨论者, 饶有兴趣提到了, 该文档中的语法问题, 简单提一下: 形如 “XT:FOSC=XT” 的意义, 我们一看就懂. 那么, “FCMDC:” (就是我们要找的这个”配置宏”) 又代表了啥? 这个帖子中, 不少人猜测这是 “If you're seeing just FCMDIS:, I'd guess that means mean exactly what you'd expect: FCMDIS is legal, but doesn't do anything (i.e., OFF is its default state anyway). ” 说起来, 我们认同这个假设…. ; P   当我们找到了 .cfgmap 文件, 并通过 “:” 后的解释, 或者直接猜测 “FCMDC:”(没有任何解释, 依靠我们推测其为默认值), 我们可以使用 __CONFIG 方式, 进行配置位设定. 但是, 检索 HICC18 的 manual 文档, 我们很清晰知道, 原来 __CONFIG 是一种过时用法, 不被 V9.80 继续推荐(From “Configuration Fuse” of Chapter “C Language Features”), 这里引入了新的配置方式如下:   之所以使用这个语法, 如同该使用手册中提到的, 各种设定值, 有着详细的文档支持.  容易找到 chipinfo.html, 很快的, 在 html 文档的支持下, 我们很容编写出类似下面语句的例子:   #include   //__CONFIG(1, FCMDIS IESODIS FOSC_INTIO7); #pragma config IESO=OFF, FOSC=INTIO7, FCMEN=OFF   void main(void) { while(1); } 显然, 两者效果是等效的. 不意外的, 我们检查 HEX 文件, 也是相同的. 另外提及的是, 在 0x300001 处的 config byte 的值就是 9, 这与 IDE 中的 configuration Bites Set Window 中选择相应的项目是一致的. 因此, 在 chipinfo.html 文档的帮助下, 设定 configuration bits 的任务变得轻易.   Allen Zhan allen_zhan@163.com Release ON  
  • 热度 24
    2013-2-20 11:14
    3031 次阅读|
    6 个评论
    PIC18 GPIO 的 "Read-modify-write操作"使用特点   接触与使用 PIC18 的 GPIO, 是一件饶有兴致的事. 原因就是我们发现, MICROCHIP 把所谓” Read-modify-write Operations” 现象, 小心翼翼地强调提出, 并在 PIC18 中, 专门使用了一个 LAT register 作为解决方法.   这个特点, 是我们在之前的经验中, 未曾遇到的.   在持续的思考这个现象后, 我们假设, 这与 “Read-modify-write” 行为中, 包含有 bit 操作有关, 应该说明的是, 没有作更多资料搜索去证明这个说法, 这只是 Allen 对这个问题的考虑与判断, 请读者自明.   随意用google 检索到一个简单解释: http://www.piclist.com/tecHREF/readmodwrite.htm When you perform any operation, apart from a MOV on a register ... the PIC {or SX} first reads the register, then it performs the operation on the number it has just read and finally it write the number back to the register.  当我们对某个 register 进行操作时, 我们首先从该 register中读回(read) data, 然后对该 data进行修改(modify)后, 再写回(write)该register. 这就是所谓” Read-modify-write 操作”.   但是对于 GPIO register. ” Read-modify-write 操作”可能会带来两个问题: (1) PORT 总是读回 PIN 脚上的当前值. ---- 这个值有可能是错的(因为外部电路可能非正常改变它).  (2) 对一个 PIN 单独地立即 toggle 操作, 将可能得不到正确的状态响应. ---- 可能在PIN 没有 toggle 改变时, 下一个 read pin 的操作已经到来. 一份中文资料, http://blog.21ic.com/user1/5742/archives/2010/72577.html, 也基本上对上述说法进行了类似的解释.   当然. 我们在假设不进行 bit 操作的情况下, 我们可以避免上面的错误的发生, 那么我们只用下面的用法即可(我们总是对整个的 PORT 进行操作即可):   // this sample code used with microchip PIC18F45K20 TRISD = 0x00; PORTD = 0x01;   但是, 在一个 real world里, 对单个 PORT PIN 的操作是经常的事情, 大多数情况下, 特别是非并行操作的情况下, 我们其实无需对整个 PORT 相关寄存器进行操作.  比方说, 在 8-bit MCU 中, 我们可能不需要对 PORTA(8PINS) 进行操作. 而对于 32-bit MCU, 当然这里 PORTA 往往代表着 32 个PIN脚. 回到上面的例子中, 我们其实仅仅只想将 D0 置1, 而不是想将 D7~D1 同时都置 0.   让我们看看其他的 MCU 给出的单独操作 PIN 脚的办法吧. 以 NXP 的 LPC21XX 系列进行比较, 这是颗 32-bit ARM7 MCU. 我们注意到, 用于 GPIO 的 register, 往往包括 4 个 register:  IOPIN, IOSET, IODIR(方向), IOCLR.   其中, IODIR 是方向寄存器, 那么, 对 PINIO 的操作即是. (1) RD: 用 IODIR 定义方向, READ IOPIN (2) WR: 用 IODIR 定义方向后, WRITE IOPIN   对于单独PIN如何处理? 我们注意到, NXP 给出的方式是: 两个registers, IOSET/IOCLR. 两者用于单独控制某个 PIN 脚.  From lpc21xx datatsheet pdf:   比如说,  // this sample code used with nxp lpc2103 #define RELAY_PIN 0x0121 // P0.21   IO0DIR = IO0DIR | RELAY_PIN;     IO0CLR = RELAY_PIN; 我们注意到, 在这份代码片段中, 只有被置 1 的 P0.21 被拉低, 而根据 datasheet 对 register 的解释, 被置 0 的bit(代表其他不同的PIN), 不产生任何影响.   这就是 NXP 的单独控制 GPIO 的方案. 完全没有提及所谓” Read-modify-write 操作”.  这里我们随意提到另个 IOSET/IOCLR 的特点, 同时并行输出多个”1”与”0”, 不推荐使用 IOSET/IOCLR. 而应该使用 IOPIN. 理由是前者同时输出可能会出现错误.   在我们注意到 ” Read-modify-write 操作” 的限制后,  如果我们相信电路上 GPIO 技巧被上拉下拉或者限流电阻的存在的可靠性, 或者我们相信我们不需要考虑立即的 toggle, 那么我们可以使用下面的不可靠用法: // PORTD bit 0 to output (0); bits 7:1 are inputs (1) TRISD = 0b11111110; PORTDbits.RD0 = 1;   如果我们不确定呢? 也许我们可能会有一个 back ram 就能解决 “read-modify-write GPIO register” 的烦恼.   但是, 如同我们好奇地发现的, 在 PIC18 系列中, 出现了一个新的 register: LAT.  我们也注意到很多 PIC10 serial 中, 不存在这个 LAT register .   让我们观察 MICROCHIP 的 PIC18 的 GPIO 的原理框图(from datasheet pdf):   难道不是很有趣吗? 现在我们看到了别出心裁的 Data Latch 了. 我们现在有 3 个 registers 处理 GPIO: TRIS(方向), PORT, LAT (1) RD PORT, 用 TRIS 定义方向, 我们从 I/O 读到了实际的 PIN脚状态. (2) WD, 无论是写 PORT register, 还是写 LAT 寄存器, 我们都把 data 放到了 Data Latch 中, 然后输出到了 PIN 脚. (3) RD LAT, 从 DataLatch 中读取了被锁存的 data.  这意味着, 尽管我们用 PORT 和 LAT register 都能输出正确的状态. 但是考虑到 “Read-modify0write”, 我们承担着 PIN 脚上(PORT)上可能被外部电路影响的错误数据的风险(从而导致错误输出), 我们使用 LAT 将不会产生这个担心.    // PORTD bit 0 to output (0); bits 7:1 are inputs (1) TRISD = 0b11111110; LATDbits.LATD0 = 1;   因此, 对 PIN18, 不意外的, 我们应该使用 LAT register 作 output 操作, 用 PORT 做 read 操作. 在特别的 LAT register 的帮助下, 我们可以使用 LAT 进行"bit相关操作"而不必担心 “Read-modify0write” 操作影响.        Written by Allen Zhan   Realse on EETC  
相关资源
  • 所需E币: 1
    时间: 2023-3-29 17:18
    大小: 210.02KB
    上传者: 张红川
    基于PIC18单片机的RS+485CAN智能转换器的设计.pdf
  • 所需E币: 0
    时间: 2022-6-2 10:55
    大小: 266.31KB
    ImplementingaPidControllerUsingaPic18mcu(Microchip)
  • 所需E币: 3
    时间: 2021-3-20 21:34
    大小: 170.82MB
    上传者: samewell
    PIC18系列单片机原理及C语言开发
  • 所需E币: 0
    时间: 2020-9-26 00:21
    大小: 126.84MB
    上传者: LGWU1995
    PIC18系列单片机原理及C语言开发.rar
  • 所需E币: 1
    时间: 2020-9-10 12:26
    大小: 204.65MB
    上传者: 林剑斌
    PIC18系列单片机的原理介绍,以及C语言编程,还有Protues仿真实验
  • 所需E币: 5
    时间: 2019-12-25 21:23
    大小: 88.77KB
    上传者: 978461154_qq
    IAREmbeddedWorkbench®isasetofhighlysophisticatedandeasy-to-usedevelopmenttoolsforprogrammingembeddedapplications.ItintegratestheIARC/C++compiler,assembler,linker,librarian,texteditor,projectmanager,andC-SPY™debuggerinoneintegrateddevelopmentenvironment(IDE).Withitsbuilt-inchip-specificcodeoptimizer,IAREmbeddedWorkbenchgeneratesveryefficientandreliablePROMablecodeforthePIC18microcontroller.Inadditiontothissolidtechnology,IARSystemsalsoprovidesprofessionalworldwidetechnicalsupport.……
  • 所需E币: 5
    时间: 2019-12-24 21:21
    大小: 155.57KB
    上传者: wsu_w_hotmail.com
    Thisapplicationnoteisdevelopedbasedonlowlatencydesign.Itprovidesanalgorithm,whichisdesignedtousetheSPI/I2C™interrupts,toachievetherequiredcommunicationandenableoptimumprocessorusage.ThealgorithmisdevelopedbasedonthePIC18MasterSynchronousSerialPort(MSSP)modulewithexternalSerialPeripheralInterface(SPI)EEPROMsandI2CEEPROMs,respectively.Thealgorithmusesaninterruptdrivenapproach.AN1243LowLatencyDrivertoAccessExternalEEPROMUsingPIC18FamilyDevicesAuthors:ObulReddyandGaneshKrishnaS.MDisadvantagesofConventionalApproachMicrochipTechnologyInc.ExternalEEPROMchips,connectedviaSPIorI2C,tendtoconsumealotofmicrocontrollerthroughputtocommunicate.TheroutinesaccessingtheEEPROMINTRODUCTIONwillhavetowaituntilthecommunicationisreliablyThisapplicationnoteisdevelopedbasedonlowlatencycompleted.Duringt……
  • 所需E币: 3
    时间: 2019-12-24 21:20
    大小: 298.62KB
    上传者: rdg1993
    ThisapplicationnotepresentsaLIN2.0-compliantdriverforthePIC18XXXXfamilyofmicrocontrollers.Thisdocumentwillfocusonthesetupandimplemen-tationofthedriverforamasterand/oraslavenode(s).ThematerialinthisdocumentispresentedwiththeassumptionthatthereaderisfamiliarwiththepreviousversionsoftheLINspecification.OnlykeyadditionsandmodificationsoftheLINspecification2.0,themostcurrentspecificationavailabletodate,willbehighlighted.AN1009LIN2.0CompliantDriverUsingthePIC18XXXXFamilyMicrocontrollersAuthors:ThorstenWaclawcyzkLIN2.0CHANGESMicrochipTechnologyInc.SignalgroupsarereplacedwithbytearraysthatJinXusupportsignalsizesuptoeightbytes.MicrochipTechnologyInc.Automaticbitratedetectionisincorporated.Unliketheclassicchecksumthatincludesonlythedatabytes,theenh……
  • 所需E币: 4
    时间: 2019-12-24 21:19
    大小: 355.45KB
    上传者: wsu_w_hotmail.com
    ThisApplicationNotecoversfourencryptionalgorithms:AES,XTEA,SKIPJACK®andasimpleencryptionalgorithmusingapseudo-randombinarysequencegenerator.ThescienceofcryptographydatesbacktoancientEgypt.Intoday’seraofinforma-tiontechnologywheredataiswidelyaccessible,sensitivematerial,especiallyelectronicdata,needstobeencryptedfortheuser’sprotection.Forexample,anetwork-basedcardentrydoorsystemthatlogsthepersonswhohaveenteredthebuildingmaybesuscep-tibletoanattackwheretheuserinformationcanbestolenormanipulatedbysniffingorspoofingthelinkbetweentheprocessorandthememorystoragedevice.Iftheinformationisencryptedfirst,ithasabetterchanceofremainingsecure.Manyencryptionalgorithmsprovideprotectionagainstsomeonereadingthehiddendata,aswellasprovidingprotectionagainsttampering.Inmostalgorithms,thedecryptionprocesswillcausetheentireblockofinformationtobedestroyedifthereisasinglebiterrorintheblockpriortodecryption.AN953DataEncryptionRoutinesforthePIC18Author:DavidFlowersENCRYPTIONMODULEOVERVIEWMicrochipTechnologyInc.Fouralgorithmstochoosefrom,eachwiththeirownbenefitsINTRODUCTIONAdvancedEncryptionStandard(AES)ThisApplicationNotecoversfourencryption-ModulesavailableinC,Assemblyandalgorithms:AES,XTEA,SKIPJACKandasimpleAssemblywrittenforCencryptionalgorithmusingapseudo-random……
  • 所需E币: 4
    时间: 2019-12-24 19:09
    大小: 247.84KB
    上传者: 238112554_qq
    Traditionally,themicrocontrollerstackhasonlybeenusedasastoragespaceforreturnaddressesofsub-routinesorinterruptroutines,whereall‘push’and‘pop’operationswerehidden.Forthemostpart,usershadnodirectaccesstotheinformationonthestack.ThePIC18microcontrollerdivergesfromthistraditionslightly.WiththenewPIC18core,usersnowhaveaccesstothestackandcanmodifythestackpointerandstackdatadirectly.Havingsuchlevelsofaccesstothestackallowsforsomeuniqueandinterestingprogrammingpossibilities.Thisapplicationnotedescribesspecificinformation,registers,andinstructionsrelatedtoaccessingthestack.Anexampleisalsoincludeddemonstratingaverysimpletaskmanager,anessentialelementforareal-timeoperatingsystem(RTOS).MAN818ManipulatingtheStackofthePIC18MicrocontrollerAuthor:RossM.FoslerThepointertothetopofthestackisprovidedinregisterMicrochipTechnologyInc.STKPTR.Thepointerisonlyfive-bitswide,whichaccountsforastackdepthof32words.However,thefirstlocationisnotcounted,sinceitisnotphysicallyaINTRODUCTIONmemorylocationinthestack.ThefirstlocationalwaysTraditionally,themicrocontrollers……
  • 所需E币: 5
    时间: 2019-12-24 19:03
    大小: 812.9KB
    上传者: 978461154_qq
    AmongthemanyfeaturesbuiltintoMicrochip’sEnhancedFLASHMicrocontrollerdevicesisthecapa-bilityoftheprogrammemorytoself-program.Thisveryusefulfeaturehasbeendeliberatelyincludedtogivetheusertheabilitytoperformbootloadingoperations.DeviceslikethePIC18F452aredesignedwithadesig-nated“bootblock”,asmallsectionofprotectablepro-grammemoryallocatedspecificallyforbootloadfirmware.ThisapplicationnotedemonstratesaverypowerfulbootloaderimplementationforthePIC16F87XAandPIC18Ffamiliesofmicrocontrollers.Thecodingforthetwodevicefamiliesisslightlydifferent;however,thefunctionalityisessentiallythesame.Thegoalsofthisimplementationstressamaximumperformanceandfunctionality,whilerequiringaminimumofcodespace.AN851AFLASHBootloaderforPIC16andPIC18DevicesAuthor:RossM.FoslerandFIGURE1:BOOTLOADERFUNCTIONALRodgerRicheyBLOCKDIAGRAMMicrochipTechnologyInc.BootloaderFirmwareRXTXINTRODUCTION……
  • 所需E币: 5
    时间: 2019-12-24 17:52
    大小: 1.21MB
    上传者: wsu_w_hotmail.com
    ThischaptercontainsgeneralinformationthatwillbeusefultoknowbeforeyouusetheMPLABStarterKitforPIC18F.Itemsdiscussedinthischapterinclude:•DocumentLayout•ConventionsUsedinthisGuide•WarrantyRegistration•RecommendedReading•TheMicrochipWebSite•DevelopmentSystemsCustomerChangeNotificationService•CustomerSupport•DocumentRevisionHistoryMPLABStarterKitforPIC18FUser’sGuide2009MicrochipTechnologyInc.DS51852ANotethefollowingdetailsofthecodeprotectionfeatureonMicrochipdevices:MicrochipproductsmeetthespecificationcontainedintheirparticularMicrochipDataSheet.Microchipbelievesthatitsfamilyofproductsisoneofthemostsecurefamiliesofitskindonthemarkettoday,whenusedintheintendedmannerandundernormalconditions.Therearedishonestandpossiblyillegalmethodsusedtobreachthecodeprotectionfeature.Allofthesemethods,toourknowledge,requireusingtheMicrochipproductsinamanneroutsidetheoperatingspecificationscontainedinMicroc……
  • 所需E币: 3
    时间: 2019-12-24 10:36
    大小: 754.5KB
    上传者: quw431979_163.com
    PIC18家族指令集MicrochipPIC18家族指令集PIC18系列家族指令快速索引|指令|指令说明|影响旗号|参考说|||||明页数||字节运算指令(BYTE-ORIENTEDFILEREGISTEROPERATIONS)||ADDWF|f,d,|将W与f做相加,并将结果放至W或|C,DC,Z,|7|||a|f。|OV,N|||ADDWFC|f,d,|将W与C做相加,并将结果放至W或|C,DC,Z,|10|||a|f。|OV,N|||ANDWF|f,d,|将W与f做AND运算,并将结果放至|Z,N|14|||a|W或f。||||CLRF|f,a|将f内的值都清为0。|Z|31||COMF|f,d,|将f内的值取补码,并将结果放至|Z,N|33|||a……
  • 所需E币: 5
    时间: 2019-12-24 10:36
    大小: 1.01MB
    上传者: wsu_w_hotmail.com
    PIC18外设配置应用_中文版.pdf……