Custom Interrupts - ARM

From Flowcode Help
Jump to navigationJump to search

Target ARM Processor ( AT91SAM7S128 )

(Note: For other ARM devices you may have to refer to the device datasheet to obtain the correct code)


The official device datasheet is an invaluable source of information when dealing with custom interrupts, as are two header files,lib_AT91SAM7S128.h and AT91SAM7S128.h, which provide functions and definitions. These files are applicable to all the devices in the AT91SAM7S range.

The header files can be found in the \Tools\ Global folder of the Flowcode installation. These files must not be modified!


Enable Code:

This command enables the receive interrupt of USART1.


AT91F_US_EnableIt(AT91C_BASE_US1,AT91C_US_RXRDY);


Gen Custom Interrupts ARM US1.png

AT91F_US_EnableIt()

This library function can be used to enable any of the interrupts generated by a USART. AT91SAM7S16 and 32 devices have only one USART, the other devices in the range have two. The function writes to the interrupt enable register of the designated USART.


There is an AT91F_US_DisableIt() function that can be used in the same way in the Disable Code section to disable the interrupt.


AT91C_BASE_US1

This is the system definition of the base address of the registers associated with USART1


AT91C_US_RXRDY

This is the system definition of the RXRDY (Receive Ready) bit in a USART interrupt enable register.


Disable Code:

AT91F_US_EnableIt(AT91C_BASE_US1,AT91C_US_RXRDY);


Handler Code:

This code section checks the identity of the peripheral device generating the interrupt and the interrupt event being generated. The Flowcode Custom Interrupt system receives two parameters when an interrupt is generated:

Peripheral device identity number (periphID)

Active interrupt flags (IFlags)


Active interrupt flags are those that have been both enabled and triggered.


if ( (periphID == AT91C_ID_US1) && (IFlags & AT91C_US_RXRDY) )

{

FCM_%n(); / Call Flowcode Macro

}



FCM_%n():

This is converted into the name of the macro selected in the 'Will call macro' box of the interrupt properties panel.


periphID:

This parameter is the system identification number of the peripheral device generating the interrupt. The following peripheral devices are supported by Flowcode as custom interrupts;


AT91C_ID_PIOA - Parallel IO Controller

AT91C_ID_ADC - Analog-to-Digital Converter

AT91C_ID_SPI - Serial Peripheral Interface

AT91C_ID_US0 - USART 0

AT91C_ID_US1 - USART 1

AT91C_ID_TWI - Two-Wire Interface

AT91C_ID_PWMC - PWM Controller

AT91C_ID_TC0 - Timer Counter 0

AT91C_ID_TC1 - Timer Counter 1

AT91C_ID_TC2 - Timer Counter 2


IFlags:

This parameter contains all the interrupt flags that are being generated by the peripheral device and have been previously enabled.


AT91C_US_RXRDY:

In addition to being the definition of the interrupt enable flag, this also acts as the definition of the interrupt request flag.