11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PreprocessingC Language Features36 psect text37 0002 _read_port:Look above this to see the first PSECT directive you encounter. This will indicate thename of the psect in which the code is located. In this case it is the psect called text.So let us redirect this psect into one with a unique and more meaningful name. In the Cmodule that contains the definition for read_port() place the following pragma:#pragma psect text=readportat the top of the module, before the function definition. With this, the read_port()function will be placed in the psect called readport. Confirm this in the new assemblylist file.Now we can tell the linker where we would like this psect positioned. Issue an additionaloption to the command-line driver to place this psect at address 0x400.-L-preadport=0400hThe generate an check the map file, see Section 2.4.9. You should see the additionallinker command (minus the leading -L part of the option) present in the section afterLinker command line:. You should also see the remapped psect name appear in thesource file list of psects, e.g.:Name Link Load Length Selector Space Scale/tmp/cgt9e31jr.objmain.obj maintext 0 0 2 0 0portread 400 400 2 800 0Check the link address to ensure it is that requested, inthis case, 0x400.3.12.3.6 The #pragma regsused DirectiveHI-TECH C will automatically save context when an interrupt occurs. The compiler will determineonly those registers and objects which need to be saved for the particular interrupt function defined.The #pragma regsused directive allows the programmer to indicate register usage for functionsthat will not be “seen” by the code generator, for example if they were written in assembly code.The general form of the pragma is:60#pragma regsused routine_name register_list

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!