ImageVerifierCode 换一换
格式:DOC , 页数:9 ,大小:48.50KB ,
资源ID:8655373      下载积分:10 金币
验证码下载
登录下载
邮箱/手机:
图形码:
验证码: 获取验证码
温馨提示:
支付成功后,系统会自动生成账号(用户名为邮箱或者手机号,密码是验证码),方便下次登录下载和查询订单;
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/8655373.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请。


权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:4009-655-100;投诉/维权电话:18658249818。

注意事项

本文(Microchip单晶片上的C语言应用说明(一)(第八期双月刊).doc)为本站上传会员【s4****5z】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

Microchip单晶片上的C语言应用说明(一)(第八期双月刊).doc

1、Microchip單晶片上的C語言應用說明(一) Microchip的PIC單晶片雖然只有37個指令,指令少雖然容易了解,但要做複雜的運算,則非常難以撰寫程式,為了減少開發時間,唯有使用C語言來開發。 筆者這次要跟大家談的是用C語言來開發八位元單晶片,在過去或許聽來覺得不可思議,因單晶片它通常只有幾K的記憶體(數K的ROM合幾十bytes的RAM),那麼少的記憶體還用C語言來開發,真是非常的浪費及不實用,在我參加了Microchip的研討會及使用後,我改變了看法;通常會使用組合語言無非是要求快及精簡,但事實上真的快及精簡了嗎?對於高手而言,或許真的精簡及速度變快,但需花費多少時間呢?一搬來

2、說需比用C語言來開發多三倍以上的時間,有些人甚至用組合語言寫出的程式碼比用C語言轉譯出的組合語言還長,且C語言易懂易維護,他有跨平台的特點,就算換了微處理器也只需些許修改就可以RUN了,組合語言則不然,它必須重新改寫程式碼;至於用C語言寫出來的程式它執行的(程式碼較長)速度較慢,在以前或許存在,現今各微處理器的速度都相當快,速度慢已不是問題,且開發時間可以縮短,是許多工程師及老闆的不二選擇。 因中心在八位元的單晶片上皆使用Microchip的PICmicro Devices,所以就以PICmicro Devices來做說明如何使用C語言來開發,Microchip所生產的單晶片有PIC16、P

3、IC17及PIC18系列,這些都是八位元的單晶片,這些晶片都有A/D轉換、Timer、PWM、IIC、RS232等功能,一般控制會用到的功能這裡都有,以一顆單晶片可以取代像早期8051需搭配一些週邊才能達到目前PIC系列的功能,不僅成本減少、相對板子面積也變小且IC數量較少產品也較穩定,且目前Microchip所開發的PIC系列單皆片皆為FLASH的版本,對於個人或小公司而言,晶片可以重複燒寫測試,非常的經濟實惠,相對開發費用較少,對於產品量少及小公司實在是不二選擇。 Microchip本身也有C語言版本的開發工具,但它只支援PIC17及PIC18系列,PIC16它就沒有支援,可能是PIC1

4、6系列目前程式記憶體最大為8K bytes,可能認為只有8K bytes,只要用組合語言來撰寫即可,順便一提Microchip的PIC單晶片其組合語言的開發工具是免費的,但C語言要另外購買,因目前的控制系統使用PIC16系列就夠了,Microchip又沒有PIC16的C語言開發工具,所以轉向購買B Knudsen Data所出的CC5X C Compiler,它支援PIC12/14/16 devices,它的售價也不貴約一萬五千塊台幣,目前中心只要有用到PIC皆使用CC5X來開發,所以針對CC5X C Compiler的用法作一些說明,讓使用PIC的使用者能快速進入C的世界。 CC5X C

5、Compiler支援的Devices有: A. 12 bit core (PIC16C5X, PIC12C50X, etc.): ‧ up to 2048 words of code on 1 - 4 code pages ‧ up to 73 byte RAM in 1 - 4 banks B. 14 bit core (PIC12C67X, PIC14000, PIC16CXX, etc.): ‧ up to 8192 words of code on 1 - 4 code pages ‧ up to 512 byte RAM in 1 - 4 banks CC5X安裝 它

6、可被安裝在MSDOS、Windows95/98/NT/2000,基本上它不需安裝,當你購買時,只需將整個目錄拷貝到電腦的硬碟即可,CC5X C Compiler它是一個Command-line的程式,例如cc5x -a sample1.c ;它也可以與Microchip的MPLAB相結合,提供compilers、assemblers、simulators、emulators、device programmers等功能,其安裝步驟如下或參考cc5x目錄下的install.txt: 1. 將CC5X的檔案拷貝至你的電腦其中的一個目錄,EX:c:\cc5x。 2. 然後從c:\cc

7、5x的目錄裡copy CC5X.MTC and TLCC5X.INI兩個檔案到MPLAB的目錄。 3. 啟動MPLAB,選擇MENU的Project->Install Language,在Language Suite中選擇CC5X,然後再點選工具名稱C-Compiler,然後在右邊執行欄keyin c:\cc5x\cc5x.exe,或者用瀏覽的按鍵去選擇你的CC5X的位置,再去點選Command-line box,然後按OK即可,此時CC5X已成為MPLAB的一部分了。 以下針對CC5X做一檔案說明: CC5X.EXE : compiler INTRO.TXT : introducti

8、on INSTALL.TXT : installation guide and MPLAB setup CC5X.TXT : basic documentation on CC5X PRAGMA.TXT : the pragma statement INLINE.TXT : information on inline assembly syntax DEBUG.TXT : debugging details, MPLAB support CHIP.TXT : how to make new chip definitions CONFIG.TXT : the PICmicro co

9、nfiguration bits CDATA.TXT : info on the #pragma cdata statement CONST.TXT : standard C strings and constant data GLOBDEF.TXT : PICmicro registers STARTUP.TXT : special startup sequences LINKER.TXT : how to link several modules (C or asm) INT16CXX.H : interrupt header file INLINE.H : emulatin

10、g inline instructions CC5X.MTC : MPLAB tool configuration file TLCC5X.INI : MPLAB tool configuration file OP.INC : command line options on a file RELOC.INC : options for object modules (MPLINK) SAMPLE1.C : minimal program example IICBUS.C : IIC-bus interface IIC-COM.C : IIC-bus communication

11、 SERIAL.C : serial communication (RS232, RS485) STATE.C : state machines DELAY.C : implementing delays INT16XX.C : simple interrupt example MATH.TXT : Math library support MATH16.H : 8-16 bit math library MATH16M.H : 8-16 bit multiply, speed MATH24.H : 8-24 bit math library MATH24M.H : 8-24

12、bit multiply, speed MATH32.H : 8-32 bit math library MATH32M.H : 8-32 bit multiply, speed MATH16X.H : 16 bit fixed point library MATH24X.H : 24 bit fixed point library MATH32X.H : 32 bit fixed point library MATH16F.H : 16 bit floating point library MATH24F.H : 24 bit floating point library M

13、ATH32F.H : 32 bit floating point library MATH24LB.H : 24 bit floating point functions(log,sqrt,cos,..) MATH32LB.H : 32 bit floating point functions(log,sqrt,cos,..) 12C508.H .. 16C924.H : PICmicro header files NEWS.TXT : Recent added features README.TXT EXAMPLE 因CC5X支援PIC12、PIC16等系列的單晶片,那我們所撰

14、寫的程式要如何指定特定的PICmicro Devices,它有三種方法可以去指定: 1. 在command-line上直接加上,其方法為-p[Device name],EX:-p16C73、-pPIC16F877。 2. 在主程式上加入pragma statement,EX:#pragma chip PIC16F84。 3. 使用include file,EX:在主程式加入#include "16c73.h"。 以下為使用CC5X的執行範例,其執行方式為: cc5x -a delay.c delay.c: Chip = 16C74 RAM: 00h : -----

15、 -------- -------- -------- RAM: 20h : ==.***** ******** ******** ******** RAM: 40h : ******** ******** ******** ******** RAM: 60h : ******** ******** ******** ******** RAM: 80h : -------- -------- -------- -------- RAM: A0h : ******** ******** ******** ******** RAM: C0h : ******** ********

16、 ******** ******** RAM: E0h : ******** ******** ******** ******** Optimizing - removed 11 instructions (-14 %) File 'delay.asm' Codepage 0 has 68 word(s) : 3 % Codepage 1 has 0 word(s) : 0 % File 'delay.hex' Total of 68 instructions (1 %) Symbols: * : free location - : predefined or pragma

17、 variable = : local variable(s) . : global variable 7 : 7 free bits in this location 上面的-a意思是產生.asm(組合語言)檔案,上面的範例產生三個檔案,delay.asm、delay.occ及delay.hex,其中delay.asm為使用C語言所轉譯出的組合語言檔;delay.occ為compiler後所產生的相關訊息,包括使用記憶體(RAM)狀況及使用多少程式記憶體(ROM)等;delay.hex為產生INHX8M格式,此檔案就可利用燒錄器直接燒到PIC裡面。 COMMAND LINE OPT

18、IONS 以下針對CC5X Command-line再做一詳細說明: The syntax is: CC5X [options] .c [options] -a[]: produce assembly file. The default file name is .asm -A[scHDpftmiJbeokgN+N+N] : assembly file options s: symbolic arguments are replaced by numbers c: no C source code is printed H: hexade

19、cimal numbers only D: decimal numbers only p: no '.' in front of decimal constants f: no object format directive is printed t: no tabulators, normal spaces only m: single source line only i: no source indentation, straight left margin J: put source after instructions to achieve a compact asse

20、mbly file. b: do not add rambank info to variables in the assembly file e: do not add ',1' to instructions when result is written back to the register o: do not replace OPTION with OPTION_REG k: do not convert all hexadecimal numbers (11h -> 0x11) g: do not use PROCESSOR instead of the list dir

21、ective N+N+N: label, mnemonic and argument spacing. Default is 8+6+10. -b: do not update bank selection bits 12 bit core: FSR.5 and 6 14 bit core: STATUS.RP0 and RP1 -bu: non-optimized updating of the bank selection bits -CC[] : produce COD file, C mode -CA[] : produce COD file, A

22、SM mode -dc: do not write compiler output file .occ -D[=xxx] : define macro. Equivalent to #define name xxx -e: single line error messages (no source lines are printed). -ed : do not print error details -ew : do not print warning details -eL : list error and warning details at the e

23、nd -E : stop after errors (default is 4). -f : i.e. INHX8M, INHX8S, INHX16, INHX32. Default is INHX8M. Note that INHX8S use output files: .HXH and .HXL -F: produce error file .err -g: do not replace call by goto -GW: dynamic selected skip() format, warn

24、ing on long format (default) CC5X C Compiler B Knudsen Data 49 -GD: dynamic selected skip() format -GS: always short skip() format (error if boundary is crossed) -GL: always long skip() format -I : include files directory. Up to 5 library directories can be supplied by using separat

25、e - I

options. When using #include "test.h" the current directory is first searched. If the file is not found there, then the library directories are searched, in the same order as supplied in the command line option list (-I). The current directory is skipped when using #include

26、h>. -j: do not update page selection bits 12 bit core: STATUS.PA0 and PA1 14 bit core: PCLATH.3 and 4 -L[,] : produce list file .lst The maximun number of columns per line and lines per page can be changed. The default setting is -L80,60 -mc1: default 'const' pointe

27、r size is 1 byte (8 bits) -mc2: default 'const' pointer size is 2 bytes (16 bits) -mr1: default RAM pointer size is 1 byte -mr2: default RAM pointer size is 2 bytes -mm1: default pointer size is 1 byte (all pointer types) -mm2: default pointer size is 2 bytes (all pointer types) -o : wri

28、te hex file to name -O : output files directory. Files generated by the compiler are put on this directory, except when a full path name is supplied. -p : defines the chip type. The device have to be known internally: 16C54,55,56,57,58, 61,64,65, 71,73,74, 84 or supported by a

29、 header file (i.e. 16F877.H). Default device is 16C54. -q : assume disabled interrupt at the deepest call levels. I.e. –q1 allows the main program to use all stack levels for function calls. If the interrupt routine makes function calls, then –q2 etc. can be used. Disabling interrupt at th

30、e deepest call level MUST be properly ensured in the user application program. -r : generate relocatable assembly (no hex file) -r2[] : use separate logical section for interrupt routine -rp : name on codepage 0 is PROG, default PROG1 -rb : name on RAM bank 0 is BANK, d

31、efault BANK0 -ro : add offset when generating local variable block name -Q: write the call tree to .fcs. -S: silent operation of the compiler -u : no optimizing -V[rnuD] : generate variable file, .var, sorted by address as default. r: only variables which are referenced in the

32、 code n: sort by name u: unsorted D: decimal numbers -we: no warning when fixed point constants are rounded -wB: warning when function is called from another code page CC5X C Compiler B Knudsen Data -wI: warning on long inline code for multiplication and division -wL: (12 bit core only) prin

33、t warning on all GOTO links to functions residing on hidden half of a codepage. -wO: warning on operator library calls -wP: warning when code page bits are not correct -wr: no warning on recursive calls -wS: warning (no error) when constant expression loses significant bits -wU: warning on unc

34、alled functions -cu: use 32 bit evaluation of constant expressions -x : assembler executable: -xC:\progra~1\mplab\mpasm.exe -X

35、rted by the file system, example: c:/compiler/lib/file.h Default compiler settings: ‧ hex file output on file .hex ‧ processor = 16C54 ‧ optimizing on ‧ extended call level is allowed ‧ update bank and page selection bits Permanent assigned settings: ‧ nested comments is allowed ‧ char is unsigned

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服