With the manuals:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/CIHIGCIF.htmlBut this is the basics:
An interrupt originates from the peripheral, to work the peripheral needs power and clock. This is fixed in RCC, but you'd probably already knew that.
Then the interrupt source must be enabled in the peripherals
interrupt control register. Such as USART_ISR.
Next the NVIC must have the interrupt channel of the peripheral enabled.
See CMSIS
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/CIHIGCIF.html You probably have something similar available.
Also in the NVIC you can adjust the preemptive priority. Since arm allows higher priority interrupts to start inside lower priority interrupts. This gets you nested interrupts, and you should be aware of this. For example, RESET and HARDFAULT always executes. The order of the table is the default priority iirc. Watch your stack.
When you didn't remap the interrupt vector table, it will still be at the top of your bootable region. This is a lookup table with vectors (function pointers) to where the interrupt routine code is located, this can be in RAM if you've put them there to make things fast. Your (assembly) startup file should have this list, with WEAK defined functions. Weak means that they are defined, but they can be overridden. Also there is a infinite loop to catch any interrupts that fired, but don't have a valid address in the table. (eg: still weak)
In this list you find names "USART1_IRQHandler" or something more generic.
Simply creating the function will do the work of the vector table.
void USART1_IRQHandler(void) {
//Check if interrupt was because data is received
if (USART_GetITStatus(USART1, USART_IT_RXNE)) {
//Do your stuff here
//Clear interrupt flag
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
}
}
In the function you then have to check
why you are in the interrupt. There may be 254 interrupt channels, the number of wires going to the nvic are limited and peripheral interrupts are often grouped. You check this by reading the peripheral flags.
Then you do your stuff, for that flag.
Next you clear the peripheral flag, to notify you're done. This is done by writing a 1 to that bit. Simply do something like USART_ISR |= (1<<bitnumber); Or use driver. "USART_ClearITPendingBit".
Then you return.
Now what happens when you do not clear the status flag OR'd to the nvic? Well, you'll end up in an infinite loop of the interrupt, with any higher priority as nested interrupts.
You can also fire the interrupt from software using the NVIC, but the USART will not have its status flag set.
Refer to the "STM32F3xxx and STM32F4xxx Cortex-M4 programming manual" for details about the nvic used in the f4's.
Obviously, this is totally redundant information that can be found if you look right for websites of universities and such... But hey, It's my thousandth post, why not make it useful?