CodeWarrior 10.2简明手册(V1.1)

合集下载

Freescale CodeWarrior 10.6 集成开发环境(IDE)使用手册

Freescale CodeWarrior 10.6 集成开发环境(IDE)使用手册

单击此处“…”则会 弹出下页ppt所示的 周期设置窗口
CodeWarrior 10.6 IDE使用手册
14
设置定时器中断周期为10ms
在此输入期望的中断周期10ms 这里列出了当前选择的定时器能 够实现的定时周期及精度 设此处限定定时误差,若设置的中断周 期超出此误差,则处理器专家会报错
CodeWarrior 10.6 IDE使用手册
CodeWarrior 10.6 IDE使用手册
3
利用工程向导快速创建KEA工程
e.选择编程语言和浮点数支持以及控制 台(console)硬件支持: f.选择是否使用处理器专家系统以及工 程外设driver的使用模式:
CodeWarrior 10.6 IDE使用手册
4
利用工程向导快速创建KEA工程
其中包含了默认看门狗、SWD调试口以及Flash Memory 的设置
在CPU组件的属性设置中还包括CPU 内核中断/复位设置(CPU interrupt/reset)
其中包含了CPU内核系统级中断(ARM Cortex M0+实现的 异常):不可屏蔽中断NMI、硬件错误异常Hard fault(当 CPU执行非法指令、非对其地址访问时触发该异常,可以 用于捕获程序跑飞时的场景)、超级调用Supervisor Call和 可请求服务异常(用于RTOS系统任务切换),以及内部时 钟失锁(ICS Loss of lock)。所有这些中断的优先级都高于 外设中断。
CodeWarrior 10.6 IDE使用手册
18
添加和配置定时器中断组件
最后在中断回调函数中添加中断处理,这里为全局中断计数器加1; 注意:用户的中断处理代码必须加在处理器专家指定的位置
CodeWarrior 10.6 IDE使用手册

CODEV10.2说明书1

CODEV10.2说明书1

ALI-Alignment OptimizationALI computes the necessary changes in compensators needed to minimize the differences between nominal design wavefronts and wavefronts measured by an interferometer on the system as-built; these adjustments would then be made in the hardware to restore as much of the design performance as possible. The calculation predicts the potential improvement that making such adjustments will generate, pre- and post-alignment. ALI can also convert a null test interferogram into a surface deformation interferogram.When to Use the Alignment Optimization (ALI) OptionThe ALI option can be used for three purposes:•To predict the small changes in specified parameters (compensators designated in the LDM) needed to do final alignment of an assembled optical system•To predict the potential improvement that making such adjustments will generate, pre- and post-alignment•To convert a null test interferogram into an interferogram measured along the surface normal.The first two are part of the output of the option. The conversion of a null test interferogram to a surface normal interferogram is included here because the computation in ALI is the one needed: defining a system wavefront and relating surface errors to system wavefront errors.The use of ALI should be associated with lens systems that require adjustments after initial assembly. Most rotationally symmetric refractive lens systems are designed to be fabricated and assembled with enough precision that no internal adjustments after assembly are needed; only focus and possibly tilt of the image surface are typically used to enhance performance; an effective tolerance analysis can establish the feasibility of such an approach. Additional steps such as fitting to test plates, melt glass data, or even respacing for measured thicknesses can be applied to give wider latitude to the remaining tolerances or achieve a higher level of quality. These systems do not require the use of the ALI option.In non-rotationally symmetric systems (and even in selected centered systems) it is often too much to expect that all parts can be made and assembled without planning to have final adjustments. For example, multi-mirror unobscured systems depend on adjustable parameters (element tilts and/or displacements) for final tuning of the system to produce the design performance; in fact, they often are designed with 6degree-of-freedom mirror mounts and toleranced with adjustment as an essential step. Alignment would be an impossible task without developing the simultaneous solution for adjustments that the ALI option provides.An assembled system may show residual aberrations not present in the design. Note that - without knowing the magnitude or even the source of specific errors within the lens, but just having the system interferograms at several field angles - computational experiments can be run with this option, trying different potential adjustment scenarios until one is found that restores enough of the design performance. The best scenario can then be applied to do final alignment of the lens assembly.Even some rotationally symmetric systems (e.g., microscope objectives, Cassegrain reflecting systems, etc.) may be designed to have an adjustment (e.g., a mirror tilt, lens element decenter, and/or an airspace) aimed at taking out some residual aberration such as axial coma or spherical aberration; the ALI option makes this a single step process giving both the correct magnitude and direction, instead of a trial-and-error process on the hardware itself. For modest field systems, this often can be done with a single axial system interferogram. In all of the applications suited for treatment by the ALI option, the system must have residual wavefronterrors that can be measured interferometrically.ALI - Alignment OptimizationPreparation for Running the Alignment OptionLike the TOR option, the ALI option calculates wavefront differentials which are linear with respect to the parameter changes. Thus, it can only predict small changes in the user-specified alignment parameters. One common alignment problem is that of rotating two mirrors with respect to each other to minimize the effects of surface errors, e.g., astigmatism. This must be done by assigning the interferogram data to the appropriate surfaces and analyzing the system with any of the image quality options (e.g., WAV). By going through a series of rotation angles (e.g., 0, 30, 60, 90), a minimum may be found.Preparation for Running the Alignment Option For alignment purposes, the lens data should be the best achievable design - the design fitted to glass melt data, test plates and measured thicknesses. Only include enough of these steps, forming the “baseline” design, to represent the design performance as you want it to be post-alignment. Details such as interferometric surface errors are immaterial since the predicted adjustment magnitudes and directions will be unaffected by them; they will only affect the pre- and post-alignment predicted performance.As part of the lens data, include the compensators (CMP) you wish to have used as alignment parameters. These are entered in the LDM (see section on Tolerances). Be sure to include compensators that can be effective in correcting the system (focus shift, image plane tilt or independent focus at each field (INC command), element/subsystem spacings and tilts, etc.). Note that this is a crucial step in the process - selection of the right element decenter in a high numerical aperture microscope objective may make an otherwise unfeasible performance level achievable.There is no limit on the number of compensators allowed, however the best solutions are obtained with the fewest compensators which will accomplish the alignment. The parameters are typically motions of optical elements, such as tilt and decenter of the secondary in a Cassegrain, but also would normally include axial displacement and tilt of the image surface.The focusing mode is determined by compensator entries such as DLZ SI (defocus) and TIL SI (2components of tilt). If none of these compensators is entered, there is no adjustment of the focal surface. With INC (independent compensation), DLZ SI must also be entered if it is to work correctly, but each field will be focused independently and any focal surface tilt compensators will have no effect.A special feature of the ALIgnment option is the ability to calculate the surface deformations of a surface being tested in a null configuration. In some null tests, the surface is not measured at center of curvature, e.g., a parabola in autocollimation. The resulting interferogram, therefore, does not correctly represent surface errors as measured normal to the surface. This feature predicts the correct surface deformations as a Zernike polynomial. To use it, set up the null test configuration as the lens data in the LDM. Run the ALI option, designating the one surface associated with the null test wavefront; write out the .INT file in polynomial form. Repeat for each null tested surface in the system. Then restore the full system and attach the new files to the corresponding surfaces. Proceed with any desired CODE V operations (optimization, evaluation, alignment, etc.).Default OperationNone; no calculation is possible without at least one measured wavefront supplied (INT command). With one such wavefront (measured at the exit pupil for the assembled system in the reference wavelength) entered for each field point and zoom position, values of the small alignment changes are generated. (Alignmentparameters are selected in the LDM as compensators, such as tilts, decenters, axial spacings, and focal plane shift and tilt). The computed changes are those needed to restore as much performance as possible; they are listed along with the RMS error existing before and after alignment. The RMS error is for the difference between the measured and nominal system wavefronts; thus the goal is restoration of design performance, notenhancement relative to a perfect lens. ALI uses Gaussian apodization if present in the lens data.ALI - Alignment OptimizationCommand MnemonicsCommand Mnemonics (alphabetical)Data Input Overview The ALI option assumes that:•The lens data (entered or restored in the LDM) is a system that represents the desired wavefront performance, and that the desired alignment parameters have been designated as compensators in theLDM. Zoom positions can be used to represent a zoom lens or to extend the number of fields at which measurements have been made beyond the limit of 25 for a non-zoom lens.•Exit pupil interferograms have been measured at one or more field points for the hardware assembled as represented in the lens data, and converted to files according to the CODE V standard described in theLDM (several interferometer manufacturers supply this form of output).•These files are attached to their appropriate field points (INT) and scaled in deformation if needed (ISF).The interferograms they represent are matched to the exit pupil in size (INR) and position (FID or IMI, IRO, INX, INY).•All exit pupil interferograms have been measured with respect to images lying on the desired focal surface, or else adjusted so (FOC).•Appropriate values or defaults are present for ray grid density (NRD) and the desired weighting of the various field points (WTF). The default field weights are the LDM field weights.The option then proceeds with its computation. All calculations are done in the reference wavelength only. If it is a null test conversion see “Null Test Computations” on page 21-18 for details. Also see “Discussion of Input and Computations” on page 21-16 for a thorough explanation.FID FOC IMI INR INT INX INY IRO ISF NRD NUL WIN WTF ZFRZRNALI - Alignment OptimizationDefining the InterferogramDefining the Interferogram To define the interferogram, select the Analysis >Fabrication Support > Alignment Optimization menu. The Alignment Optimization dialog box is displayed, with the Interferogram tab in the mand Syntax Screen ControlExplanation Default INT Fk [ Zn ] int_filenameFile Assign system (exit pupil) interferogram data in the file int_filename.INT to field k, zoom n. When more than twenty-five fields are needed, the system may be zoomedto allow other fields (up to 35) to be defined in the added position(s); this is the most frequent use of Zn, althoughzoom systems can also be aligned.None; at least one interferogram isREQUIRED.ISF Fk scale_factor....zScale Scale the measured wave deformation for field k anddesignated zoom position by the specified scale factor -provides a convenient scale factor separate from the one specified in the interferogram file. Example : use 0.5 for scaling of wavefront data measured in a double-pass test.1.0.ALI - Alignment Optimization Defining the Interferogram INR Fk radius....z Radius Radius of data on the exit pupil at field k and designatedzoom position, in units of the lens. This connects the unit length of the file data to a physical length on the exit pupil. The unit length of file data is defined:Zernike polynomials–In a circle of unit radius Grid –In a square of unitsemi-dimension The entered value of physical length is the radius on the exit pupil, measured in a direction normal to the chief ray.Note : If the given value of radius scaled theinterferogram smaller than needed to cover the exit pupil, the data outside the unit semi-dimension will eitherbe missing (grid) or extrapolated (polynomial) leading to false results; this must be avoided.Semi-diameter of the exit pupil.IMI Fk XC | YC | No....zMirror Mirror image in X or Y at field k and designated zoom position:XC –Move deformation data to theopposite X-coordinateYC –Move deformation data to theopposite Y-coordinateN or No – No mirror image is doneOnly one of IMI XC or IMI YC can be done at a given field position; to do both is equivalent to an IRO of 180°.No.INX Fk x_dec....zX Decenter The X coordinate for the interferogram center in the plane containing the exit pupil point and normal to the chief ray, at field k and designated zoom position.Chief rayintersection.INY Fk y_dec....zY Decenter The Y coordinate for the interferogram center in the plane containing the exit pupil point and normal to the chief ray, at field k and designated zoom position.Chief rayintersection.IRO Fk ang_rot_degr....zRotation Angle of rotation, in degrees, of the deformation data in the interferogram at field k and designated zoom position. Rotation is about the center of the interferogram. Rotation of the positive X axis toward the positive Y axis(counterclockwise) is a positive rotation. If IMI was entered, the IRO action is done after IMI.0.0Command Syntax Screen Control Explanation DefaultALI - Alignment OptimizationFitting the Interferograms to the Exit PupilFitting the Interferograms to the Exit PupilOrienting Interferogram DataFive commands are available for orienting interferogram data on the exit pupil in this option:FID Fk [ Zn ] x_R2 y_R2 x_R3 y_R3 [ x_R4 y_R4 [ x_R5 y_R5 ] ]Fiducials for interferogram data alignment w.r.t. reference ray Fiducials for aligning the interferogram data at field k, zoom n with the CODE V reference rays. Values are points relative to the unit circle (of the interferogram) where the CODE V reference rays (R2, R3, R4 and R5) pass through the interferogram (assuming it is positionedin the real exit pupil, normal to the chief ray). The action is dependent on the number of rays referenced in the X_Rn, Y_Rn values:R2, R3MINIMUM DATA. Generatesvalues for rotation (IRO), scaling(INR), and decenter in X and Y(INX, INY) to match exactly the4 values.R2, R3, R4, orR2, R3, R4, R5Generates values for mirrorimage (IMI,XC),rotation (IRO),scaling (INR), image (IMI, XC),and decenter in X and Y (INX,INY) that minimizes in the least squares sense the departures fromthe 6 (or 8) values.None. Uses IMI, IRO, INR, INX, mand Description LocationIMI Reverse interferogram data “left-for-right” or “up-for-down” (i.e., a mirror image in X or Y, respectively)Interferogram tab (See “Defining the Interferogram” on page 21-8.)IRO Rotate the interferogram about its center Interferogram tab (See “Defining the Interferogram” on page 21-8.)INR Scale the interferogram unit dimension to the specified value Interferogram tab (See “Defining the Interferogram” on page 21-8.)INX, INY Shift center point of interferogram to a designated X, Y point in the exit pupil Interferogram tab (See “Defining the Interferogram” on page 21-8.)Command Syntax Screen Control Explanation DefaultALI - Alignment OptimizationFitting the Interferograms to the Exit PupilIMI and IRO apply to interferogram coordinates only. The interferogram coordinate system is:IMI XC means that data that was on the +X side is now on the -X side and vice versa. IMI YC has a similar meaning in the Y direction. Notice that it is the deformation data that moves; the axes do not move. IRO rotates the data by the specified angle, where counterclockwise is the positive direction (rotating the positive X axis toward the positive Y axis). If both IMI and IRO are entered, the IMI is done first.INX, INY and INR apply to the exit pupil only. INX and INY specify where the center of the interferogram is placed. These are given in units of the lens system. INR is the radius of the data, also in lens units. It equates the unit radius of the interferogram data to a physical distance.Mirror Image, Rotation, and Translation OrderThe transformations IMI, IRO, INX and INY are performed in the order of: mirror image, rotation,translation.Defaults apply:•The interferogram is centered on the intersection of the chief ray with the exit pupil. Overridden by FID, INX and/or INY.•No mirror image. Overridden by FID and/or IMI.•No rotation. Overridden by FID and/or IRO.•The radius of the data is the semi-diameter of the exit pupil. Overridden by FID and/or INR.Interferograms which are entered in ALI, are associated with the exit pupil. The coordinates of the exit pupil are always measured perpendicular to the chief ray. This is because an interferogram represents the image of the exit pupil of the system and the axis of the interferometric setup is approximately along the chief ray. The coordinates of the interferogram are mapped onto the plane which is tangent to the reference sphere at the position where the chief ray intersects the reference sphere.An alternate method of orienting the interferogram to the exit pupil is by matching fiducial points on the interferogram to the intersection of the CODE V reference rays with the tilted exit pupil. The CODE V reference rays are used to define the bundles of light. These rays are:Ray Label DescriptionR1Chief rayR2Upper (+) Y rayR3Lower (-) Y rayR4“Upper” (+) X rayR5“Lower” (-) X rayALI - Alignment OptimizationNull Test Analysis: Converting Non-normal Null Test Interferograms to Normal InterferogramsThe FID input defines between two and four points on the interferogram which are associated with the reference rays, R2, R3, R4 and R5. If only two points (R2, R3) are used, an exact fit can be obtained; for more than two points, a least squares fit is done between the fiducial points and the intersection of the CODE V reference rays with the tilted exit pupil. The solution gives the values of IMI, IRO, INR, INX and INY.If a set of fiducial points (FID) is entered, it will be used for the referencing. Otherwise, the specific coordinate transformations (IMI, IRO, INR, INX, INY) or their defaults will be used. Null Test Analysis: Converting Non-normal Null Test Interferograms to Normal Interferograms In some null tests, the lens surface is not measured at its center of curvature; for example, a parabola could be tested at its focus with a flat mirror. The resulting interferogram, therefore, does not directly represent surface errors as measured normal to the surface. Since surface errors, as specified in .INT files, are assumed to be measured along the surface normal, a way is needed to convert the results of a non-normal null test to surface deformations along the surface normal. This is done, on one interferogram at a time, as follows:•Set up the single field null test configuration as your lens, in the LDM, then enter this option (ALI) •Use INT to place the null test interferogram in the exit pupil•Use ISF, FID or IMI, IRO, INR, INX, INY as necessary•Use NUL to bypass regular alignment operations and to convert the exit pupil interferogram into a surface interferogram for the designated surface•Use ZRN or ZFR to designate form of Zernike polynomial to be generated•Use NRD if necessary to provide enough grid points for the single field fit to polynomials of the designated order•Use WIN (writes the information on a file in a format compatible with the INT command in the LDM) •Do the same for any other surfaces measured by null test interferogramsSet up your actual optical system in the LDM, attaching these new surface interferograms to the assigned surfaces plus any other surface interferograms. Proceed with any desired CODE V operations (optimization,evaluation, etc.).ALI - Alignment Optimization Defining a Null Test Analysis Defining a Null Test Analysis To define a null test analysis, select the Analysis >Fabrication Support > Alignment Optimization menu. The Alignment Optimization dialog box is displayed. Select the Null Test tab to bring it to the foreground. Command SyntaxScreen Control Explanation DefaultNUL Sk [ radius ]Surface number for null test /Radius of surface (lensunits)Bypass the normal alignment calculation and convert the one exit pupil interferogram from a null test into a surface interferogram for surface Sk. The lens must bethe optical system representing the null test; one, and only one, exit pupil interferogram (INT) must beentered. The ray traced wavefront is compared to themeasured exit pupil interferogram; any differences are assumed to be due to errors on the specified surface. A Zernike polynomial fit is done to the surfacedeformations, specified by the ZRN or ZRF command;if neither is given, ZRN 36 is used. The unit circle for the polynomial corresponds to the radius entered on theNUL command. If a radius is not entered, the clear aperture of surface Sk is used.Do the normal alignment process.ALI - Alignment OptimizationDefining a Null Test AnalysisZRN num_terms Select Interferogram Format: StandardZernike Use with NUL. Fit the residual system wavefront, from the null test configuration, to a standard Zernike polynomial to be used as a surface deformation. The fit is done with respect to normalized exit pupilcoordinates, but centered on and measured in a direction normal to the chief ray. Either ZFR or ZRN may be entered but not both. 36, if NUL is used.ZFR num_termsSelect Interferogram Format: Fringe Zernike /Number of terms Use with NUL. Fit the residual system wavefront, from the null test configuration, to a FRINGE Zernike polynomial to be used as a surface deformation. The fit is done with respect to normalized exit pupilcoordinates, but centered on and measured in a direction normal to the chief ray. Either ZFR or ZRN may be entered but not both.None. Use ZRN.WIN int_filenameEnter interferogram file name for saving Zernike coefficients Use with NUL. For the residual system wavefront, from the null test configuration, write Zernike coefficients on an interferogram file namedint_filename.INT, for use as a surface deformation.No file mand Syntax Screen Control Explanation DefaultDefining Computation ControlsDefining Computation ControlsTo define computation controls, select the Analysis >Fabrication Support > Alignment Optimization menu. The Alignment Optimization dialog box is displayed. Select the Computation tab to bring it to the foreground.Command SyntaxScreen ControlExplanationDefaultNRDnum_rays_across_diameter Number of rays across diameterNumber of rays traced across the pupil diameter at each wavelength. Recommendation: There should be enough rays to give a reasonable representation of theaberrations for the RMS calculation. The default is sufficient in most cases. For significant vignetting and/or central obscuration, increase NRD. For the NUL analysis, the smoothness of fit to Zernikepolynomials is dependent on having significantly more (at least twice as much) information than the number of terms in the polynomial. Increase NRD if number of terms is high, especially with significant vignetting and/or central obscuration.16.Discussion of Input and ComputationsDiscussion of Input and ComputationsWhat to Include in the LDM Lens DataFor alignment purposes, the lens data should be the best achievable design – the design fitted to glass melt data, test plates and measured thicknesses. Only include enough of these steps, forming the “baseline” design, to represent the design performance as you want it to be post-alignment. On the other hand, don't expect the option to overcome the effects of severe, unadjustable errors; the process only aims to minimize the difference between the baseline design and the post-alignment system; if the baseline design is too far away from what is achievable with the adjustment parameters given, the balance may not be optimum. Details such asinterferometric surface errors are immaterial since the predicted adjustment magnitudes and directions will be unaffected by them; they will only affect the pre- and post-alignment predicted performance.As part of the lens data, include the compensators (CMP) you wish to have used as alignment parameters. Values entered with the compensators (or their defaults) act as limits to the allowed changes. Be sure to include compensators that can be effective in correcting the system (focus shift, image plane tilt orindependent focus at each field (INC command), element/subsystem spacings and tilts, etc.). Note that this is a crucial step in the process - selection of the right element decenter in a high numerical aperture microscope objective may make an otherwise unfeasible performance level achievable.Specific tolerancing controls allow ALI to select the most effective set of compensators for your system. The Singular Value Decomposition (SVD) Threshold and Used Compensators controls in the System Data window (SVT and MCP commands, respectively) regulate the compensators used to align the system. See “Defining Tolerance Controls” on page 3-60 for details about these commands. In addition, you can specify which compensators must be used, and which can be dropped from the system. This is done using the Compensator Use Control field in the Surface Properties window, on the Tolerances page. From the command line, use the CMP command. For details, see the CMP command description under “Other Tolerance Controls” on page 8-23.WTF field-zoom_weight....f, zField Weights forBalancing Alignment SolutionField weights to balance for solution of alignment parameters. If field_zoom_weight value is 0, computations for that field will be skipped.Lens system weightsfrom WTF in the LDM.FOC focal_shift....f, z Wavefront Focal ShiftFocal shift added to the lens at the specified field/zoom position. Use to compensate for focal shifts known to be present in the measured system interferograms, and to bring them, as needed, into acommon reference with respect to the focal surface as defined in the lens data. Note : Needed so that the focus compensation arrangement defined in the LDM is applied correctly; otherwise, focus compensator values will apply to the unrelated (and possibly unknown) foci represented in the system interferograms.0.0Command SyntaxScreen ControlExplanationDefaultDiscussion of Input and ComputationsUsageThe ALI option predicts small changes in specified alignment parameters based on measured wavefront data at one or more fields:•It uses the baseline design as the performance standard, and compensators (CMP) to designate the alignment parameters, entered in the LDM•It uses measured system wavefront data entered in the option itself•Predicted changes in the alignment parameters are used for adjusting the hardware.Figure 2.Schematic of the ALI optionMore specifically, the ALI option assumes that:•The lens system (entered in the LDM or restored) has been optimized to represent the quality standard to be used, and that the desired alignment parameters have been designated as compensators in the LDM. Zoom positions can be used to represent a zoom lens or to extend the number of fields at whichmeasurements have been made beyond the limit of 25 for a non-zoom lens.•Exit pupil interferograms have been measured at one or more field points for the hardware assembled as represented in the lens data, and converted to files according to the CODE V standard described in theLDM (several interferometer manufacturers supply this form of output).•These files are attached to their appropriate field points (INT) and scaled in deformation if needed (ISF ). The interferograms they represent are matched to the exit pupil in size (INR ) and position (FID or IMI , IRO , INX , INY ).•All exit pupil interferograms have been measured with respect to images lying on the desired focal surface, or else adjusted so (FOC ).•Appropriate values or defaults are present for ray grid density (NRD ) and the desired weighting of the various field points (WTF ). The default field weights are the LDM field weights.。

FreescaleCodeWarrior10.6集成开发环境(IDE)使用用户手册

FreescaleCodeWarrior10.6集成开发环境(IDE)使用用户手册

e.选择编程语言和浮点数支持以及控制 台(console)硬件支持:
f.选择是否使用处理器专家系统以及工 程外设driver的使用模式:
CodeWarrior 10.6 IDE使用手册
4
利用工程向导快速创建KEA工程
处理器专家系统工程介绍 工程及文件窗口
处理器专家为
每一个组件 (compontent) 生一个对应 的.h和.c文件, 包含该组件图
Freescale CodeWarrior 10.6 集成 开发环境(IDE)使用手册
本手册详细介绍了利用Freescale CodeWarrior 10.6 IDE 处 理器专家系统(Processor Expert)快速建立KEA工程和调试的 步骤,以及该IDE常用的编程及调试技巧,旨在帮助用户快速 熟悉和掌握CodeWarrior 10.6的使用,利用处理器专家系统快 速搭建应用工程进行产品原型验证。
CodeWarrior 10.6 IDE使用手册
2
利用工程向导快速创建KEA工程
c. 选择器件,这里KEA属于Kinetis E系列, d. 选择调试工具,这里必须选择TRK-KEA128板
故选择如下:
载的OpenSDA作为本工程的调试工具:
CodeWarrior 10.6 IDE使用手册
3
利用工程向导快速创建KEA工程
6
CPU组件介绍及配置
在CPU组件的属性设置中还包括常
规设置(common settings)
其中包含了默认看门狗、SWD调试口以及Flash Memory 的设置
在CPU组件的属性设置中还包括CPU
内核中断/复位设置(CPU
interrupt/reset)
其中包含了CPU内核系统级中断(ARM Cortex M0+实现的 异常):不可屏蔽中断NMI、硬件错误异常Hard fault(当 CPU执行非法指令、非对其地址访问时触发该异常,可以 用于捕获程序跑飞时的场景)、超级调用Supervisor Call和 可请求服务异常(用于RTOS系统任务切换),以及内部时 钟失锁(ICS Loss of lock)。所有这些中断的优先级都高于 外设中断。

C语言重点语法及CodeWarrior使用介绍

C语言重点语法及CodeWarrior使用介绍
硬件调试。实际就是我们经常说的 BDM 调试。BDM 调试是基于芯片本身内含
的在线调试功能,可实现程序下载,单步/全速运行,可以设若干个断点,可 以观察和修改任意寄存器或 RAM 内存空间。BDM 几乎是开发飞思卡尔 8 位 (9S08 和 RS08 系列)、16 位(9S12 系列)和 32 位(Coldfire V1 系列)单片
快速实现芯片初始化代码的自动生成工 作,而且 PE 还提供了大量的软件库可供 用户开发时嵌入或调用。因为 8 位单片机
结构和功能相对简单,实现的控制项目复
杂度也不是很高,故一般情况下 8 位机开 发我们都不需要 PE 的介入,自己直接编
图 1-6
写程序代码即可。关于 PE 的详细介绍将
耗费大量的文字,这里按下不提。所以在 图 1-6 的对话框中选择“None”,并直接 按“Next”进入下一步。
如果你以前编写了很多代码文件现在想重 复利用,那么可以通过图 1-5 对话框左面
的文件树选择对应的文件,按中间的
“ Add ” 逐 个 添 加 到 右 侧 的 “ Project Files ” 列 表 中 。 若 加 错 了 就 用 “Remove”把列表中的文件移除。注意 此列表下方的两个选项:“Copy files to project”选择是否将所选的文件拷贝到现
这是项目建立模板的最后一步。在这一步
你可以决定有关 C/C++的一些编译和代码 生成模式,见图 1-7。 启动代码选择。所有 C 编译器会自动
生成一些启动代码。单片机复位后的
指令运行将首先执行这些启动代码, 然后再进入到你自己的程序模块 main
函数。这些启动代码主要完成堆栈指
针初始化、全局和静态变量自动清零

CodeWarriorV.软件使用指南

CodeWarriorV.软件使用指南

CodeWarriorV.软件使⽤指南Code Warrior 软件使⽤指南⼀、软件安装指南⼆、关于BDM驱动三、创建⼀个新的⼯程四、编写与运⾏你的程序2011年10⽉16⽇陈万忠Code Warrior 软件使⽤指南⼀、软件安装指南1. 打开⽂件安装⽂件夹2. 找到安装⽂件3. 双击此⽂件,出现安装界⾯:4. 点击“NEXT”按钮,出现安装路径信息。

如果修改系统默认路径,点击“change”按钮,然后修改安装路径,否则点击“NEXT”按钮。

5. 在安装过程中,根据提⽰信息,完成每⼀步的安装。

6. 安装完毕后,在所有程序中找到Code Warrior 执⾏⽂件,点击执⾏即可进⼊Code Warrior 集成环境。

7. 也可以拖到桌⾯上。

此时桌⾯出现如下图标:⼆、关于BDM驱动请将“BDM使⽤说明和驱动”⽂件夹下的⽂件:和以及三个⽂件,复制到:C:\Program Files\Freescale\\Prog\gdi⽬录下(或者你安装时修改过的Code Warrior 所在⽬录\Prog\gdi⼦⽬录下),在调试时选择Open Source BDM 调试接⼝即可。

三、创建⼀个新的⼯程创建⼀个新的⼯程,要按照下⾯向导选项的8个步骤来选择完成。

双击桌⾯快捷图标,进⼊ Code Warrior集成开发环境窗⼝。

第⼀步:创建⼀个新的⼯程。

第⼆步:选择CPU类型,选择HCS12X⽬录下的HCS12X Family。

第三步:选择CPU芯⽚型号和BDM⼯具TBDML。

第四步:选择编程语⾔,我们选择C语⾔编程。

第五步:添加⽂件到⼯程,⼀般直接按“下⼀步”。

第六步:快速开发应⽤程序选择,选None。

第七步:选择中的⽤户⾃定义模式。

第⼋步:选择不使⽤PC-Lint(TM)链接⼯具软件,点击“完成”按钮,Code Warrior集成开发环境就会⾃动⽣成整个⼯程的⽂件系统。

四、编写与运⾏你的程序在Code Warrior集成开发环境中,利⽤其⾃动⽣成的函数模板,就可以编写和调试你的应⽤程序了。

codewarrior使用指南

codewarrior使用指南
CodeWarrior 快速入门
1、安装 CodeWarrior 软件 安装 CodeWarrior 所需要的电脑的硬件资源如下,目前一般的电脑都可以满足这个要求。
16 位单片机的编程环境:CodeWarrior V4.6,V4.7,V5.0,V5.1 CodeWarrior V5.1 的下载链接: /lgfiles/devsuites/HC12/CW_HC12_v5.1_SPECIAL.exe 软件安装很简单,和其它软件的安装过程是一样的,按照默认的设置直接点击“下一步” 即可完成安装。 2、创建新工程(单片机以以 MC9S12XS128 为例,调试工具以 BDM 为例) 1) 点 击电 脑 左下 角 的 开始 菜 单, 开 始 >所 有 程 序>Freescale CodeWarrior> CodeWarrior development studio for S12(X) V5.0> CodeWarriorIDE。IDE 开始运行,出现下图 1 所示的窗口。
图11
图12 接下来给核心板供电,核心板的供电电压是 5V。有的 BDM 有 5V 供电模式,这个时候 直接用 BDM 供电就可以。 2)在新建的工程中键入如下代码 #include <hidef.h> #include "derivative.h" #define LEDCPU PORTK_PK4 #define LEDCPU_dir DDRK_DDRK4 void delay(void) { unsigned int i; for(i=0;i<50000;i++); } void main(void) { LEDCPU_dir=1; EnableInterrupts;
图8

Codewarrior使用指南

Codewarrior使用指南

Codewarrior使用指南Codewarrior 使用指南飞思卡尔 HC08/HCS12 系列微控制器开发环境 - Codewarrior 使用指南(草稿)tyf01@/doc/ab18307025.html, 2005 年 10 月仅供学习参考,请勿用于商业目的1Codewarrior 使用指南第一章 Codewarrior IDE 概述在软件开发过程中,通常需要经过以下几个步骤:? 新建:创建新项目,源文件? 编辑:按照一定的规则编辑源代码,注释? 编译:将源代码编译成机器码,同时还会检查语法错误和进行编译优化? 链接:将编译后的独立的模块链接成一个二进制可执行文件? 调试:对软件进行测试并发现错误在软件开发中,每个过程都会用到不同的工具。

如果每个工具都单独存在,这样就会给开发人员带来很多不便。

所以很多公司为开发人员提供了集成开发环境。

开发人员可以在同一个工具或平台上完成以上全部的工作。

Codewarrior 是 Metrowerks 公司开发的软件集成开发环境(以后简称IDE)。

飞思卡尔所有系列的微控制器都可以在 codewarrior IDE 下进行软件开发。

Codewarrior IDE 特点Codewarrior IDE 为软件开发提供了一系列的工具,其中包括:项目管理器:为软件开发人员管理上层的文件;将项目进行分组管理,比如文件或目标系统;跟踪状态信息,比如修改日期;决定编译顺序或每次编译应包括哪些文件;与插件一起提供版本控制功能编辑器:利用颜色来区分不同的关键字;允许用户利用颜色机制自定义关键字;自动检查括号范围;利用菜单在不同的文件或函数中导航搜索器:搜索一个特定的字符串;用特定的字符串代替查找到的字符串;允许使用常规表达式;提供文件比较功能;源代码浏览器:标志符(变量名称,函数名称)数据库;利用数据库来对代码快速定位;对所有的标志符连接到用到它的代码中;编译系统:编译器将源代码编译成机器码;链接器将目标文件链接成可执行文件调试器:利用标志符数据库进行源代码级调试;支持各种标志符数据库,比如:codeview, DWARF, SYM 等Codewarrior IDE 优点交叉平台开发2Codewarrior 使用指南开发人员可以在不同的操作系统下使用codewarrior IDE 来开发自己的软件。

CodeWarrior使用教程

CodeWarrior使用教程

CodeWarrior 使 用 教 程一、认识 CodeWarriorCodeWarrior 能做些什么?当你知道自己能写更好的程序时,你一定不会再使用别人开发的应用程序。

但是常常会发生这种情况,就是当你写了无数行代码后,却找不到使得整个程序出错的那一行代码,导致根本没法编译和链接整个程序。

这可能更令人灰心丧气。

本文将告诉你如何使用 CodeWarrior 这一工具解决上述问题。

从现在开始,我们将集中精力学习如何在 CodeWarrior 中使用 C/C++ 进行编程。

为了学习本课程,你必须已经能够比较熟练地使用上述两种语言之一。

CodeWarrior 也可以支持 Java 开发,但那是另一门课程的内容。

本课程仅限于在 Windows 平台上使用 CodeWarrior 进行的开发。

一旦你精通了 CodeWarrior 编程后,你可以试试在其它平台上使用 CodeWarrior。

本文中讨论过的大部分内容都可以应用到开发 Mac 应用程序中。

CodeWarrior 能够自动地检查代码中的明显错误,它通过一个集成的调试器和编辑器来扫描你的代码,以找到并减少明显的错误,然后编译并链接程序以便计算机能够理解并执行你的程序。

你所使用过的每个应用程序都经过了使用象 CodeWorrior 这样的开发工具进行编码、编译、编辑、链接和调试的过程。

现在你在我们的指导下,自己也可以去做这些工作了。

你可以使用 CodeWarrior 来编写你能够想象得到的任何一种类型的程序。

如果你是一个初学者,你可以选择编写一个应用程序(比如一个可执行程序),比如象微软公司的文本编辑器 WordPad 这样的应用程序。

应用程序可能是最容易编写的程序了,而那些庞大的商业软件,比如象 Adobe Photoshop,Microsoft Word 以及 CodeWarrior 软件都是极其复杂的。

其它类型的程序指的是控制面板(control panels),动态链接库(dynamic linked libraries,DLLs) 和插件(plug-ins)。

CodeWarrior介绍(自己整理)

CodeWarrior介绍(自己整理)

写给CodeWarrior初学者1.运行CodeWarrior IDE,打开软件界面;2.点击“File”菜单下的“New”选项,然后在“Project”选项卡中选择“HC(S)12 New Project Wizard”,也就是新建工程向导,在右侧输入你要键入的工程名和你要放在哪个文件夹下面;3.点击“确定”后下面选择你采用的单片机型号,比如你选择“MC9S12D64”或者“MC9S12NE64”;(其中如果选择MC9S12NE64,则必须安装光盘上的NE64补丁插件)4.点击“下一步”后,选择你采用哪种编程语言,尽量不要选第三个“C++”,因为好像我试的有问题,如果你单纯的C,则选择第二个,如果你是C和汇编混合编程,则前两个都要选的;5.选择是否采用“处理器专家”,该项功能可以方便程序的寄存器设置,但我用过感觉比较糊涂,所以我一般选择“No”;6.下面就是选择是否采用“PC-lint”,选择“No”;7.选择是不是支持浮点数,如果你的工程采用浮点数则选择下面的两个中一个,否则选择“No”;8.选择采用哪种内存定位模式,一般选择第一个“Small”模式9.最后一步,选择前面两项,如果仅选择第一项,则仅可以软件调试,前两项都选择可以支持软件和硬件调试。

10.完成后,软件会自动创建一个工程,如下图所示,,其中左侧的sources 文件夹下面的main.c就是你的主程序文件,你可以在里面添加代码,同时在左侧按鼠标右键,会弹出菜单,里面有“Add Files”或“Create Group”等,可以根据你的需要往新创建的工程里添加你自己的头文件或者C文件。

11.你可以在main.c里面编辑你的代码,如果需要加入中断,则在左侧找到Prm文件夹下面打开“P&E_ICD_Linker.prm”,然后在右侧该文件里你可以加入你自己的中断函数和中断向量入口地址,记住:你在这个Prm里定义的自己的中断函数名,要和主函数里面的中断函数名对应起来;比如我在Prm文件里定义了串口接收中断:VECTOR ADDRESS 0XFFD6 SCI0Recive_ISR则在主函数(main.c)里面这样引用该中断函数:interrupt void SCI0Recive_ISR(void){里面是你自己的代码}12.现在一个简单的工程基本创建完成,点击下面的编译按钮进行或者调试按钮就进入调试环境13.如果您点击调试(绿色类似箭头按钮)的时候没反应,那可能是您设置的Debug 路径有问题,如果您采用我的方法,比如CW3.0仅安装了Compiler,然后安装了CW4的Debugger,这样的话就要设置一下Debug的路径。

Codewarrior帮助文件

Codewarrior帮助文件
14. C1412: Not a function call, address of a function 不是调用函数而是调用函数地址 [DISABLE, INFORMATION, WARNING, ERROR] Description A function call was probably desired, but the expression denotes an address of the function. 调用函数时,调用了函数的地址 Example void f(unsigned char i); void main() { f; // warning } Tips Write parenthesis (, ) with the arguments after the name of the function to be called. 在函数名后写括号。如上例 f();
5. C1016: Parameter redeclaration not permitted 参数不能重复定义 [ERROR]
2
ห้องสมุดไป่ตู้
《单片机技术初步实践》帮助文档
Description A parameter object was declared with the same name as another parameter object of the same function. 在一个函数中,反复定义一个参数名 Example void f(unsigned char i, unsigned char i) Tips Choose another name for the parameter object with the already used name. 如果想定义的参数名已定义,则换一个参数名,如例改为 void f(unsigned char i, unsigned char j)

CodeWarrior10.2教程

CodeWarrior10.2教程

CodeWarrior10.2教程上手CodeWarrior10.2建立Kinetis系统工程上篇说了说CW更新的事,昨天CW10.2装上之后玩了玩,结果不玩不知道一玩下一跳(说玩不是简单的打开软件看看界面美观否,而是对整个系统做了个初步的了解),哈哈,觉着基于eclipse的开发环境体验效果真的非常爽,顿时觉着MDK,IAR都是浮云了(呵呵,说这话可能会得罪人啊,纯属个人意见,还是那句话个人喜好和习惯问题,谅解,嘿嘿),下面会上图,给大家展现出Codewarrior10.2一些美好的体验。

在正式开篇建立kinetis工程之前,我在本篇博客更想分享关于10.2版本的两个好消息,我觉着大家肯定会很高兴,第一个就是10.2终于解决了license问题(可能用10.1Beta的网友大多数都遇到过在系统构建和调试时弹出的license窗口问题,当然自己公司购买的就不清楚了),这也证实了我当初的一种猜测,可能飞思卡尔当初急于推出kinetis占领cortex-m4市场,所以各项配套工具还不是很完善,从给出的官方例程上就可以看出来貌似FSL的工程师们赶工写出来的,有点乱,呵呵,所以10.1版本就在这个背景下推出来了,自然问题多多;谈完第一个好消息还有就是第二个好消息,那就是10.2在稳定性和对系统资源占用等方面做了些优化,我最大的体会就是以前用10.1时电脑经常性的卡机,甚至死住(当然我电脑配置算是中等偏下水准),尤其在调试下程序的时候,而10.2运行情况很流畅,这是我最大一个体验。

sorry,还没完(本山大叔小品看多了,呵呵),这里还得啰嗦一句,就是好多网友对软件的Special Edition和Evaluation Edition有所困惑,这里简单解释一下,Special Edition对软件基于C的代码空间有限制,而Evaluation版本则是对时间的限制(一般为30天全功能使用,之后就跟Special Edition一样了),当然这两个版本对汇编语言的大小还是不错限制的(废话,一般谁会用汇编写几十K,甚至上百K,软件开发商真是绝啊,哈哈)。

CodeWarrior使用说明

CodeWarrior使用说明

CodeWarrior使⽤说明第⼀章: 认识CodeWarrior第⼆章: ⼯程和⽬标⽂件的显⽰和定制第三章: 编译第四章: 链接第五章: 调试第六章: 定制第七章: 库函数和Microsoft Foundation Classes (MFC)1). CodeWarrior 能做些什么?A).使⽤C/C++ 进⾏编程B).也⽀持Java 开发本课程仅限于应⽤C/C++ 语⾔在Windows 平台上使⽤CodeWarrior 进⾏的开发.2). CodeWarrior 优点是什么?CodeWarrior 能够⾃动地检查代码中的明显错误,它通过⼀个集成的调试器和编辑器来扫描你的代码,以找到并减少明显的错误,然后编译并链接程序以便计算机能够理解并执⾏你的程序.3).常⽤编程类型说明:A).应⽤程序(如:⽂本编辑器WordPad )B). 庞⼤的商业软(如:⽐如象Adobe Photoshop,MicrosoftWord,CodeWarrior…)C). 控制⾯板(control panels)<实际上是设置系统功能的⼀个简单界⾯,⽐如可以在控制⾯板中完成.如:设置⾳量和⿏标移动速度这样⼀些参数.>D). 动态链接库(dynamic linked libraries,DLLs)<提供⼀些很有⽤的被系统和应⽤程序共享的函数.通常它们没有⽤户界⾯.>E). 插件(plug-ins)<类似于DLLs,插件也是可供其它软件使⽤的⼩程序,但插件只能被特定的软件使⽤.>4).CodeWarrior⼯具条介绍: 4.1).⽂件菜单: 4.2).编辑菜单4.3).查看菜单4.4).查找菜单4.5).⼯程菜单4.6).调试菜单4.8).窗⼝菜单4.9).帮助菜单4.7).VCS 菜单5).CodeWarrior 集成开发环境的设置5.1).通⽤设置5.5.1).编译设置(Build Settings): 选择是否在执⾏编译之前保存已打开的源⽂件,以及有多少内存被⽤于编译⼯作;5.5.2).IDE 之外(IDE Extras): ⼏个独⽴的设置.⽐如指定CodeWarrior 是否使⽤⼀个第三⽅的⽂本编辑器——因为集成的编辑器并不是很完美,这可以通过指定⼀个你惯⽤的编辑器来替代它;5.5.3).插件设置(Plug-In Settings): 供插件开发商调试他们的插件;5.5.4).隐藏⽂件夹(Shielded Folders): 在这⾥指定的⽂件夹在⼯程设计期间,或执⾏查找和⽐较操作期间,将要被忽略掉.如果在你的⼯程级有⼀个巨⼤的“数据”⽂件⽬录,⽽你⼜不想让这些⽂件降低CodeWarrior 的操作速度时,这个设置就很管⽤了;5.5.5).资料树(Source Trees): ⽤于指定CodeWarrior 在编译程序时⽤不着的⽬录.5.2).编辑器设置5.2.1).编辑器设置(Editor Settings): ⼏个⽤于定制编辑器显⽰、管理⽂本和窗⼝的设置项;5.2.2).字体和制表符(Fonts and Tabs): 设置编辑器中的⽂本⼤⼩、字体、制表符和其它显⽰设置;5.2.3).⽂本颜⾊(Text Colors): ⽤于指定特定语⾔元素(⽐如程序的注释)在编辑窗⼝中的显⽰的颜⾊。

CodeWarrior操作步骤

CodeWarrior操作步骤

CodeWarrior操作步骤建立Workspace1.打开CodeWarrior2.在目录下建立Workspace(注意工程不要建在桌面,在此为示范请勿效仿)3.建立新项目4.输入项目名称→Next5.选择您使用的芯片型号→Next6.选择编译器类型7.选择编译语言8.选择是否使用PE工具和视图工具9.代码优化选择10.配置完成,点击Finish工程各项配置1. 时钟配置.用户根据自己需求选择内外时钟及时钟大小2. 功能模块配置。

用户根据自己需求选择功能模块。

eg 。

IO 配置3.4. 各个功能模块配置好后,进行程序编写5. 主函数在ProcessorExperience.c 中6. 事件和中断等处理函数编写在Events 。

c 中Main 函数中的for 或while 循环从此出开始写,不然在更新PE 配置是程序被擦除触摸按键编写1.先将触摸按键库的5个文件添加进工程项目Sources中2.将触摸库添加到工程项目中。

右键点击Properties,进行一下设置。

3.更改触摸库TSI_config。

c文件设置第一步: 根据项目需要增加和减少使用到的TSI 通道.在TSI_config。

c 文件中,TSI_TOUCH _DELTA[MAX_TSI_NUM]数组定义了每个按键出发的阈值,分别对应TSI 物理通道的0-15,当某个按键触摸前后的差值大于该Delta 值时,就会触发对应的通道事件. 如果不需要使用某个通道时,可以直接把对应的Delta 值配置为0,那么在代码中该通道就不会被Initial, calibrate 和scan,如果重新启用,只需Delta 值配置为非0 即可。

第二步:配置按键号与物理通道之间的映射关系。

如下二维数组中, 左侧TSI_x 是实际的TSI 物理通道,右侧KEY_1, 2…N 对应着按键号0~N—1,这个按键号和TSI_main 函数的返回值touched_key 相对应,0xFF 表示未启用。

Freescale CodeWarrior 10.6 集成开发环境(IDE)使用手册

Freescale CodeWarrior 10.6 集成开发环境(IDE)使用手册

CodeWarrior 10.6 IDE使用手册
18
添加和配置定时器中断组件
最后在中断回调函数中添加中断处理,这里为全局中断计数器加1; 注意:用户的中断处理代码必须加在处理器专家指定的位置
CodeWarrior 10.6 IDE使用手册
19
在Main()函数添加用户代码
在main.c中引用全局变量Timer_10ms; 注意:这里添加全局变量和头文件include也必须加在处理器专家指定的位置
在当前工作空间(workspace),用户 也可以将其放到其他工作空间)
CodeWarrior 10.6 IDE使用手册
2
利用工程向导快速创建KEA工程
c. 选择器件,这里KEA属于Kinetis E系列,
故选择如下:
d. 选择调试工具,这里必须选择TRK-KEA128板
载的OpenSDA作为本工程的调试工具:
CodeWarrior 10.6 IDE使用手册
3
利用工程向导快速创建KEA工程
e.选择编程语言和浮点数支持以及控制 台(console)硬件支持: f.选择是否使用处理器专家系统以及工 程外设driver的使用模式:
Байду номын сангаас
CodeWarrior 10.6 IDE使用手册
4
利用工程向导快速创建KEA工程
29
观察指定地址的memory或变量
CodeWarrior 10.6 IDE使用手册
30
一些使用技巧
快捷键
跳转到函数/变量/宏定义:F3 C代码行注释/反注释:Ctrl + / C代码段注释:Ctrl + Shift + / 快速跳转至上一编辑处: Alt + Left 快速跳转至下一编辑处: Alt + Right 在资源管理器中快速打开CodeWarrior工程中的某一文件:选中该文件 右键选择最后一个选项“Show In Windows Explorer”

CODEV10.2说明书3

CODEV10.2说明书3

Application Programming InterfaceReference GuideVersion 10.2December 2009Pasadena, California 91107Phone: (626) 795-9101Fax: (626) 795-0184E-mail: service@The information in this document is subject to change without notice and should not be construed as a commitment by Optical Research Associates (ORA®). ORA assumes no liability for any errors that may Arrayappear in this document.The software described in this document is furnished under license and may be used or copied only in accordance with the terms of such license. The CODE V output shown (plotted and printed) may vary in different versions.Copyright © 2009 by Optical Research Associates. All rights reserved.Proprietary Software NotificationCODE V® is the proprietary and confidential property of ORA and/or its suppliers. It is licensed for use on the designated equipment on which it was originally installed and cannot be modified, duplicated, or copied in any form without prior written consent of ORA. If supplied under a U.S. Government contract the following also applies:Restricted Rights LegendUse, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 or insubparagraph (c) of the Commercial Computer Software - Restricted Rights clause at FARS 52.227-19.ORA, CODE V, and LightTools are registered trademarks of Optical Research Associates. Other trademarksor marks are the property of their respective companies.CODE V API Reference Guide Contents • iiiContentsChapter 1OverviewWhat is the CODE V API? (1)Requirements (1)A Note about the DEFAULTS.SEQ File (2)Getting Started (2)DisplayAlerts Property (4)Speeding Up COM Client Execution...............................................................................................4Chapter 2CODE V Interface FunctionsGeneral Utility Functions (6)Start/StopCodeV (6)Get/SetCommandTimeout (7)Get/SetMaxTextBufferSize (8)Get/SetStartingDirectory (9)GetCodeVVersion (10)Asynchronous Usage Functions (11)AsyncCommand (11)IsExecutingCommand (12)Wait (13)GetCommandOutput (14)StopCommand (15)Synchronous Usage Functions (16)Command (16)EvaluateExpression (17)CODE V State Information (18)GetCurrentOption (18)GetCurrentSubOption (19)GetZoomCount (20)GetSurfaceCount (21)GetFieldCount (22)GetWavelengthCount (23)GetDimension (24)GetStopSurface (25)GetMaxAperture (26)Math and Optical MACRO Functions (27)BESTSPH (27)EVALZERN (28)FITERROR (29)GAUSSBEAM (30)GAUSSWTS (32)INDEX (33)MTF_1FLD (34)NORMRADIUS (35)POLGRID (36)RAYPOL (39)RAYRSI (42)RAYSIN..................................................................................................................................43iv • Contents CODE V API Reference GuideRAYTRA................................................................................................................................44RMSWE..................................................................................................................................45RMS_1FLD.............................................................................................................................48SAGF (50)SASF (51)SURFSAGD (52)SVD (53)TRA_1FLD (54)TRANSFORM (56)ZERNIKE (57)ZERNIKEGQ (59)Zernike Fitting Functions (61)ZFRCOEF (62)Buffer Functions (63)Sample Code: Outputting buffer data from CODE V (63)BufferToArray (64)ArrayToBuffer (65)Chapter 3CODE V API by ExampleWriting PSF Data to an Excel Spreadsheet (67)Results (69)Creating a Surface Listing (70)MATLAB Sample File...................................................................................................................72Appendix A CVCommand ErrorsE_INVALIDARG (73)DISP_E_BADINDEX (73)E_UNEXPECTED (73)FACILITY_ITF..............................................................................................................................73Chapter 1OverviewWhat is the CODE V API?The CODE V API is an application programming interface designed to allow access from otherprograms to CODE V commands. The CODE V API uses the Microsoft Windows standardComponent Object Model (COM) interface1. This enables you to execute CODE V commandsusing applications such as Microsoft Visual Basic (VB), Microsoft Office Applications, C++,MATLAB, or any other application that supports Windows COM architecture. The CODE V API is particularly useful for automating tasks or retrieving data used in calculations in other programs.Both Visual Basic and Excel provide an integrated development environment in which you candevelop CODE V command functions.2 This type of environment provides context-sensitiveediting and debugging, Windows standard forms, object oriented programming capabilities(Classes), standard functions in Visual Basic/Excel (or the client program), external object libraries known as dynamic link libraries (DLLs), as well as other conveniences that can enhance thefunction writing process.The CODE V API has no graphical user interface, and therefore no graphics support; any plotscreated with a CODE V API function must be output to a file or they are lost. Plot files can beviewed either in CODE V, or in the standalone CODE V Viewer program (CVPlotView). RequirementsIn order to use the CODE V API to write and run commands, you must have installed:•CODE V 9.30 or laterDuring installation, CODE V is configured to support API command execution. This processregisters CODE V as a COM server on your system (cvcommand).•Any Visual Basic compliant application (such as Microsoft Excel, Word, PowerPoint, Visual Basic, or MATLAB) or any other Windows program that supports Microsoft COMarchitecture1. The COM enables Windows Programs to communicate with each other using the Client/Serverconcept. For example, the program that initiates the communication process is referred to asthe client, and the program that responds to client’s requests is referred to as the server. Currently,CODE V can only act as a server, meaning that it can only respond to client programs.2. This document concentrates on Visual Basic as the client for writing functions. To use other pro-grams, please refer to their documentation (under “Automation” or “COM” support).CODE V API Reference Guide Overview • 12 • Overview CODE V API Reference GuideA Note about the DEFAULTS.SEQ FileWhen you use the CODE V API, note that your DEFAULTS.SEQ file is not automatically loaded when CODE V is run. You must include the following command in your function to load this file:mand("in defaults.seq")Getting StartedThis example describes how to write a very simple command function using the Visual Basic Editor provided with Microsoft Excel.1.Start Microsoft Excel.2.Select Tools > Macro > Visual Basic Editor .The Microsoft VisualBasic window is displayed.3.Add the CODE V Command Type Library as a reference by doing the following:a.Select Tools > References . . ..b.In the References - VBAProject window, select the Optical Research AssociatesCVCommand Type Library and click OK .If you are running Excel 97, the CVCommand Type Library may not be listed in theAvailable References. If it is not, select Browse and navigate to the CODE V installation directory. Click on cvcommand.tlb and click Open to add the CVCommand Type Library to the Available References.3.Back in the Microsoft Visual Basic window, select Tools > Macros .4.In the Macros window, key in a name and click Create .5.In the Book1 - Module1(Code) window, you can begin writing your macro.a.Declare the session variable:Dim Session As CVCommand b.Request an instance of the CVCommand interface using the Set statement:Set session = CreateObject("mand.930")This instance should be requested by object name, which in this case is version 9.30 ofCODE V . A specific version number should be requested because the interfaces maychange with later versions of CODE V.CODE V API Reference Guide Overview • 3c.Once an instance is created, the CODE V utility functions can be called on to set up theenvironment parameters, such as buffer size and starting directory. For example:session.SetStartingDirectory("c:\CVUSER")e the StartCodeV function to start up CODE V:session.StartCodeVplete the macro as desired and save your project.Following is a sample macro that starts CODE V , opens the sample lens file dbgauss.len, and optimizes the lens:Sub RunCodeV()Dim Session As CVCommand'Create an instance of CODE V and set the starting directory to c:\CVUSER Set session = CreateObject("mand.xxx")'where xxx is the CODE V version; for example, xxx=101 for version 10.1 session.SetStartingDirectory("c:\CVUSER")session.StartCodeVmand("in defaults.seq")'load a lens (dbgauss) and run AUTO to optimize itresult = mand("res cv_lens:dbgauss")result = mand("aut; go")MsgBox (result)'evaluate the Effective Focal Lengthresult = session.EvaluateExpression ("(efl)")'Shut down the instance of CODE Vsession.StopCodeVSet session = NothingEnd Sub6.From the Visual Basic window, click Run > Run Sub/User Form , or click the Run icon on thetoolbar.The macro will run CODE V and execute the specified CODE V command functions.For details about the available CODE V commands available for use with the CODE V API, go to Chapter 2, “CODE V Interface Functions” on page5.DisplayAlerts PropertyIf your macro starts a CODE V process that takes time, and waits for a response, then VB or VBA Array will try to issue a warning message indicating that the server is not responding and may not run the remaining portion of the macro. To suppress this message, you can use the following code:in VBA:Application.DisplayAlerts = Falsedisables the display of alert boxes; however, this setting should be used selectively and changedback to True when not needed.in VB, you can set:App.OleRequestPendingTimeout = NApp.OleRequestBusyTimeout = Nwhere N is the number of milliseconds. N should be greater than the time it takes to run the process. Speeding Up COM Client ExecutionThe REC command allows you to disable recording of data in the CODE V recovery file, whichcan help speed up execution of COM clients. See “Defining Configuration - I/O” on page24-19 ofthe CODE V Reference Manual for details about REC. Note that, by default, CODE V alwaysrecords data in the recovery file, which is recommended for general CODE V usage.4 • Overview CODE V API Reference GuideCODE V API Reference Guide CODE V Interface Functions • 5Chapter 2CODE V Interface FunctionsThis section contains details for each CODE V interface function. The CODE V interface functions are grouped in the following categories, based on what they do.•General Utility Functions.................................................................................... 6•Asynchronous Usage Functions......................................................................... 11•Synchronous Usage Functions........................................................................... 16•CODE V State Information ............................................................................... 18•Math and Optical MACRO Functions............................................................... 27•Buffer Functions................................................................................................63General Utility FunctionsStart/StopCodeVThese functions start or stop the CODE V session being run by CVCommand. Start must be called before any function other than Set/GetCommandTimeout, Set/GetMaxTextBufferSize,GetCodeVVersion, or Set/GetStartingDirectory is called. StopCodeV must be called when you are done running the session of CODE V.Visual Basic SyntaxStartCodeV()StopCodeV()6 • CODE V Interface Functions CODE V API Reference GuideGet/SetCommandTimeoutThese functions are used to get or set the timeout for synchronous commands. They have no effect on asynchronous commands.Visual Basic SyntaxSetCommandTimeout(nTimeout As Integer)GetCommandTimeout() As IntegerParameterReturn ValueFor GetCommandTimeout, the current timeout time in seconds.nTimeoutCurrent timeout time in secondsGet/SetMaxTextBufferSizeThese functions are used to get or set the maximum buffer size for text returned by the Command and GetCommandOutput functions.Visual Basic SyntaxSetMaxTextBufferSize(lSize As Long)GetMaxTextBufferSize() As LongParameterReturn ValueFor GetMaxTextBufferSize, a pointer to a long integer that contains the current maximum buffer size.lSize Long integer containing the desired maximum buffer size in characters.Default is 256000.Get/SetStartingDirectoryGet or set the working directory for CODE V . SetStartingDirectory must be called before StartCodeV to set the directory of execution.Visual Basic SyntaxGetStartingDirectory() As StringSetStartingDirectory(bstrStartingDirectory As String)ParameterReturn ValuePointer to a string defining the current starting directory.bstrStartingDirectoryString defining the desired starting directory.GetCodeVVersionVisual Basic SyntaxGetCodeVVersion() As StringParameterNone.Return ValueVersion of CODE V that is running.Asynchronous Usage FunctionsAsyncCommandStart an asynchronous command. Only one AsyncCommand call can be run at a time, but multiple AsyncCommand calls can be made during a CVCommand session. This function call fails if CODE V is already running a command. Calling this function clears the results of the previous asynchronous function call.Visual Basic SyntaxAsyncCommand(bstrCommandLine As String)ParameterbstrCommandLineCommand to be executed.IsExecutingCommandVisual Basic SyntaxIsExecutingCommand() As LongParameterNone.Return ValueBoolean that indicates whether or not an asynchronous command is currently executing.WaitWait for an asynchronous command to complete.Visual Basic SyntaxWait(nWaitTime As Integer) As CVWaitStatusParameterReturn ValueEnumeration for wait status, either Completed or TimeOut:Completed Command completed 1TimeOut Wait timed out with the command still runningnWaitTimeTime to wait in seconds.GetCommandOutputEvaluateExpression, or math and optical functions) between calls to AsyncCommand andGetCommandOutput. This will preserve the buffer between those two calls.Visual Basic SyntaxGetCommandOutput() As StringParameterNone.Return ValueString containing the output. Its maximum length is the maximum buffer size.StopCommandThis function aborts the currently running CODE V calculation.Visual Basic SyntaxStopCommand()Synchronous Usage FunctionsCommandThis function sends a command to the CODE V session being run by CVCommand and returns its output. Calling this function clears the results of the previous asynchronous function call.Visual Basic SyntaxCommand(bstrCommandLine As String) As StringParameterReturn ValueThe command output. Its size is limited by the maximum buffer size set withSetMaxTextBufferSize.bstrCommandLineCODE V command.EvaluateExpressionThis function evaluates an expression and returns its value. It is equivalent to the EV A command in CODE V .Visual Basic SyntaxEvaluateExpression(bstrExpression As String) As StringParameterReturn ValuePointer to a string into which CVCommand will put the results of the evaluation. Note that because this is a string, the value is only as precise as the output into the string; it is not a true floating point value.bstrExpressionString containing the expression to evaluate.CODE V State Informationasynchronous command.GetCurrentOptionReturns the name of the current option.Visual Basic SyntaxGetCurrentOption() As StringParameterNone.Return ValueThe option short name (e.g., AUT for Automatic Design). Returns "CHA" if CODE V is notcurrently in an option.GetCurrentSubOptionVisual Basic SyntaxGetCurrentSubOption() As StringParameterNone.Return ValueThe option name. Returns an empty string if CODE V is not currently in a sub-option.Visual Basic SyntaxGetZoomCount() As Integer ParameterNone.Return ValueThe current number of zoom positions in the lens.Visual Basic SyntaxGetSurfaceCount() As Integer ParameterNone.Return ValueThe current number of surfaces.GetFieldCountVisual Basic SyntaxGetFieldCount() As Integer ParameterNone.Return ValueThe current number of fields.GetWavelengthCountVisual Basic SyntaxGetWavelengthCount() As Integer ParameterNone.Return ValueThe current number of wavelengths.GetDimensionReturns a value representing the type of dimensions in the system.Visual Basic SyntaxGetDimension() As IntegerParameterNone.Return ValuesThe value representing the type of dimensions in the system:0Inches1Centimeters2MillimetersVisual Basic SyntaxGetStopSurface() As Integer ParameterNone.Return ValueThe surface number of the current stop surface.Returns the maximum aperture size for the specified surface and zoom.Visual Basic SyntaxGetMaxAperture(nSurface As Integer, nZoom As Integer) As DoubleParametersReturn ValueMaximum aperture size. This uses the “MAP” database item.nSurfaceNumber of the surface for which the maximum aperture will be oomZoom position at which the maximum aperture will be determined.Math and Optical MACRO FunctionsThe following functions are equivalent to calling various CODE V macro functions. For more details about the CODE V macro functions referenced, see “Language Reference” on page 25A-1 of the CODE V Reference Manual .BESTSPHThis is equivalent to calling the BESTSPH macro function in CODE V .Visual Basic SyntaxBESTSPH(nSurface As Integer, nZoomPos As Integer,dblMinHeight As Double, dblMaxHeight As Double) As DoubleParametersReturn ValueThe return value of the BESTSPH macro function. It is the curvature of the best fitting sphere.nSurface Desired surface.nZoomPos Desired zoom position.dblMinHeight Minimum Y coordinate.dblMaxHeightMaximum Y coordinate.EVALZERNThis is equivalent to calling the EV ALZERN macro function in CODE V . The EV ALZERN macron function evaluates a Zernike polynomial generated with the ZERNIKE, ZERNIKEGQ, orZFRCOEF macro function and computes the value of the polynomial at a point X,Y , where X and Y are normalized to the unit circle.Visual Basic SyntaxEVALZERN(nWavelengthNum As Integer, nFieldNum As Integer, nZoomPos As Integer, dblX As Double, dblY As Double, nPolType As Integer, eOutputType As CVZernOutputTypeEnum, eZernType As CVZernTypeEnum) As DoubleParametersReturn ValueThe value of the Zernike polynomial at the specified coordinate. If the polynomial has not been defined with the ZERNIKE, ZERNIKEGQ, or ZFRCOEF function, EV ALZERN returns a value of -1e10.nWavelengthNum Number of the wavelength defined in ZERNIKE, ZERNIKEGQ, or ZFRCOEF.nFieldNum Number of the field point defined in ZERNIKE, ZERNIKEGQ, or ZFRCOEF.nZoomPos Zoom position defined in ZERNIKE, ZERNIKEGQ, or ZFRCOEF.dblX X coordinate to be evaluated.dblY Y coordinate to be evaluated.nPolTypeNumber specifying whether polarization ray tracing is enabled for this computation; matches the number defined in ZERNIKE or ZERNIKEGQ. If you used ZFRCOEF, this must be 0.eOutputTypeEnumeration of the output type ('intensity' or 'phase'), specifying intensity or phase. Matches the type used in ZERNIKE or ZERNI-KEGQ. If you used ZFRCOEF, the output must be 'phase.'eZernTypeType of the Zernike polynomial. Matches the expression defined inZERNIKE or ZERNIKEGQ. If you used ZFRCOEF, it must be 'zfr.'FITERRORThis is equivalent to calling the FITERROR macro function in CODE V .Visual Basic SyntaxFITERROR(nWavelengthNum As Integer, nFieldNum As Integer, nZoomPos As Integer, nPolType As Integer, eOutputType As CVZernOutputTypeEnum, eZernType As CVZernTypeEnum) As DoubleParametersReturn ValueThe RMS fit error of the Zernike polynomial. If the polynomial has not been defined with the ZERNIKE or ZFRCOEF function, FITERROR returns a value of -1. If used with the ZERNIKEGQ macro function, returns a value of 0.nWavelengthNum Number of the wavelength defined in ZERNIKE or ZFRCOEF.nFieldNum Number of the field point defined in ZERNIKE or oomPos Zoom position defined in ZERNIKE or ZFRCOEF.nPolTypeNumber specifying whether polarization ray tracing is enabled for this computation; matches the number defined in ZERNIKE. If you used ZFRCOEF, this must be 0.eOutputTypeEnumeration of the output type ('intensity' or 'phase'), specifying intensity or phase. Matches the type used in ZERNIKE. If you used ZFRCOEF, the output must be 'phase.'eZernTypeType of the Zernike polynomial. Matches the expression defined inZERNIKE. If you used ZFRCOEF, it must be 'zfr.'GAUSSBEAMThis is equivalent to calling the GAUSSBEAM macro function in CODE V .Visual Basic SyntaxGAUSSBEAM(nSurface As Integer, nZoomPos As Integer, nFieldNum As Integer, nWavelengthNum As Integer, psaInput() As Double, eOutputType As CVGaussbeamOutputTypeEnum) As DoubleParametersnSurfaceThe surface number to use. For non-sequential systems, if you enter a negative value, that value refers to the hit number rather than the sur-face number. This gives you direct access to the information by hit number.nZoomPos Zoom position to use.nFieldNumNumber of field positions to use.nWavelengthNum Number of the wavelength to use (not the value of the wavelength).psaInputA five-element input array containing the following parameters (in this order): initial beam-width radius (at the object plane) at the 1/ e 2 inten-sity point in the X meridian (WRX), initial beam-width radius (at the object plane) at the 1/ e 2 intensity point in the Y meridian (WRY), radius of curvature of input wavefront (at object plane) in X meridian (RCX), radius of curvature of input wavefront (at object plane) in Y meridian (RCY), orientation (in degrees) of input beam definition about the optical (z) axis (AZI).eOutputTypeEnumeration specifying the output value of the function:0PROP Propagation distance to the next surface 1BSDX X semi-diameter of the beam 2BSDY Y semi-diameter of the beam 3BANG Beam angle (in degrees)4WCUX X Curvature of the Wavefront 5WCUY Y Curvature of the Wavefront 6WSDX X semi-diameter of the waist 7WSDY Y semi-diameter of the waist 8WDSX X waist distance from the surface 9WDSY Y waist distance from the surface 10SURX X Coordinate of the beam on the surface 11SURY Y Coordinate of the beam on the surface 12SURZZ Coordinate of the beam on the surfaceReturn ValueFor non-sequential systems, the macro function returns results for the last time the specified surface was hit. If that surface was not hit, the function returns 0.13RDCL L Direction cosine (geo) of center of beam prior to surface14RDCM M Direction cosine (geo) of center of beam prior to surface15RDCN N Direction cosine (geo) of center of beam prior to surface16AINC Angle of incidence (in degrees) of center of beam at surface17SURNFor NS systems. Return the surface number for the hit number specified with the surface numparameterGAUSSWTSThis function is equivalent to calling the GAUSSWTS macro function in CODE V .Visual Basic SyntaxGAUSSWTS(nNumInputPts As Integer, psaInputCoords() As Double, psalInputWeights() As Double, nNumQuadPts As Integer, psaCoords() As Double, psaWeights() As Double) As DoubleParametersReturn ValueThe return value of the GAUSSWTS macro function. It is 0 if there are no errors in the computation, and -1 if any errors are encountered.nNumInputPts Number of input points at which weights are supplied.psaInputCoordsInput array of coordinates at which weights are supplied. It must be nNumInputPts long. The input coordinates do not need to be equally spaced.psalInputWeights An input array, dimensioned at nNumInputPts, of the weighting function at the points specified in psaInputCoords.nNumQuadPts Number of Gaussian quadrature points and weights desired.psaCoords An output array, dimensioned at nNumQuadPts, of the coordinates to be used for the numerical integration.psaWeightsAn output array, dimensioned at nNumQuadPts. It will receive theweights to be used for the numerical integration.INDEXThis is equivalent to calling the INDEX macro function in CODE V .Visual Basic SyntaxINDEX(nSurface As Integer, nZoomPos As Integer,nWavelengthNum As Integer, nGlassNum As Integer, dblX As Double, dblY As Double, dblZ As Double) As DoubleParametersReturn ValueThe refractive index at the specified point. Note that it can be positive or negative, depending on the direction the light is traveling. If the first four parameters are outside their allowed range or if the index cannot be computed for any reason, the return value is set to 0.0.nSurface Surface number of the GRIN oomPosZoom position.nWavelengthNum Number of the wavelength to be used (not the wavelength value).nGlassNum Glass number (for NSS surfaces). Value must be either 1 or 2. For sequential surfaces, use 1.dblX, dblY , dblZCoordinates relative to the surface origin where the index is to becomputed.MTF_1FLDMTF_1FLD computes the MTF of the lens system including or excluding diffraction effects,assuming either a sine wave or a square wave object, similar to the MTF option. It is equivalent to calling the MTF_1FLD macro function in CODE V .Visual Basic SytaxMTF_1FLD(nZoomPos As Integer, nFieldNum As Integer, Frequency As Double, Azimuth As Double, NRD As Integer, MTFValues() As Double, MTFtype As CVMTFTypeEnum, MTFWave As CVMTFWaveEnum) As DoubleParametersReturn ValueThe return value of the function is the modulation. If there is an error in the computation or inputs, the return value is -1. Since a negative modulation is not valid, any negative return value indicates that the calculation failed.nZoomPos Zoom position to use. Range: 1 to (NUM Z).nFieldNum Number of field point to use. Range: 1 to (NUM F).FrequencySpatial frequency at the image surface. Units are cycles/mm for focal systems, and cycles per angular measure for afocal (AFC) systems, where the angular measure is defined by the angular units specification (ADM).Azimuth Orientation of the spatial frequency at the image, in degrees.NRD Number of grid rays across the diameter of the pupil. If nrd is set to zero, the calculation is performed using a default value of 60.MTFValuesThe output array name must be declared before the macro is called, and is a one-dimensional output array that will contain the following six elements:1.Modulation2.Phase (degrees)3.Analytic diffraction limit value4.Actual diffraction limit value5.Illumination for unit brightness6.Number of rays traced (in convolved pupil for diffraction MTF)These data values correspond to the equivalent values output by the MTF option.MTFtype String expression specifying diffraction MTF ('DIF') or geometrical MTF ('GEO').MTFWaveString expression specifying sine wave response ('SIW') or square waveresponse ('SQW').。

USBDM 驱动固件升级安装使用指南

USBDM 驱动固件升级安装使用指南

USBDM驱动固件升级安装使用指南版本V1.0 2012年04月25日清华Freescale应用开发研究中心USBDM是针对Freescale公司处理器调试接口的开源工程。

为了满足Freescale智能车大赛的需要,清华大学飞思卡尔应用开发研究中心特别针对大赛需要制作了可用于Kinetis系列处理器调试的USBDM调试器。

图1是第七届大赛提供给参赛队伍的K10处理器核心板和配套的USBDM调试器。

图1,USBDM和K10核心板外观为了帮助参赛队伍尽快入门Kinetis处理器的使用和调试,本文着重阐述USBDM调试器的驱动安装和固件升级。

USBDM是pgo在网络上开源的调试器接口,其固件在广大开源爱好者和单片机开发工程师的广泛使用下,会不断的修正设计中存在的bug,因此会经常更新驱动和固件等。

同时Freescale公司的调试软件Codewarrior Eclipse 版本也在不断的升级,参赛队伍可以按照本文描述的方法及步骤安装新版本的USBDM驱动,升级USBDM的固件等。

1.下载和安装最新版本的Codewarrior Eclipse版本Codewarrior是Freescale公司的单片机和处理器以及DSP开发软件,目前正在从传统版本过渡到基于Eclipse架构的新版本。

参赛队伍可以从Freescale公司的网站下载到最新版本的Codewarrior for Microcontrollers软件,目前最新版本是10.2。

具体的网址在:/codewarrior。

下载完成以后安装即可,默认的安装目录是在C:\Freescale\ CW MCU v10.2 。

2.下载和安装最新版本的USBDM驱动版本USBDM是网友pgo开发的开源调试接口,主要用于Freescale公司的单片机和处理器的调试,本次智能车大赛使用的是针对Kinetis处理器的版本。

为了适应中国的国情,我们针对pgo版本的硬件做了一些调整,主要是比如添加了USB接口的TVS保护,共模抑制的滤波,调试电源的显示,调试接口的TVS保护等。

Codewarrior使用指南

Codewarrior使用指南

创建新工程 6
9、是否添加Startup Code 10、选择Memory类型 11、选择是否使用浮点数及 类型
Slide 8
TM
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc. 2005.
创建新工程 5
8、选择是否用设置初始化或处理器专家
Slide 7
TM
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc. 2005.
模拟调试器界面
工具条
打开文件 单步 进入 单步 跳出 停止 复位
保存当前 设置
运行 单步跳过
汇编单步
Slide 15
TM
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc. 2005.

CODEV10.2说明书6

CODEV10.2说明书6

Appendix C Zernike Polynomials About Zernike Polynomials Zernike polynomials are polynomials defined in radial coordinates (R and θ) over a unit circle. They are favored for representing wavefronts because they are orthogonal within the unit circle in which they aredefined. Typically, measured data is fit inside the unit circle, so the polynomial is less reliable in regions outside the circle. Scalings (INR) which make the unit circle smaller than the clear aperture of the surface or the exit pupil should be avoided.The relationship between (R,θ), where R is the radial distance and θ is the azimuth, and (X,Y) is X=R*cos(θ) and Y=R*sin(θ). The coordinate system is shown below, where a positive rotation is counter-clockwise (rotate +X axis toward +Y axis).Figure 1.Coordinate System for Zernike PolynomialsTwo types are used in CODE V, the standard Zernike polynomial and the FRINGE Zernike polynomial. Terms for these are listed, respectively, in “Standard Zernike Polynomials (ZRN)” on page C-2 and “FRINGE Zernike Polynomials (ZFR)” on page C-5.See “Technical Notes” on page C-7 for in-depth discussions regarding the application of Zernike polynomials to various purposes.Use of Zernike Polynomials in CODE VZernike polynomials are used in a number of different ways in CODE V, including the following:•Modeling surface types—see “Zernike Polynomial (SPS ZRN)” on page 4-103.•Describing interferometric data—see “INT File Format” on page 10-30.•Pupil mapping—see “Fitting Data to Zernike Polynomials” on page 18-141.•Defining error functions for tolerancing—see “Zernike Polynomial Controls” on page 20-32.Specific details about using Zernike polynomials in these applications can be found in the cited locations. Several pre-defined Macro-PLUS functions have been created for use with Zernike polynomials in CODE V, and are listed in “Predefined Functions” on page 25A-16.Zernike PolynomialsStandard Zernike Polynomials (ZRN)Standard Zernike Polynomials (ZRN)The standard Zernike polynomial is described in Born and Wolf, Principles of Optics (Pergamon Press, New York, 1989). The standard Zernike polynomial may have any number of terms, although a large number of terms will naturally increase the computation time. A typical number of terms is 36. The first 66 terms are listed in the following table.Table 1Standard Zernike Polynomials (ZRN) Term Standard Zernike Polynomial Aberration Type 11Piston (constant)2Rcos θDistortion - Tilt (x-axis)3Rsin θDistortion - Tilt (y-axis)4R 2cos2θAstigmatism, Primary (axis at 0° or 90°)52R 2 - 1Defocus - Field curvature6R 2sin2θAstigmatism, Primary (axis at ±45°)7R 3cos3θTrefoil, Primary (x-axis)8(3R 3 - 2R)cos θComa, Primary (x-axis)9(3R 3 - 2R)sin θComa, Primary (y-axis)10R 3sin3θTrefoil, Primary (y-axis)11R 4cos4θTetrafoil, Primary (x-axis)12(4R 4 - 3R 2)cos2θAstigmatism, Secondary (axis at 0° or 90°)136R 4 - 6R 2 + 1Spherical Aberration, Primary14(4R 4 - 3R 2)sin2θAstigmatism, Secondary (axis at ±45°)15R 4sin4θTetrafoil, Primary (y-axis)16R 5cos5θPentafoil, Primary (x-axis)17(5R 5 - 4R 3)cos3θTrefoil, Secondary (x-axis)18(10R 5 -12R 3 + 3R)cos θComa, Secondary (x-axis)19(10R 5 -12R 3 + 3R)sin θComa, Secondary (y-axis)20(5R 5 - 4R 3)sin3θTrefoil, Secondary (y-axis)21R 5sin5θPentafoil, Primary (y-axis)Zernike PolynomialsStandard Zernike Polynomials (ZRN)22R 6cos6θ23(6R 6 -5R 4)cos4θTetrafoil, Secondary (x-axis)24(15R 6c - 20R 4 + 6R 2)cos2θAstigmatism, Tertiary (axis at 0° or 90°)2520R 6 - 30R 4 + 12R 2 - 1Spherical Aberration, Secondary 26(15R 6 - 20R 4 + 6R 2)sin2θAstigmatism, Tertiary (axis at ±45°)27(6R 6 -5R 4)sin4θTetrafoil, Secondary (y-axis)28R 6sin6θ29R 7cos7θ30(7R 7 - 6R 5)cos5θ31(21R 7 - 30R 5 + 10R 3)cos3θTrefoil, Tertiary (x-axis)32(35R 7 - 60R 5 + 30R 3 - 4R)cos θComa, Tertiary (x-axis)33(35R 7 - 60R 5 + 30R 3 - 4R)sin θComa, Tertiary (y-axis)34(21R 7 - 30R 5 + 10R 3)sin3θTrefoil, Tertiary (y-axis)Z35(7R 7 - 6R 5)sin5θ36R 7sin7θ37R 8cos8θ38(8R 8 - 7R 6)cos6θ39(28R 8 - 42R 6 + 15R 4)cos4θ40(56R 8 - 105R 6 + 60R 4 - 10R 2)cos2θAstigmatism, Quaternary (axis at 0° or 90°)4170R 8 - 140R 6 + 90R 4 - 20R 2 + 1Spherical Aberration, Tertiary42(56R 8 - 105R 6 + 60R 4 - 10R 2)sin2θAstigmatism, Quaternary (axis at ±45°)43(28R 8 - 42R 6 + 15R 4)sin4θ44(8R 8 - 7R 6)sin6θ45R 8sin8θ46R 9cos9θ47(9R 9 - 8R 7)cos7θTable 1Standard Zernike Polynomials (ZRN) (con’t.)Term Standard Zernike PolynomialAberration TypeZernike PolynomialsStandard Zernike Polynomials (ZRN)48(36R 9 - 56R 7 + 21R 5)cos5θ49(84R 9 - 168R 7 + 105R 5 - 20R 3)cos3θ50(126R 9 - 280R 7+ 210R 5 - 60R 3 + 5R)cos θComa, Quaternary (x-axis)51(126R 9- 280R 7 + 210R 5 - 60R3 + 5R)sin θComa, Quaternary (y-axis)52(84R 9 - 168R 7 + 105R 5 - 20R 3)sin3θ53(36R 9 - 56R 7 + 21R 5)sin5θ54(9R 9 - 8R 7)sin7θ55R 9sin9θ56R 10cos10θ57(10R 10 - 9R 8)cos8θ58(45R 10 - 72R 8 + 28R 6)cos6θ59(120R 10 - 252R 8 + 168R 6 - 35R 4)cos4θ60(210R 10 - 504R 8 + 420R 6 - 140R 4 + 15R 2)cos2θ61252R 10 - 630R 8 + 560R 6 - 210R 4 + 30R 2 - 1Spherical Aberration, Quaternary62(210R 10 - 504R 8 + 420R 6 - 140R 4 + 15R 2)sin2θ63(120R 10 - 252R 8 + 168R 6 - 35R 4)sin4θ64(45R 10 - 72R 8 + 28R 6)sin6θ65(10R 10 - 9R 8)sin8θ66R 10sin10θTable 1Standard Zernike Polynomials (ZRN) (con’t.)Term Standard Zernike Polynomial Aberration TypeZernike PolynomialsFRINGE Zernike Polynomials (ZFR)FRINGE Zernike Polynomials (ZFR)The FRINGE Zernike polynomial was originally developed at the University of Arizona and is used in the FRINGE program. It is also used by several vendors of interferometers and interferometer software. It has a maximum of 37 terms, which are a subset of the standard Zernike polynomials, arranged in a different order. The terms are listed below.Table 2 FRINGE Zernike polynomials (ZFR) Term FRINGE Zernike polynomial Aberration Type 11Piston (constant)2R cos(θ)Distortion - Tilt (x-axis)3R sin(θ)Distortion - Tilt (y-axis)42R 2 - 1Defocus - Field curvature5R 2 cos(2θ)Astigmatism, Primary (axis at 0° or 90°)6R 2 sin(2θ)Astigmatism, Primary (axis at ±45°)7(3R 3 - 2R) cos(θ)Coma, Primary (x-axis)8(3R 3 - 2R) sin(θ)Coma, Primary (y-axis)96R 4 - 6*R 2 + 1Spherical Aberration, Primary10R 3 cos(3θ)Trefoil, Primary (x-axis)11R 3 sin(3θ)Trefoil, Primary (y-axis)12(4R 4 - 3R 2) cos(2θ)Astigmatism, Secondary (axis at 0° or 90°)13(4R 4 - 3R 2) sin(2θ)Astigmatism, Secondary (axis at ±45°)14(10R 5 - 12R 3 + 3R) cos(θ)Coma, Secondary (x-axis)15(10R 5 - 12R 3 + 3R) sin(θ)Coma, Secondary (y-axis)1620R 6 - 30R 4 + 12R 2 - 1Spherical Aberration, Secondary17R 4 cos(4θ)Tetrafoil, Primary (x-axis)18R 4 sin(4θ)Tetrafoil, Primary (y-axis)19(5R 5 - 4R 3) cos(3θ)Trefoil, Secondary (x-axis)20(5R 5 - 4R 3) sin(3θ)Trefoil, Secondary (y-axis)21(15R 6 - 20R 4 + 6R 2) cos(2θ)Astigmatism, Tertiary (axis at 0° or 90°)22(15R 6 - 20R 4 + 6R 2) sin(2θ)Astigmatism, Tertiary (axis at ±45°)Zernike PolynomialsFRINGE Zernike Polynomials (ZFR)23(35R 7 - 60R 5 + 30R 3 - 4R) cos(θ)Coma, Tertiary (x-axis)24(35R 7 - 60R 5 + 30R 3 - 4R) sin(θ)Coma, Tertiary (y-axis)2570R 8 - 140R 6 + 90R 4 - 20R 2 + 1Spherical Aberration, Tertiary 26R 5 cos(5θ)Pentafoil, Primary (x-axis)27R 5 sin(5θ)Pentafoil, Primary (y-axis)28(6R 6 - 5R 4) cos(4θ)Tetrafoil, Secondary (x-axis)29(6R 6 - 5R 4) sin(4θ)Tetrafoil, Secondary (y-axis)30(21R 7 - 30R 5 + 10R 3) cos(3θ)Trefoil, Tertiary (x-axis)31(21R 7 - 30R 5 + 10R 3) sin(3θ)Trefoil, Tertiary (y-axis)32(56R 8 - 105R 6 + 60R 4 - 10R 2) cos(2θ)Astigmatism, Quaternary (axis at 0° or 90°)33(56R 8 - 105R 6 + 60R 4 - 10R 2) sin(2θ)Astigmatism, Quaternary (axis at ±45°)34(126R 9 - 280R 7 + 210R 5 - 60R 3 + 5R) cos(θ)Coma, Quaternary (x-axis)35(126R 9 - 280R 7 + 210R 5 - 60R 3 + 5R) sin(θ)Coma, Quaternary (y-axis)36252R 10- 630R 8 + 560R 6 - 210R 4 + 30R 2 - 1Spherical Aberration, Quaternary37924R 12 - 2772R 10 + 3150R 8 - 1680R 6 + 420R 4 - 42R 2 + 1Table 2 FRINGE Zernike polynomials (ZFR) (con’t.)Term FRINGE Zernike polynomialAberration TypeZernike PolynomialsTechnical NotesTechnical Notes Using Zernike polynomials as a set of basis functions to fit wavefronts, surface shapes,etc.It is well known that Zernike polynomials form an orthogonal set of basis functions over the unit circle. The orthogonal character of these polynomials over the unit circle implies that, for a function defined over the unit circle, the coefficients in the Zernike approximation of that function are unique. An equally important consequence of orthogonality is that these coefficients do not change as the number of terms included in the fitting process is changed. While this is a desirable property, and is one of the main reasons for the popularity of the Zernike polynomials in optical applications, it is important to point out that it does not imply that Zernike polynomials are inadequate basis functions for approximating wavefronts, surface shapes etc. over non-circular regions. A one-dimensional example is helpful in understanding the role of orthogonality in fitting a function:If one considers the functionover the closed interval [0,1], it is clear that one can use the monomial terms for n=0 through 4 as a set to fit the function F(x). However, these monomial terms do not form an orthogonal set. As a specific example, consider the case where only the odd terms of F(x) is given by:If this function is fit with just the linear term, using a least-squares fitting procedure, then the linearapproximating polynomial is:and the quadratic approximating polynomial is:If the polynomial is fit with a cubic polynomial, then it is obvious that it can be fit exactly with the linear coefficient being 1.0, and the cubic coefficient being -0.5. This example clearly shows that the lack oforthogonality causes the coefficients to change as the number of terms in the fitting process is changed. The plot below shows the function and the linear and quadratic approximations.Figure 2 Use of monomials as basis functions over the interval [0,1].F x ()ax 4bx 3cx 2dx e++++=F x ()x 0.5x 3–=L x ()0.6970x=Q x () 1.20198x 0.66996x 2–=Zernike PolynomialsTechnical NotesDespite the lack of orthogonality of these monomial terms over the [0,1] interval, the quadratic approximation is a reasonably good fit to the exact function. However, the lack of orthogonality leads to strong coupling between the coefficient values when the number of terms in the expansion is not sufficient to represent the underlying function perfectly.1 As this example shows, in order to uniquely specify a fit with Zernike terms over a non-circular region, it is necessary to specify both the coefficient values in the expansion and the number of terms in the expansion. As a practical matter, when one is performing a fit using a subset of the Zernike polynomials, it is important to include enough terms of high order so that the error in the fit is small. For most aperture shapes that are compact,2 when the number of terms needed to accurately represent the function is reached, the coefficients, particularly the lower order ones, will be reasonably stable as additional terms are added. That is, if the function is well-approximated then, as a practical matter, the coefficients can be considered to be unique, and one of the major benefits of the orthogonality of the Zernike polynomials is obtained.A final point to make is that the orthogonality of the Zernike polynomials may appear not to be maintainedwhen the continuous integrals that need to be evaluated when fitting a function are approximated by discrete sums. That is, using a discrete set of sample points and a quadrature scheme within the unit circle toapproximate continuous integrals can lead to similar kinds of interactions between the Zernike coefficients as occurs with non-circular pupils. This effect can be reduced to a point where it becomes insignificant by including enough properly distributed sampling points within the unit circle. However, when the number of sample points is insufficient to provide a good approximation of the continuous integral that defines the inner product, the process of fitting a wavefront over a circular pupil with Zernike polynomials does not result in stable coefficient computations.Using Zernike Polynomials to approximate wavefrontsAs mentioned in the previous section, Zernike polynomials are an excellent choice as basis functions for representing functions (e.g. wavefronts). In all cases in which a function is fit with Zernike polynomials, CODE V uses a least-squares fitting procedure to determine the value of the coefficients. These polynomials can be used to accurately fit most continuous wavefronts over circular, square, elliptical and other regions that are compact. It is important to understand that the least-squares fitting procedure will produce a fit thatminimizes the error between the Zernike approximation and the true function over the sample points used in the fitting process . In all cases in which a Zernike fit is performed, CODE V provides the user with theresidual fit error. This number indicates how well the Zernike polynomial is able to approximate the function over the data set that was used in the fit.One potential problem with using Zernike polynomials as approximating functions is due to the fact that they can be evaluated over the entire X-Y plane. If a function which is defined over some region is fit to a set of Zernike polynomials by performing a least-squares fit over some subregion, it may not accurately represent the function over the full region. When the polynomial is evaluated outside of the subregion, it may be a poor approximation to the function.A perfect illustration of this issue can be seen if we consider the one-dimensional example discussed in the previous section. If we consider the quadratic approximation to the function , we see that it is a reasonably good approximation of the function over the region [0,1] where the fit was performed. However, if we now look at the function over an extended region, [-0.5,1] we see that the approximation is quite poor.1.This example is a bit extreme in the sense that the interaction of the individual monomial terms is particularly strong over the [0,1] interval. For example, had the interval [-1,1] been used instead, we would see no coupling between the odd andeven terms.2.In this context, the term compact aperture is defined as an aperture that does not contain substantial voids within the smallest circle that contains all regions of the clear aperture. For example, a thin annular aperture would not fit this definition of a compact aperture, but an aperture for a “mildly” obscured system would fit this definition. In a loose sense, one can consider the ratio of the square of the perimeter of the aperture to the area of the aperture as an indicator of how compact the aperture is. For circles, this ratio is 4, while for squares, it is 16. For such regions, Zernike polynomials are not generally orthogonal, but do not have strong coupling between the individual terms.F x ()x 0.5x 3–=Zernike PolynomialsTechnical NotesFigure 3 Use of approximating polynomial outside the interval over which the fit was determined.Thus, we see the importance of making sure that a Zernike is used to represent a wavefront, surface etc, only over a region where it was properly fit. Any reliance on the approximating polynomial outside of that region should be avoided.Zernike Polynomials Technical Notes。

CodeWarrior中建立新项目

CodeWarrior中建立新项目

CodeWarrior中建立新项目
1.运行CodeWarrior(CW)集成开发平台
2.选择第一个“create new project”新建一个工程,弹出以下窗口:
3.选择芯片型号MC9S12DG128,然后在右边选择TBDML,即用BDM来载入程序:
4.点击“下一步”,如下图:
在这个窗口来选择编程的语言,一般常用C语言,所以不用改。

在右边选择工程的名字和工程的建立地方。

5.完成了上面的操作就可以直接点“完成”:就会弹出:
6.在左边的:双击main.c就可以编程。

①在左边的“”中添加FREESCALE.h和FREESCALE.c
②回到CW中,在main.c中,在
#include <hidef.h>
#include "derivative.h"
后面加上#include “FREESCALE.h”//””代表在当前工程文件夹中寻找
#include <mc9s12dg128.h> //<>表的芯片头文件,在头文件库中找
7.其中“”图标为编译。

而点击“”图标就是向开发板载入程序,点击
后有如图:。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

CodeWarrior 10.2简明手册CodeWarrior 10.2简明手册 (1)1 下载安装CW v10.2 (1)2 安装BDM驱动 (2)3 导入现有工程 (3)4 编译、下载源码工程 (4)5. 带有操作系统程序的编译、下载 (6)5.1 带有操作系统模板程序的打开 (6)5.2 带有操作系统模板程序的编译 (7)5.3 带有操作系统模板程序的下载 (7)6 CodeWarrior 10.2常用操作 (8)7 常见问题说明 (9)基于Eclipse的CodeWarrior Development Studio for Microcontroller v10.2(简称CW10.2)作为一个完整的集成开发环境,提供了高度可视化操作及自动创建复杂嵌入式系统应用的功能,为使用Freescale嵌入式产品开发提供了便利。

官方推荐使用CW v10.2进行Freecale Kinetis嵌入式产品的开发。

本文将对使用CW v10.2开发K60项目的操作进行简要说明。

本文安装的cw10.2 版本是特别版的,支持128KB的代码大小。

用户若需要更大的代码空间和更多的功能的话,则需要向飞思卡尔申请license,这些license都是要收费的。

1 下载安装CW v10.2飞思卡尔半导体为注册用户在其官方网站的网址链接处下载后,双击可执行安装文件,如图1所示,根据提示即可完成安装。

由于有的CW10.2版本安装完成后默认是中文版的,有的默认是英文版的。

集成开发环境的原版是英文版的,所以英文版的运行速度比中文版的快很多。

这里建议用英文版的CW10.2,不建议用户使用中文版集成开发环境,所以本章介绍的使用说明都是基于英文版的。

想将飞思卡尔的CW10.2集成开发环境变成英文版,首先需要关闭当前的CW10.2,然后右击CW10.2桌面图标选择“属性”,在“目标”栏下“…”后面加上“–nl en”再单击“应用”后便改成英文版;加上“–nl zh”可以改2 安装BDM驱动CW_v10.2中已包含了BDM写入器(Open Source BDM,OSBDM)的驱动文件,将BDM接到PC机器时,Windows会提示发现新硬件:提示连接到“Windows Update”更新,选择“否,暂时不”,点击“下一步”。

提示系统自动安装向导,选择“自动安装软件”,点击“下一步”。

安装“PEMicro USB Serial Port”与安装“Open Source BDM”过程相同。

至此,BDM驱动安装过程结束。

3 导入现有工程在Windows XP下,选择“开始”->“所有程序”->“Freescale CodeWarrior”->“CW for MCU v10.2”->“CodeWarrior”启动CW10.2。

启动CW10.2时,提示选择工作空间,可使用默认。

选择“File”->“Import...”,出现导入文件对话框,选择“General”常规分组中的“Existing Projects into Workspace”,点击“Next”。

在“Brose…”导入项目对话框中,选中工程目录(即程序所在最里一层的根目录,例如D:\Ch03-PRG(GPIO-Light)\Ch03-GPIO(Light)\Light),在“Projects”面板中会出现IDE图3 导入项目对话框导入的过程中可能会提示4次关于添加远程系统引用的提示信息,这是关于BDM的引用声明,均点击“是”即可。

另外还有一种简单的方法,找到工程目录最里一层的工程文件夹,例如上例的“D:\Ch03-PRG(GPIO-Light)\Ch03-GPIO(Light)\Light)”文件,直接拖入CW10.2的代码编辑框内便可自动打开工程,一般使用此种方法打开工程较为简便。

4 编译、下载源码工程导入已有工程成功之后,重新对工程进行创建,可下载生成机器码文件下载到MCU 中。

菜单栏中选定“Project”->“Build Configrations”->“Set Active”->“MK60N512VMD100_INTERNEL_FLASH”,设定当前创建的是要写入到目标芯片Flash 的项目,如图4所示。

图4 设置当前活跃项目为写入Flash选择“Project”->“Clean...”,出现清理对话框,选择清理工程(例如“Ch03-GPIO(Light)”)。

同时,勾选“Clean projects selected below”,“Build only the selected project”,点击“OK”,由于编译环境从cw10.1变成了cw10.2,相应的写入器固件程序也得升级。

利用苏州大学“飞思卡尔Kinetis微控制器写入器”写程序时,若写入器不升级,将无法将程序写入芯片中,将出现图6所示的升级提示。

将苏州大学飞思卡尔Kinetis微控制器写入器上的J10两脚的短排针焊接上,并给它加上跳线帽(没有跳线帽和短排针用导线将两个引脚短接即可)。

重新插拔USB接口,点击图6提示对话框的“OK”按钮。

用户只需等待几分钟便可以升级完成。

完成后拔掉J10接口上的跳线帽,重新连接USB线供电,便可以写入程序了。

点击工具栏中的“下载”工具图选中“Flash File To Target”,出现编程下载对话框。

选择运行配置为“K60_MK60N512VMD100_INTERNEL_FLASH_PnE OSJTAG”;选择“Flash Configuration”为“MK60N512VMD100”其它选项不做修改。

选择“Workspace...”,从工程组织下选择“MK60N512VMD100_INTERNEL_FLASH”分组下“Source”的“xxx.afx”(或xxx.afx.s19、xxx.afx.hex任一亦可)文件,载入生成机器码文件。

选择“Erase and Program”,即可完成下载程序到MCU中,如图8所示。

图8 写入程序选项5. 带有操作系统程序的编译、下载5.1 带有操作系统模板程序的打开飞思卡尔实验室为用户设计了基于K60N512芯片的MQX的模板工程,下面讲解飞思卡尔MQX模板工程在CodeWarrior10.2集成开发环境下的打开、编译与下载过程。

首先将带有MQX程序的模板工程目录放在英文目录下。

注意CodeWarrior 10.2同CodeWarrior 10.1一样CodeWarrior 10.2的编译器只能编译英文目录下的工程,不然会出现编译错误,从而导致MQX模板工程不能通过编译。

模板工程的文件组织与Freescale MQX 3.8默认的安装目录下样例工程的结构类似,各目录的简要功能如图80-9所示。

MQX的BSP工程、PSP工程和APP工程(应用工程)在..\mqx_k60n512\mqx\build\cw10目录下,对带有操作系统的程序模板工程文件便是这3个文件,读者对模板工程程序的操作都只是针对这3个文件而言的。

MQX模板工程组织如图9所示。

带有操作系统程序的打开方法与不带操作系统的程序一样,具体参见第3节“导入现有工程”,可分为三个步骤。

第一步:将..\mqx\build\cw10\psp_sdk60n512下的PSP工程按照第3节中的方法拖入CodeWarrior 10.2中。

第二步:将..\mqx\build\cw10\bsp_sdk60n512下的BSP工程按照第3节中的方法拖入CodeWarrior 10.2中。

第三步:..\mqx\build\cw10\app_sdk60n512下的用户工程按照第3节中的方法拖入CodeWarrior 10.2中。

这样带有操作系统的程序便全部加载进CodeWarrior 10.2集成开发环境了,下面便是5.2 带有操作系统模板程序的编译编译的方法与第4节的方法一样,注意编译的顺序应该为PSP工程、BSP工程、APP 工程,先后顺序不能颠倒,不然很有可能出现编译错误的情况。

编译成功完后,BSP、PSP工程的编译生成文件将在“..\mqx_k60n512\lib”路径文件下。

APP工程生成的S19格式的文件将在APP工程自己的目录下“..\mqx_k60n512 \mqx\build\cw10\app_k60n512\twrk60n512_Int_Flash_Debug”文件夹下生成。

5.3 带有操作系统模板程序的下载将5.2节中最后编译APP工程生成的S19文件写进K60N512的芯片中,写入的方法如第4节相同。

至此带有操作系统模板程序的打开、编译、下载便全部完成了。

6 CodeWarrior 10.2常用操作1.查看函数、宏定义原型在利用CW10.2查看代码的过程中若想查看函数或者宏定义的原型,把光标定位到函数、宏定义上,单击右键点击“Open Declaration”或直接按“F3键”便可。

2.查找利用CW10.2集成开发环境在整个工程的所有文件中查找某个关键字,在菜单栏的“Search”下选择“Search”选项。

在跳出的Search对话框中的“Containing text”下输入搜索内容,在“File name patterns”下点击“choose”选择要在什么文件内查找搜索框内的字符(一般选.c和.c文件即可),最后单击“Search”按钮完成搜索。

如图10所示。

在搜索完成后再CW10.2运行界面的右边部分会出现搜索的结果,单击依次查询搜索3.在工程中添加文件与文件引用1)添加文件方法一:点击工程名单击右键现则“Add Files”,在对话框中找到要添加的文件选择“打开”按钮。

在单击“打开”按钮后,选择“Copy files”是将添加的文件复制到工程物理目录下。

选择“Link files”是将文件链接到工程内,添加的文件本身还在原来的物理路径下。

使用方法一时建设使用“Copy files”添加文件。

方法二:将要添加的文件复制到要放入的工程目录下,然后在CW10.2下,点击工程名,右击工程名点击“Refresh”,文件便会自动加进工程。

这里推荐使用第二种方法添加一个文件。

2)添加文件引用利用上述方法虽然将文件加进了工程,但CW 10.2并未将文件“引用”,需要添加工程应用,这样头文件见才能将其包含至工程。

在CW10.2下点击工程名,右击后点击“Properties”,在左边栏点击“C/C++ Build”下选择“Settings”。

在“Setting”右边的选项卡内选择“Tool Settings”下的“ARM Compiler”中的“Input”项,然后在“Include UserSearch Paths (-i)”单击选择“Workspace…”添加工程路径单击“OK”便可。

相关文档
最新文档