Microchip
直播中

宋艳艳

7年用户 201经验值
私信 关注
[问答]

设备是如何编程的?

如果我用C语言生成程序,然后点击程序来编程,实际上会发生什么,C程序是如何转换成可以自己执行的呢?是把C编译成ASM然后编译成十六进制然后到芯片吗?我曾尝试谷歌,但不知道该搜索什么。芯片是如何理解什么的。谢谢,

以上来自于百度翻译


      以下为原文

    If I produce program in C language and then I click to program the device, what actually happens, how does the C program convert into something that can later be executed on its own?
Is the C compiled into ASM then compiled into HEX then to the chip? I have tried to google but not sure what to search.
How does the chip understand whats what.
Thanks,

回帖(4)

李兆峰

2019-3-5 16:20:37
是的,基本上就是这样

以上来自于百度翻译


      以下为原文

   


Yep, basically that's the way it goes
举报

王焕树

2019-3-5 16:34:54
当然,这只会在安装C编译器之后发生。MPLABX不是一个。你没有提到你正在看的PIC家族,所以我不能说你需要哪一个编译器。

以上来自于百度翻译


      以下为原文

    Of course, this will only happen once you have installed a C compiler. MPLABX does not come with one.
You did not mention what family of PICs you are looking at, so I can't say which compiler you need.
 
举报

钱杨静

2019-3-5 16:40:26
你的理解是正确的。C编译器将你所写的代码编译成汇编代码,然后使用MPASM汇编成二进制(HEX),例如可以使用PICTIT3写入该设备。

以上来自于百度翻译


      以下为原文

    Your understanding is correct. The C compiler compiles what you wrote into assembly code which is then assembled using MPASM into binary (HEX) that can be written into the device using PICKIT3 for example. 
举报

李铭鑫

2019-3-5 16:47:43
是的,消息1中的理解是正确的,但是在路上有很多细节,这个过程可能略有不同,这取决于编译器和链接器的使用,使用什么编程工具链,以及目标机器是什么。R是最典型的,如果安装了XC8编译器,在/DOCS目录中与编译器安装并行,则有XC8C编译器用户指南,它描述了如何对具有高级整体程序优化的编译器进行操作。它存储在类似于:C//程序文件(x)的地方。86)/Microchip /XC8/V1.42/DOCS/MPLABAXXC8YCCOMPILRIOR USER指南。PDFL是困难的:如果编译和链接用于调试,“.HEX”文件并不是没有产生或使用的。“ELF”文件,实际上是由链接器产生的,都需要为MicroCONT编程所需的所有信息。Road,并且在调试过程中还需要调试符号信息,因此,如果程序由调试器执行,则可能不需要'.HEX '文件。否则,“.HEX”文件将由一个从“.ELF”文件中提取信息的程序在单独的步骤中创建,并写入I。NTO十六进制文本,在一个文件中,你可以在文本编辑器中打开并查看它。它被许多在生产编程中使用的闪存编程工具所使用,并且由可以输入序列号的实用程序使用,并且对于每一个生成和编程的程序都是不同的。在PIC设备中,有一个单独的文档:Flash编程规范,你可以找到它,并从每个PIC设备的产品网页下载它。在途中有几个中间文件。可以在IDE中设置复选框,或者给命令行添加一个。为了保持这些,其中一些可能是有用的,如果追逐一个困难的bug,但可能有很多东西,很难知道在哪里搜索。

以上来自于百度翻译


      以下为原文

    Yes,
the understanding in message #1 is correct as an overwiev. 
There is however a lot of details along the way,
and the process may be slightly different, depending upon what compiler and linker is used,
what programming toolchain is used, and what target machine is intended.
 
While not the simplest, nor the most typical,
if you have XC8 compiler installed, in /docs directory in parallel with the compiler installation,
there is XC8 C Compiler user's guide, with descriptions of how it is done for a compiler that have advanced whole program optimization.
 
It is stored somewhere like:
C:/Program Files (x86)/Microchip/xc8/v1.42/docs/MPLAB_XC8_C_Compiler_User_Guide.pdf
 
Just to be difficult:
If compiling and linking for debugging, a '.hex' file is not nessesarily produced nor used. 
The '.elf' file, which is what may actually be produced by the linker, have all information needed to program the microcontroller, and also have debugging symbol information that will be needed during debugging anyway, 
so if programming is performed by the debugger, a '.hex' file may not be needed.
 
Otherwise, the '.hex' file is created in a separate step by a program that extract information from '.elf' file, and write into hexadecimal  text, in a file that you may open and look at in a text editor. 
It is used by many flash programming tools used in production programming, and by utility programs that may put in serial numbers and such that shall be different for each item produced and programmed.
 
Then for every family of PIC devices, there is a separate document: Flash Programming Specification,
you can find it and download it from the product webpage for each PIC device.
 
There are several intermediate files produced along the way.
It is possible to set a checkbox in the IDE, or give an addition to command line, to keep these.
Some of these may be useful if chasing a difficult bug, but there may be a lot of stuff, and be difficult to know where to search.
 
Regards,
   Mysil
 
 
 
 
 
 
 
举报

更多回帖

发帖
×
20
完善资料,
赚取积分