How can i enable disable interrupts in KDS with k64f

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i enable disable interrupts in KDS with k64f

1,860 Views
Contributor IV

I am trying to make a simple program where i will toggle leds when i press a button.

i am using FRDM K64F.

 

I am trying to do that without cmsis as i have ever done. i have just configured the ports no problem but i can not see how to configure the interrupt.

using NVICICPR0 and  NVICISER0 registers.

 

is there any simple example. without all this pe and cmsis?

 

//HABILITA CLOCKS PARA OS PORTS A B C D e E
SIM_SCGC5 |=  SIM_SCGC5_PORTA_MASK + SIM_SCGC5_PORTB_MASK + SIM_SCGC5_PORTC_MASK + SIM_SCGC5_PORTD_MASK + SIM_SCGC5_PORTE_MASK ;

 

// CONFIGURA PORTS DO LED COMO PINOS DIGITAIS
PORTB_PCR21 |= PORT_PCR_MUX(1);
PORTB_PCR22 |= PORT_PCR_MUX(1);
PORTE_PCR26 |= PORT_PCR_MUX(1);
//CONFIGURA PINOS COMO SAIDA
GPIOB_PDDR |= GPIO_PDDR_PDD(GPIO_PIN(21) + GPIO_PIN(22));
GPIOE_PDDR |= GPIO_PDDR_PDD(GPIO_PIN(26));
Labels (1)
0 Kudos
3 Replies

82 Views
NXP TechSupport
NXP TechSupport

Hi Edriano,

Take a look to this document:

https://community.freescale.com/docs/DOC-101862

Regards,

Garabo

0 Kudos

82 Views
Specialist V

Hi

Eg of configuring an interrupt on PTA19 (falling edge sensitive with pull-up enabled on input).

1. Install the address of the handling interrupt routine at the PORT A vector

2. Enable the interrupt in the NVIC (for the K64 this means) - set the priority to 0xP0000000 of the NVIC piority register IRQ56_59_PRIORITY and enable the interrupt with a write of 0x08000000 to IRQ32_64_SER.

3. Enable the port interrupt (falling edeg with pull-up enabled) by writing 0x000a0103 to PORTA_PCR19

4. Make sure that global interrupts are also enabled [asm("cpsie  i")]

Handle theinterrupt in the handling routine entered in 1) and clear the edge sensitive interrupt source by writing 0x00080000 to PORTA_ISFR.

Regards

Mark

P.S: Taken from the port interrupt interface in the uTasker project which is configured using:

INTERRUPT_SETUP interrupt_setup;                                              // interrupt configuration parameters

interrupt_setup.int_type = PORT_INTERRUPT;                                    // identifier to configure port interrupt

interrupt_setup.int_handler = test_irq;                                       // handling function

interrupt_setup.int_priority = PRIORITY_PORT_A_INT;                           // interrupt priority level

interrupt_setup.int_port = PORTA;                                             // the port that the interrupt input is on

interrupt_setup.int_port_bits = PORTA_BIT19;                                  // the IRQ input connected

interrupt_setup.int_port_sense = (IRQ_FALLING_EDGE | PULLUP_ON);              // interrupt is to be falling edge sensitive

fnConfigureInterrupt((void *)&interrupt_setup);                               // configure interrupt

82 Views
Contributor IV

thank you Mark.

I will take a look on that.

I find the names where definede as NVICISPRx and NVICICPRx.

As i have always worked and whished to work with the bare metal. the learning curve for me will be very hard.

0 Kudos