17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

parts. See the devices .h file for all valid interrupts for the part or in PCW use the pull<br />

down VIEW | Valid Ints<br />

The compiler will generate code to jump to the function when the interrupt is<br />

detected. It will generate code to save and restore the machine state, and will clear the<br />

interrupt flag. To prevent the flag from being cleared add NOCLEAR after the<br />

#INT_xxxx. The application program must call ENABLE_INTERRUPTS(INT_xxxx) to<br />

initially activate the interrupt along with the ENABLE_INTERRUPTS(GLOBAL) to<br />

enable interrupts.<br />

The keywords HIGH and FAST may be used with the <strong>PCH</strong> compiler to mark an interrupt<br />

as high priority. A high-priority interrupt can interrupt another interrupt handler. An<br />

interrupt marked FAST is performed without saving or restoring any registers. You<br />

should do as little as possible and save any registers that need to be saved on your<br />

own. Interrupts marked HIGH can be used normally. See #DEVICE for information on<br />

building with high-priority interrupts.<br />

A summary of the different kinds of PIC18 interrupts:<br />

#INT_xxxx<br />

Normal (low priority) interrupt. <strong>Compiler</strong> saves/restores key registers.<br />

This interrupt will not interrupt any interrupt in progress.<br />

#INT_xxxx FAST<br />

High priority interrupt. <strong>Compiler</strong> DOES NOT save/restore key registers.<br />

This interrupt will interrupt any normal interrupt in progress.<br />

Only one is allowed in a program.<br />

#INT_xxxx HIGH<br />

High priority interrupt. <strong>Compiler</strong> saves/restores key registers.<br />

This interrupt will interrupt any normal interrupt in progress.<br />

#INT_xxxx NOCLEAR<br />

The compiler will not clear the interrupt.<br />

The user code in the function should call clear_interrput( ) to<br />

clear the interrupt in this case.<br />

#INT_GLOBAL<br />

<strong>Compiler</strong> generates no interrupt code. User function is located<br />

at address 8 for user interrupt handling.<br />

Some interrupts shown in the devices header file are only for the enable/disable<br />

interrupts. For example, INT_RB3 may be used in enable/interrupts to enable pin B3.<br />

However, the interrupt handler is #INT_RB.<br />

Similarly INT_EXT_L2H sets the interrupt edge to falling and the handler is #INT_EXT.<br />

Examples:<br />

#int_ad<br />

adc_handler() {<br />

adc_active=FALSE;<br />

}<br />

#int_rtcc noclear<br />

isr() {<br />

...<br />

}<br />

Example<br />

See ex_sisr.c and ex_stwt.c for full example programs.<br />

114

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

Saved successfully!

Ooh no, something went wrong!