Hi John
To program an interrupt on the SW1 button of the K64 TWR board (falling edge when pressed) the following operations are required:
Interrupt vector 0x3d entered to point to the PORTC interrupt handling routine
IRQ60_64_PRIORITY = 0x00006000; // set priority of PORT C interrupt(s) to 6 (for example)
IRQ32_63_SER = 0x20000000; // enable the PORT C interrupt in the NVIC
PORTC_PCR6 = 0x000a0103; // configure and enable negative edge interrupt on PTC6
You can change the register names to match those in your header files and can look at the register content to work out what is being done.
If you need more details you can download the uTasker project [KINETIS Project Code], which also simulates the port interrupt operation. Below is a user interface code to configure any pin for interrupt operation. Each port has one interrupt vector but the interrupt interface allows a user interrupt call-back handler to be associated with a single pin or single interrupt handler to respond to changes on multiple pins, which makes port change interrupts to be used with great ease.
// Interrupt call-back handler
//
static void test_sw1_press(void)
{
// Insert IRQ code (interrupt has been cleared)
}
//Interrupt configuration
INTERRUPT_SETUP interrupt_setup; // interrupt configuration parameters
interrupt_setup.int_type = PORT_INTERRUPT; // identifier to configure port interrupt
interrupt_setup.int_handler = test_sw1_press; // handling function
interrupt_setup.int_priority = PRIORITY_PORT_C_INT; // interrupt priority level
interrupt_setup.int_port = PORTC; // the port that the interrupt input is on
interrupt_setup.int_port_bits = PORTC_BIT6; // the IRQ input connected (SW1 on TWR-K64F)
interrupt_setup.int_port_sense = (IRQ_FALLING_EDGE | PULLUP_ON); // interrupt is to be falling edge sensitive
fnConfigureInterrupt((void *)&interrupt_setup); // configure interrupt
Regards
Mark
µTasker Kinetis support