Hi I have a task that should be executed once (to set up some pins and variables) and then executed based on an external interrupt. However the task is executed periodically and every time it repeats the set-up. Basically, the if (iState) is entered periodically and the OUTPUT_PIN doesn't stay low but goes high between executions
#include "config.h"
#define OUTPUT_PIN PORTB_BIT5
#define SETUP_PIN() _CONFIG_DRIVE_PORT_OUTPUT_VALUE(B, OUTPUT_PIN, OUTPUT_PIN, (PORT_SRE_FAST | PORT_DSE_LOW));
#define SET_PIN_LOW() _CLEARBITS(B, OUTPUT_PIN)
#define SET_PIN_HIGH() _SETBITS(B, OUTPUT_PIN)
static int iState = 0;
static void fn_my_interrupt(void)
{
fnInterruptMessage(TASK_MY_INTERRUPT, 141);
}
extern void fnTaskMyInterrupt(TTASKTABLE *ptrTaskTable) {
QUEUE_HANDLE PortIDInternal = ptrTaskTable->TaskID;
unsigned char ucInputMessage[MEDIUM_MESSAGE];
if (!iState) {
SETUP_PIN();
SET_PIN_LOW();
INTERRUPT_SETUP interrupt_setup; // interrupt configuration parameters
interrupt_setup.int_type = PORT_INTERRUPT; // identifier to configure port interrupt
interrupt_setup.int_handler = fn_my_interrupt; // handling function
interrupt_setup.int_priority = PRIORITY_PORT_B_INT; // interrupt priority level
interrupt_setup.int_port = PORTB; // the port that the interrupt input is on
interrupt_setup.int_port_bits = PORTB_BIT4; // 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);
iState = 1;
//uTaskerStateChange(TASK_MY_INTERRUPT, UTASKER_SUSPENDED);
}
while (fnRead( PortIDInternal, ucInputMessage, HEADER_LENGTH)) {
switch (ucInputMessage[MSG_SOURCE_TASK]) {
case 141 :
// YOUR CODE HERE //
SET_PIN_HIGH();
break;
}
break;
}
}