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.

C Language FeaturesMixing C and Assembler CodeTable 3.7: Interrupt Vector Address MacrosMacro name Vector address DescriptionFLTA_VCTR 0x6A PWM Fault AFLTB_VCTR 0x6C PWM Fault B3.10.1.1 Context Saving on InterruptsHI-TECH <strong>dsPIC</strong>C automatically generates code to save context when an interrupt occurs. This codewill be executed before the code generated from the C interrupt function is entered.Only those registers which are used by the interrupt function are saved.If called functions have not been “seen” by the compiler, a worst case scenario is assumed andall registers not preserved by function calls will be saved.HI-TECH C does not scan assembly code which is placed in-line within the interrupt functionfor register usage. Thus, if you include in-line assembly code into an interrupt function, you mayhave to add extra assembly code to save and restore any registers or locations used if they are notalready saved by the interrupt entry routine.3.10.1.2 Context RestorationAny objects saved by the compiler are automatically restored before the interrupt function returns.A retfie instruction placed at the end of the interrupt code which will reload the program counterand re-enable the master interrupt bit. The program will return to the location at which it was whenthe interrupt occurred.3.10.2 Enabling InterruptsHardware interrupt sources can be enabled and disabled using macros defined in . Themacros are called DI(), and EI() which enable and disable interrupts respectively. Also providedis DISI(n)which will disable interrupts for the given number of cycles plus one. Its parameter mustbe a literal constant.3.11 Mixing C and Assembler CodeAssembly language code can be mixed with C code using two different techniques: writing assemblycoe and placing it into a separate assembler module, or including it as in-line assembler in a Cmodule. For the latter, there are two formats in which this can be done.49

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

Saved successfully!

Ooh no, something went wrong!