MCUXpresso - Help to initialize EINT2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCUXpresso - Help to initialize EINT2

971 Views
andreyshtyrya
Contributor I

Hello! Im new with MCUXpresso, just starting to program mcu in C, before i always worked in assembler. Im trying to make a program witn lpc1769 with the OM13000 board to change the frecuency of blinking led when the interrupt on a pin is triggered, pin 2.12 falling edge. Build goes ok but it never enters IRQ rutine. Can please someone check the if EINT2_IRQ init or rutine is okey??? The only work the irq should do is to change frec value.  Here is the code:

/*
===============================================================================
Name : gpio.c
Author : $(author)
Version :
Copyright : $(copyright)
Description : cambiar frecuencia de parapdeo del led con un pulsador por interrupcion
===============================================================================
*/

#if defined (__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif

#include <cr_section_macros.h>

#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "queue.h"

xSemaphoreHandle xSemaforo; // Tiene que ser Global, porque lo tiene que poder ver todas las tareas
int boton=0; //variable global del boton en pin 53

int frec=100; //tiempo de semiciclo de parpadeo en ms

void static taskLEDoff (void)
{
while(1)
{
xSemaphoreTake(xSemaforo,portMAX_DELAY);
Chip_GPIO_WritePortBit(LPC_GPIO,0,22,0); //apago con 0
vTaskDelay(frec/portTICK_RATE_MS); //tiempo off en 100ms
xSemaphoreGive(xSemaforo);
}
}

void static taskLEDon (void)
{
while(1)
{
xSemaphoreTake(xSemaforo,portMAX_DELAY);
Chip_GPIO_WritePortBit(LPC_GPIO,0,22,1); //enciendo con 1
vTaskDelay(frec/portTICK_RATE_MS); //tiempo on en 100ms
xSemaphoreGive(xSemaforo);
}
}

//RUTINA DE INTERRUPCION
void EINT2_IRQHandler()
{
NVIC_DisableIRQ(EINT2_IRQn); //desactivo interrupcion
Chip_GPIOINT_ClearIntStatus(LPC_GPIOINT,GPIOINT_PORT2,12); //limpio IRQ
NVIC_ClearPendingIRQ(EINT2_IRQn);

frec=500;

NVIC_EnableIRQ(EINT2_IRQn); //hablito IRQ de vuelta
}


int main (void)
{


SystemCoreClockUpdate();
Board_Init();

//INICIALIZACION INTERRUPCION
Chip_GPIO_SetPinDIRInput(LPC_GPIO,2,12); //pin como entrada
Chip_GPIOINT_Init(LPC_GPIOINT); //inicializacion IRQ
Chip_GPIOINT_SetIntFalling(LPC_GPIOINT,GPIOINT_PORT2,12); //2.12 IRQ por flanco negativo
NVIC_EnableIRQ(EINT2_IRQn); //habilito IRQ en 2.12 EINT2


xTaskCreate(taskLEDoff,"taskLEDoff",1024,0,1,0);
xTaskCreate(taskLEDon,"taskLEDon",1024,0,1,0);
xSemaforo = xSemaphoreCreateMutex();

vTaskStartScheduler();

while(1);
}

0 Kudos
Reply
2 Replies

802 Views
jeremyzhou
NXP Employee
NXP Employee
Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.

Please refer to periph_pinint demo in the lpcopen_2_10_lpcxpresso_nxp_lpcxpresso_1769 to view the details.

LPCOpen Software for LPC17XX|NXP

Have a great day,

TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

802 Views
andreyshtyrya
Contributor I

Thanks i will read it.

0 Kudos
Reply