ENABLE

(Difference between revisions)
Jump to: navigation, search
(Created page with "= <span class="f_Header">Action</span> = Enable specified interrupt. <span style="font-family: Arial;"> </span> <span style="font-family: Arial;"> </span> = <spa...")
 
Line 3: Line 3:
 
Enable specified interrupt.
 
Enable specified interrupt.
  
<span style="font-family: Arial;">&nbsp;</span>
+
<span style="font-family: Arial;">(ATTINY, ATMEGA, ATXMEGA)</span>
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 12: Line 12:
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
 +
 +
[, prio] is only for ATXMEGA
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 182: Line 184:
 
It depends on the processor how many and which interrupts it has. If you type ENABLE in the editor, you will get a pop up with a list of interrupts you can chose from.
 
It depends on the processor how many and which interrupts it has. If you type ENABLE in the editor, you will get a pop up with a list of interrupts you can chose from.
  
<span style="font-family: Arial;">&nbsp;</span>
+
&nbsp;
  
= <span class="f_Header">XMEGA</span> =
+
= <span class="f_Header">ATTINY & ATMEGA Interrupt List</span> =
  
 
In normal AVR chips the priority is determined by the interrupts address. The lower the address, the higher the priority.
 
In normal AVR chips the priority is determined by the interrupts address. The lower the address, the higher the priority.
Line 196: Line 198:
 
&nbsp;
 
&nbsp;
  
[INTLIST]
+
<span style="font-weight: bold;">[INTLIST]</span>
  
count=56
+
<span class="f_CodeExample">count=56</span>
  
INTname1=INT0,$002,EIMSK.INT0,EIFR.INTF0
+
<span class="f_CodeExample">INTname1=</span><span class="f_CodeExample">INT0</span><span class="f_CodeExample">,$002,EIMSK.INT0,EIFR.INTF0</span>
  
INTname2=INT1,$004,EIMSK.INT1,EIFR.INTF1
+
<span class="f_CodeExample">INTname2=INT1,$004,EIMSK.INT1,EIFR.INTF1</span>
  
INTname3=INT2,$006,EIMSK.INT2,EIFR.INTF2
+
<span class="f_CodeExample">INTname3=INT2,$006,EIMSK.INT2,EIFR.INTF2</span>
  
INTname4=INT3,$008,EIMSK.INT3,EIFR.INTF3
+
<span class="f_CodeExample">INTname4=INT3,$008,EIMSK.INT3,EIFR.INTF3</span>
  
INTname5=INT4,$00a,EIMSK.INT4,EIFR.INTF4
+
<span class="f_CodeExample">INTname5=INT4,$00a,EIMSK.INT4,EIFR.INTF4</span>
  
INTname6=INT5,$00c,EIMSK.INT5,EIFR.INTF5
+
<span class="f_CodeExample">INTname6=INT5,$00c,EIMSK.INT5,EIFR.INTF5</span>
  
 
&nbsp;
 
&nbsp;
Line 218: Line 220:
 
&nbsp;
 
&nbsp;
  
The XMEGA has a priority system. You can specify if an interrupt as a low, medium or high priority.
+
Following an Overview where&nbsp;<span style="font-weight: bold; color: rgb(255, 0, 0);">INT0</span>&nbsp;is used as an example.
  
But you MUST enable these priorities &nbsp;with&nbsp;[[CONFIG_PRIORITY|CONFIG PRIORITY]]
+
&nbsp;
  
If you use LO and MED priority, they have to be enabled.
+
= <span class="f_Header">Overview</span> =
 +
 
 +
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
 +
 
 +
1. You configure an Interrupt
 +
 
 +
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">On</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Int0</span><span style="font-family: 'Courier New';">&nbsp;Int0_isr &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Int0</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Low</span><span style="font-family: 'Courier New';">&nbsp;Level</span>
 +
 
 +
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
 +
 
 +
2. You enable the specific Interrupt
 +
 
 +
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Int0</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
 +
 
 +
3. Enable all Interrupts
 +
 
 +
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-family: 'Courier New';">&nbsp;</span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Interrupts</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/>4. You have an Interrupt Service Routine after the<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">&nbsp;"End"&nbsp;</span>with an<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">&nbsp;Return</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
 +
 
 +
<span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span>
 +
 
 +
<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">&nbsp;</span>
 +
 
 +
<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Interrupt Service Routine</span><br/><span style="font-size: 8pt; font-family: Courier;">Int0_isr</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">:</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' so someting.....</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Return</span>
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
 +
 +
&nbsp;
 +
 +
= <span class="f_Header">XMEGA</span> =
 +
 +
&nbsp;
 +
 +
The XMEGA has a priority system. You can specify if an interrupt has a low, medium or high priority.
 +
 +
But you MUST enable these priorities &nbsp;with&nbsp;[[CONFIG PRIORITY|CONFIG PRIORITY]]
 +
 +
&nbsp;
 +
 +
<span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Priority</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;Static&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;Vector&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;Application&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;Lo&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;Enabled&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;Med&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;Enabled&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;Hi&nbsp;</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;">&nbsp;Enabled</span>
 +
 +
<span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
 +
 +
If you use LO or High priority, they have to be enabled.
 +
 +
<span style="color: rgb(255, 0, 0);">If you do not specify a priority,&nbsp;</span><span style="font-weight: bold; color: rgb(255, 0, 0);">MED</span><span style="color: rgb(255, 0, 0);">&nbsp;will be used.</span>
 +
 +
&nbsp;
 +
 +
In the DAT file you can find a list with interrupts and their address.
 +
 +
For example , taken from the "xm128A4Udef.dat file "
 +
 +
&nbsp;
 +
 +
<span class="f_CodeExample">INTLIST]</span>
 +
 +
<span class="f_CodeExample">count=95</span>
 +
 +
<span class="f_CodeExample">INTname1=OSCFAIL,$0002,OSC_XOSCFAIL.0,OSC_XOSCFAIL.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;&nbsp;XOSC&nbsp;Failure&nbsp;Detection&nbsp;Register</span>
 +
 +
<span class="f_CodeExample">INTname2=</span><span class="f_CodeExample">PORTC_INT0</span><span class="f_CodeExample">,$0004,#PORTC_INTCTRL.0,PORTC_INTFLAGS.0</span>
 +
 +
<span class="f_CodeExample">INTname3=PORTC_INT1,$0006,#PORTC_INTCTRL.2,PORTC_INTFLAGS.1</span>
 +
 +
<span class="f_CodeExample">INTname4=PORTR_INT0,$0008,#PORTR_INTCTRL.0,PORTR_INTFLAGS.0</span>
 +
 +
<span class="f_CodeExample">INTname5=PORTR_INT1,$000A,#PORTR_INTCTRL.2,PORTR_INTFLAGS.1</span>
 +
 +
<span class="f_CodeExample">INTname6=DMA_CH0,$000C,#,DMA_CH0_CTRLB.0,DMA_CH0_CTRLB.4</span>
 +
 +
<span class="f_CodeExample">INTname7=DMA_CH1,$000E,#,DMA_CH1_CTRLB.0,DMA_CH1_CTRLB.4</span>
 +
 +
<span class="f_CodeExample">INTname8=DMA_CH2,$0010,#,DMA_CH2_CTRLB.0,DMA_CH2_CTRLB.4</span>
 +
 +
<span class="f_CodeExample">INTname9=DMA_CH3,$0012,#,DMA_CH3_CTRLB.0,DMA_CH3_CTRLB.4</span>
 +
 +
<span class="f_CodeExample">INTname10=RTC_OVF,$0014,#RTC_INTCTRL.0,RTC_INTFLAGS.0</span>
 +
 +
<span class="f_CodeExample">INTname11=RTC_COMP,$0016,#RTC_INTCTRL.2,RTC_INTFLAGS.1</span>
 +
 +
<span style="font-family: Arial;">&nbsp;</span>
 +
 +
<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">&nbsp;</span>
 +
 +
Example with<span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">&nbsp;</span><span style="font-weight: bold; color: rgb(255, 0, 0);">PORTC_INT0</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span><br/><span class="f_CodeExample">On Portc_int0 portc_isr</span><br/><span class="f_CodeExample">Enable Portc_int0 , Hi</span><br/><span style="font-size: 8pt; font-family: Courier;">&nbsp;</span>
 +
 +
&nbsp;
 +
 +
In&nbsp;[[ATXMEGA]]&nbsp;there is an example for Pin Interrupt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 230: Line 318:
 
= <span class="f_Header">See also</span> =
 
= <span class="f_Header">See also</span> =
  
[[DISABLE]]&nbsp;,&nbsp;[[ON INTERRUPT|ON]]&nbsp;,&nbsp;[[CONFIG PRIORITY|CONFIG PRIORITY]]
+
[[DISABLE]]&nbsp;,&nbsp;[[ON INTERRUPT|ON]]&nbsp;,&nbsp;[[CONFIG PRIORITY|CONFIG PRIORITY]],&nbsp;[[ATXMEGA]]
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 236: Line 324:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Partial Example</span> =
+
= <span class="f_Header">Example</span> =
  
<br/><source lang="bascomavr">
+
<source lang="bascomavr">
Enable Interrupts 'allow interrupts to be set
+
$regfile = "attiny25.dat"
Enable Timer1 'enables the TIMER1 interrupt
+
$crystal = 1000000 ' 1MHz
 +
$hwstack = 10
 +
$swstack = 0
 +
$framesize = 24
 +
 +
 +
On Int0 Int0_isr ' INT0 will be the wake-up source for Powerdown Mode
 +
Config Int0 = Low Level ' External Pull-up (47K) on Portb.2
 +
Enable Int0
 +
 +
'###############################################################################
 +
Do
 +
Wait 3 ' now we have 3 second to measure the Supply Current in Active Mode
 +
 +
Enable Interrupts
 +
 +
' Now call Powerdown function
 +
Config Powermode = Powerdown
 +
 +
'Here you have time to measure PowerDown current consumption until a Low Level on Portb.1 which is the PowerDown wake-up
 +
Loop
 +
'###############################################################################
 +
End
 +
 +
 +
Int0_isr:
 +
' wake_up
 +
Return
 
</source><br/>{{Languages}}
 
</source><br/>{{Languages}}
  
 
[[Category:BASCOM Language Reference]]
 
[[Category:BASCOM Language Reference]]

Revision as of 21:07, 24 August 2013

Contents

Action

Enable specified interrupt.

(ATTINY, ATMEGA, ATXMEGA)

 

Syntax

ENABLE interrupt [, prio]

 

[, prio] is only for ATXMEGA

 

Remarks

Interrupt

Description

INT0

External Interrupt 0

INT1

External Interrupt 1

OVF0,TIMER0, COUNTER0

TIMER0 overflow interrupt

OVF1,TIMER1,

 

COUNTER1

TIMER1 overflow interrupt

CAPTURE1, ICP1

INPUT CAPTURE TIMER1 interrupt

COMPARE1A,OC1A or

 

COMPARE1, OC1

TIMER1 OUTPUT COMPARE A interrupt

 

In case of only one compare interrupt

COMPARE1B,OC1B

TIMER1 OUTPUT COMPARE B interrupt

SPI

SPI interrupt

URXC

Serial RX complete interrupt

UDRE

Serial data register empty interrupt

UTXC

Serial TX complete interrupt

SERIAL

Disables URXC, UDRE and UTXC

ACI

Analog comparator interrupt

ADC

A/D converter interrupt



XMEGA ONLY


prio

The priority you want to assign to the interrupt.

Specify Lo, Hi or Med.

In the Xmega you must provide the priority of the interrupts. Lo=Low priority. Hi=High priority and Med=Medium priority.

If you do not specify a priority, MED will be used.

 

By default all interrupts are disabled.

The global interrupts master switch is also disabled by default.

If you enable an interrupt, it will only fire if the master interrupt switch is enabled.

You enable this master switch with ENABLE INTERRUPTS.

You can disable it with DISABLE INTERRUPTS.

 

If an interrupt is executed, the global master switch will be disabled automatically by the hardware.

This is to prevent other interrupts to occur.

When the interrupt routine returns, the processor hardware will automatically enable the master switch so new interrupts may occur.

 

It depends on the processor how many and which interrupts it has. If you type ENABLE in the editor, you will get a pop up with a list of interrupts you can chose from.

 

ATTINY & ATMEGA Interrupt List

In normal AVR chips the priority is determined by the interrupts address. The lower the address, the higher the priority.

In the DAT file you can find a list with interrupts and their address.

For example , taken from the m1280def.dat file "

 

 

[INTLIST]

count=56

INTname1=INT0,$002,EIMSK.INT0,EIFR.INTF0

INTname2=INT1,$004,EIMSK.INT1,EIFR.INTF1

INTname3=INT2,$006,EIMSK.INT2,EIFR.INTF2

INTname4=INT3,$008,EIMSK.INT3,EIFR.INTF3

INTname5=INT4,$00a,EIMSK.INT4,EIFR.INTF4

INTname6=INT5,$00c,EIMSK.INT5,EIFR.INTF5

 

INT0 has the highest priority since it has the lowest address (address 2)

 

Following an Overview where INT0 is used as an example.

 

Overview

 

1. You configure an Interrupt

 
On Int0 Int0_isr                                           
Config Int0 = Low Level

 

2. You enable the specific Interrupt

 
Enable Int0
 

3. Enable all Interrupts

 
Enable Interrupts
 
 
4. You have an Interrupt Service Routine after the "End" with an Return
 

End

 

' Interrupt Service Routine
Int0_isr:
' so someting.....
Return

 

 

XMEGA

 

The XMEGA has a priority system. You can specify if an interrupt has a low, medium or high priority.

But you MUST enable these priorities  with CONFIG PRIORITY

 

Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled , Hi = Enabled

 

If you use LO or High priority, they have to be enabled.

If you do not specify a priority, MED will be used.

 

In the DAT file you can find a list with interrupts and their address.

For example , taken from the "xm128A4Udef.dat file "

 

INTLIST]

count=95

INTname1=OSCFAIL,$0002,OSC_XOSCFAIL.0,OSC_XOSCFAIL.1        ; XOSC Failure Detection Register

INTname2=PORTC_INT0,$0004,#PORTC_INTCTRL.0,PORTC_INTFLAGS.0

INTname3=PORTC_INT1,$0006,#PORTC_INTCTRL.2,PORTC_INTFLAGS.1

INTname4=PORTR_INT0,$0008,#PORTR_INTCTRL.0,PORTR_INTFLAGS.0

INTname5=PORTR_INT1,$000A,#PORTR_INTCTRL.2,PORTR_INTFLAGS.1

INTname6=DMA_CH0,$000C,#,DMA_CH0_CTRLB.0,DMA_CH0_CTRLB.4

INTname7=DMA_CH1,$000E,#,DMA_CH1_CTRLB.0,DMA_CH1_CTRLB.4

INTname8=DMA_CH2,$0010,#,DMA_CH2_CTRLB.0,DMA_CH2_CTRLB.4

INTname9=DMA_CH3,$0012,#,DMA_CH3_CTRLB.0,DMA_CH3_CTRLB.4

INTname10=RTC_OVF,$0014,#RTC_INTCTRL.0,RTC_INTFLAGS.0

INTname11=RTC_COMP,$0016,#RTC_INTCTRL.2,RTC_INTFLAGS.1

 

 

Example with PORTC_INT0
 
On Portc_int0 portc_isr
Enable Portc_int0 , Hi
 

 

In ATXMEGA there is an example for Pin Interrupt.

 

See also

DISABLE , ON , CONFIG PRIORITYATXMEGA

 

 

Example

$regfile = "attiny25.dat"
$crystal = 1000000 ' 1MHz
$hwstack = 10
$swstack = 0
$framesize = 24
 
 
On Int0 Int0_isr ' INT0 will be the wake-up source for Powerdown Mode
Config Int0 = Low Level ' External Pull-up (47K) on Portb.2
Enable Int0
 
'###############################################################################
Do
 Wait 3 ' now we have 3 second to measure the Supply Current in Active Mode
 
 Enable Interrupts
 
 ' Now call Powerdown function
 Config Powermode = Powerdown
 
 'Here you have time to measure PowerDown current consumption until a Low Level on Portb.1 which is the PowerDown wake-up
Loop
'###############################################################################
End
 
 
Int0_isr:
' wake_up
Return

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language