Difference between revisions of "Interrupt Icon Properties"

From Flowcode Help
Jump to navigationJump to search
(Created page with " '''<img>''' '''<img>''' '''Introduction to Interrupts''' Interrupts are called to react to an event such as an external stimulus, or a timing event. When an interrupt i...")
 
Line 84: Line 84:
  
 
*Internal clock (CLK0)
 
*Internal clock (CLK0)
 +
 
*Transition on T0CKI
 
*Transition on T0CKI
  
Source edge select
+
'''Source edge select'''
 +
 
 
Select the transition edge used for clock signal timing.
 
Select the transition edge used for clock signal timing.
High-to-low transition on T0CKI
+
 
Low-to-high transition on T0CKI
+
*High-to-low transition on T0CKI
 +
*Low-to-high transition on T0CKI
  
 
Prescaler rate
 
Prescaler rate

Revision as of 08:48, 16 May 2013


<img>


<img>


Introduction to Interrupts

Interrupts are called to react to an event such as an external stimulus, or a timing event. When an interrupt is activated it executes a Macro. The macro to be called is specified by the user when creating the interrupt.

The number and types of interrupts available are dependent on the device used. Some devices have a number of interrupts whereas other devices may only have a few.

The exact details, properties and operation of an interrupt vary from interrupt to interrupt. Users will need to refer to the interrupt dialogs for exact details of any particular Interrupt. However there are four main types that Flowcode uses:

  • TMR<X>- overflow - reacts to the clocked overflow event
  • INT - reacts to an input on an external interrupt pin.
  • Port change -reacts to any change in a specified collection of inputs
  • Custom - defines a custom interrupt procedure.


Other interrupts may be available depending on the target chip, such as the "Receive" interrupt for chips with a UART available.


Details of the various interrupts can be found below, along with example of available properties.


Creating an interrupt

<img>


Add an Interrupt icon to the program.

Select Enable Interrupt or Disable Interrupt to turn the interrupt on or off respectively.


Select the desired interrupt from the drop down list of interrupts available from that particular device.

Set the properties for that event.

Set the macro to call, or create a new macro.


Interrupt properties

<img>


TMR<X> Timer overflow Interrupt (e.g. TMR0 overflow)


Interrupts when the Timer overflows. A count is made internally based on Clock inputs and the pre-scaler property (see below for details). When the count reaches a certain point it overflows back to 0 triggering an Overflow event. This event can then be used to call a macro. Timer overflow interrupts are called repeatedly at the Interrupt time interval making them very useful for time based events, or for frequently needed features such as display updates.


Note: Check that the clock speed setting is correct (via the Project Options) as clock speed affects timer interrupt frequency settings.


The exact properties available for a timer interrupt are device and timer dependent. As such the timer overflow dialogs may vary from device to device and from timer to timer. The example below is intended to give an idea of the kind of properties available for a Timer overflow interrupt.

Specific details can be found in the Interrupt dialogs, and from Device datasheets.

TMR1 on the 16F877A, for instance, has a smaller set of pre-scaler options than the TMR0 interrupt, and also no source edge settings available unlike the TMR0 interrupt.


The TMR2 interrupt has an additional setting called the rollover value. This changes the rollover value in the timer register that is responsible for triggering the interrupt which allows for much better control over interrupt frequency. This advanced timeout functionality can be replicated with the other timers by writing to the timer count registers directly using C code.


Note: Certain Flowcode components such as the PWM and Servo consume some of the timer peripherals. For details on the hardware consumed by a component please refer to the specific component help file.


Example of TMR0 properties:


Clock source select Select the clock source signal to use for the overflow timing.

Options available are device dependent.

Examples:

  • Internal clock (CLK0)
  • Transition on T0CKI

Source edge select

Select the transition edge used for clock signal timing.

  • High-to-low transition on T0CKI
  • Low-to-high transition on T0CKI

Prescaler rate Select a pre-scaler rate for the clock signal. A prescaler divides down the clock signals used for the timer giving reduced overflow rates. The rate can be set to a number of possible values. The exact values are chip dependent. E.g. for the PIC16F877A values area a number of values are available ranging from 1:1 to 1:256.

The prescaler value is used in conjunction with the clock speed to set an overflow frequency. E.g. Clock speed:- 19660800 Prescale value:- 1:256 Interrupt frequency 75Hz Clock speed:- 19660800 Prescale value:- 1:64 Interrupt frequency 300Hz


INT Triggered when an external stimulus is used on an external interrupt (INT) pin (e.g. a Button press)

The interrupt can be set to trigger on the: Falling edge of INT Rising edge of INT

INT interrupts can be useful in setting interrupts to occur on signal on or signal off events, such as an emergency shut off switch.


Port change Interrupts when an input signal occurs on any of a selected group of port inputs.

The Port change interrupt may have properties allowing the interrupt I/O pins to be enabled or disabled as interrupt pins.

Custom The Custom option allows the creation of custom interrupt code.

Many of the chips available in Flowcode support hardware driven interrupts that are not provided in the standard set of Flowcode interrupts. To allow users to add their own interrupts to suit their application Flowcode has the option to add your own custom interrupt.

Interrupt Property page


Custom Interrupt property page


Click here for help using the PICmicro custom interrupts. Click here for help using the AVR custom interrupts. Click here for help using the ARM custom interrupts. Click here for help using the dsPIC/PIC24 custom interrupts.