Why the interruptions are not working?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Why the interruptions are not working?

866 次查看
omarantonioniño
Contributor I

Im using lpc xpresso 1769, and the pin with the interrupt is on the pin of the image.

I Run the code a couple of times, what the interrupt does is change the value of a boolean to execute a sum or subtraction; but after a while it stopped working.

The interrupt is a push button NA.

Thanks in advance.

Inkedlpc1769_3 (2)_LI.jpg


#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif

#include <cr_section_macros.h>
#include <NXP/crp.h>
#include "lpc17xx_gpio.h"
#include "lpc17xx_timer.h"
#include <math.h>
#include "lpc17xx_adc.h"
#include "lpc17xx_pinsel.h"


// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
typedef int bool;
#define true 1
#define false 0
#define USERTASK_STACK_SIZE configMINIMAL_STACK_SIZE

extern int Timer0_Wait();
// TODO: insert other include files here

// TODO: insert other definitions and declarations here

/** Fast GPIO port 0 byte accessible definition */

bool toggle=0;
int lectura1;
int lectura2;
int suma,r;
int intput,intput2;

void INIT_RGB (void);
void Contador_RGB(void);

uint32_t del =0x00000FFF;
uint32_t var2=0x00000000;


void CONFIG_GPIO (void);//prototipo de la funcion
void Int_Out (void);

char Inputs;


int main(void)
{

CONFIG_GPIO ();//llamada a la funcion

while(1)
{
Int_Out();

}
}

void CONFIG_GPIO (void)//funcion
{
GPIO_SetDir(2,0x000000FF, 1);
GPIO_ClearValue(2,0x000000FF);
GPIO_SetDir(0,0x000000FF, 0);
GPIO_ClearValue(0,0x000000FF);
GPIO_IntCmd(0,0x00002000,0);
NVIC_EnableIRQ(EINT3_IRQn);
}
void Int_Out(void)
{
//char PrimerTermino;
//char SegundoTermino;
intput = GPIO_ReadValue(0)&0xF;
intput2 = (GPIO_ReadValue(0)&0xF0)>>4;
if(r!=1){
suma = intput - intput2;
}
else{
suma = intput + intput2;
}
GPIO_SetValue(2,suma);
GPIO_ClearValue(2,0xFF);

}

extern void EINT3_IRQHandler(void)
{
if(r==0){
r=1;
}
else{
r = 0;
}

GPIO_ClearInt(2,0x00002000);
toggle=!toggle;
}

标签 (1)
0 项奖励
回复
1 回复

750 次查看
victorjimenez
NXP TechSupport
NXP TechSupport

Hello! 

I highly recommend you to use the examples provided in the LPCOpen as a guide to see how to make the configurations for a pin interrupt. The example that suits your needs is the periph_pinint, here you will see the configurations that are made to declare a GPIO pin as an interrupt. 

If you are using MCUXpresso IDE then you will find the LPCOpen package in the next path:

  • C:\nxp\MCUXpressoIDE_10.1.1_606\ide\Examples\LPCOpen\lpcopen_2_10_lpcxpresso_nxp_lpcxpresso_1769.zip

Hope it helps!

Victor.

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

0 项奖励
回复