Greetings, I'm working on a project with LPC804 (TSSOP20) and I came across a problem I can't handle. I have a simple program for capturing falling edges on pin P0.8. Pin P0.9 is used to control the thyristor and P0.1 to control the LED. Here is the program:
#include <cr_section_macros.h>
#include "LPC804.h"
#define LED_PIN (1 << 1) // LED P0.1
#define PWR_PIN (1 << 9) // POWER P0.9
// *** LED
#define LED_ON() LPC_GPIO_PORT->SET0 = LED_PIN
#define LED_OFF() LPC_GPIO_PORT->CLR0 = LED_PIN
// *** POWER
#define PWR_ON() LPC_GPIO_PORT->SET0 = PWR_PIN
#define PWR_OFF() LPC_GPIO_PORT->CLR0 = PWR_PIN
uint32_t u32_x = 0;
int main(void) {
LPC_SYSCON->SYSAHBCLKCTRL0 |= (1 << 18) | (1 << 7) | (1 << 6); // IOCON [Enable], SWM [Enable], GPIO0 [Enable]
// *** LED
LPC_GPIO_PORT->DIR0 |= LED_PIN;
LED_OFF();
// *** POWER
LPC_GPIO_PORT->DIR0 |= PWR_PIN;
PWR_OFF();
// *** CAPTURE
LPC_SYSCON->PINTSEL0 = 8; // Pin P0.8
LPC_SYSCON->SYSAHBCLKCTRL0 |= (1 << 28); // GPION_INT
LPC_PIN_INT->IENF |= (1 << 0); // Enable falling edge interrupt enabled
LPC_PIN_INT->SIENF |= (1 << 0); // Enable falling edge interrupt
LPC_PIN_INT->IST |= (1 << 0);
NVIC_EnableIRQ(PININT0_IRQn);
while(1) {
}
return 0 ;
}
void PININT0_IRQHandler(void) {
if (LPC_PIN_INT->IST & (1 << 0)) {
u32_x++;
LPC_PIN_INT->IST |= (1 << 0);
}
}
The problem occurs after initialization of pin P0.9. Before initializing this pin, pin P0.8 acts as an input with a pull up resistor. After initializing P0.9, something happens and pin P0.8 behaves as if it were a pull down. Therefore, capturing descending wounds does not work.
How do the settings of pin P0.9 relate to pin P0.8? Can anyone advise me what to do with it?