13.07.2015 Views

TASKING VX-toolset for 8051 User Guide

TASKING VX-toolset for 8051 User Guide

TASKING VX-toolset for 8051 User Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

<strong>TASKING</strong> <strong>VX</strong>-<strong>toolset</strong> <strong>for</strong> <strong>8051</strong> <strong>User</strong> <strong>Guide</strong>Using pragmas: inline, noinline, smartinlineInstead of the inline qualifier, you can also use #pragma inline and #pragma noinline to inlinea function body:#pragma inlineunsigned int abs(int val){unsigned int abs_val = val;if (val < 0) abs_val = -val;return abs_val;}#pragma noinlinevoid main( void ){int i;i = abs(-1);}If a function has an inline/__noinline function qualifier, then this qualifier will overrule the currentpragma setting.With the #pragma noinline / #pragma smartinline you can temporarily disable the default behaviorthat the C compiler automatically inlines small functions when you turn on the C compiler option--optimize=+inline.1.10.5. Interrupt FunctionsThe <strong>TASKING</strong> C compiler supports a number of function qualifiers and keywords to program interruptservice routines (ISR). An interrupt service routine (or: interrupt function, interrupt handler, exceptionhandler) is called when an interrupt event (or: service request) occurs.The difference between a normal function and an interrupt function is that an interrupt function ends witha RETI instruction instead of a RET instruction, and that all registers that might possibly be corruptedduring the execution of the interrupt function are saved on function entry (this is called the interrupt frame)and restored on function exit.1.10.5.1. Defining an Interrupt Service Routine: __isr, __interrupt()You can use the type qualifier __isr to declare a function as an interrupt service routine, but this doesnot bind the function to an interrupt vector. With the function qualifier __interrupt() you can bind thefunction to a specific vector. The function qualifier __interrupt() takes one or more vector addressesas argument(s). All supplied vector addresses will be initialized to point to the interrupt function.The __interrupt() function qualifier implies the __isr type qualifier.Interrupt functions cannot return anything and must have a void argument type list:void __interrupt(vector_address[, vector_address]...)isr( void ){38

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

Saved successfully!

Ooh no, something went wrong!