Difference between revisions of "Custom Interrupts - ARM"
Line 2: | Line 2: | ||
− | <font style="color:#FF0000"> '''Target AVR Processor ( ATMEGA8, 16, 32 ) | + | <font style="color:#FF0000"> '''Target AVR Processor''' ( ATMEGA8, 16, 32 ) |
− | (Note: For other AVR devices you may have to refer to the device datasheet to obtain the correct code)''' </font> | + | '''(Note: For other AVR devices you may have to refer to the device datasheet to obtain the correct code)''' </font> |
Revision as of 10:18, 16 May 2013
Target AVR Processor ( ATMEGA8, 16, 32 )
(Note: For other AVR devices you may have to refer to the device datasheet to obtain the correct code)
USART receive
The Flowcode RS232 component can be used to set the Baud rate and configure the mode of operation, and the ReceiveRS232Char function can be used in the handler macro to read the data (clearing the interrupt).
Enable code:
UCSRB |= ((1 << RXCIE) | (1 << RXEN)); // enable USART receiver and receive interrupts
Disable code:
UCSRB &= ~(1 << RXCIE); // disable USART receive interrupts
Handler code:
ISR(USART_RXC_vect) // USART receive vector
{
FCM_%n(); // call selected macro
}
<img>
Analogue comparator
Enable code:
SFIOR &= ~(1 << ACME); // disable multiplexer input
ACSR |= (1 << ACIE); // enable comparator interrupts - interrupt when comparator output toggles
Disable code:
ACSR &= ~(1 << ACIE); // disable comparator interrupts
Handler code:
ISR(ANA_COMP_vect) // analogue comparator interrupt vector
{
FCM_%n(); // call selected macro
}
The state of the comparator input can be read into a Flowcode variable 'compstate' with the following C code line:
FCV_COMPSTATE = ACSR & (1 << ACO);
<img>
Timer1 rollover
Enable code:
TCCR1B = 0x45; // positive edge trigger with no noise canceler, prescaler = /1024
TIMSK |= (1 << TICIE1); // enable input capture interrupts
Disable code:
TIMSK &= ~(1 << TICIE1); // disable input capture interrupts
Handler code:
ISR(TIMER1_CAPT_vect) // input capture vector
{
FCM_%n(); // call selected macro
}
The captured 16-bit count value can be read into a Flowcode variable 'captval' with the following C code line:
FCV_CAPTVAL = ICR1;
** captval must be declared as an integer variable **