hello, I have a logomatic V2 and am trying to conserve power by putting it to sleep and waking up on interrupt from pin1 via EINT3, though am struggling to get my vectored interrupts to do anything,
this is my boot up function which should enable the interrupt:
void boot_up(void)
{
set_pin_mode(STAT0, “DO”); //Set status LEDs as outputs
set_pin_mode(STAT1, “DO”);
rprintf_devopen(putc_serial0); //Open up serial port 0 for debugging
card_init(); //Init SD card interface
//Creat the main log file
char name[32];
int count = 0;
string_printf(name,“LOG%02d.txt”,count);
while(root_file_exists(name))
{
count++;
if(count == 250)
{
rprintf(“Too Many Logs!\n\r”);
error_mode(4);
}
string_printf(name,“LOG%02d.txt”,count);
}
handle = root_open_new(name);
sd_raw_sync();
//Setup TIMER1 to run
T1TCR = 0; //Reset Timer1
T1PR = 6000; //Set prescalar to 6,000 - every tick is 0.1ms (changed this from 60,000)
T1TCR = 1; //Start Timer1
//Set up the EINT3 External Interrupt Functionality
PINSEL1 &= ~(3<<28); //Clear P0.30 special function
PINSEL1 |= (2<<28); //Set P0.30 to EINT3
VICIntEnClr = EINT3_INT;//Make sure EINT3 interrupts are disabled
EXTMODE &= ~(1<<3); //Set EINT3 to be level sensitive
EXTINT |= (1<<3); //Clear the EINT3 Interrupt bit
EXTPOLAR &= ~(1<<3); //Set EINT3 to detect falling edges
INTWAKE |= (1<<3); //ARM will wake up from power down on an EINT3 interrupt
VICIntSelect = ~(EINT3_INT);
VICVectCntl0 = 0x20 | 16; //EINT3 External Interrupt
VICVectAddr0 = (unsigned long)ISR_EINT3;
flash_it(50); //Flash Status Lights
and this is my interrupt code
static void attribute ((interrupt(“IRQ”))) ISR_EINT3(void){
VICIntEnClr = EINT3_INT; //Temporarily disable EINT3 Interrupts
EXTINT |= (1<<3); //Clear the interrupt bit in EINT3
write_digital_pin(STAT1, ON); //Turn OFF LED
write_digital_pin(STAT0, ON);
delay_ms(50)
write_digital_pin(STAT1, OFF); //Turn OFF LED
write_digital_pin(STAT0, OFF);
VICIntEnable = EINT3_INT;
VICVectAddr =0; //Update the VIC priorities
}
and here’s the start of my code if it helps
/* Header Files */
//======================================
#include <stdio.h>
#include <string.h>
//#include “LPC21xx.h”
#include “LPC214x.h”
//UART0 Debugging
#include “serial.h”
#include “rprintf.h”
//Needed for main function calls
#include “string_printf.h”
#include “fat16.h”
#include “rootdir.h”
#include “sd_raw.h”
/* Global Variables */
//======================================
#define ON 0
#define OFF 1
#define STAT1 9
#define STAT0 10
#define HIGH 1
#define LOW 0
#define EINT3_INT (1<<17)
struct fat16_file_struct* handle;
/* Function Declarations */
//======================================
void UNDEF_Routine(void) attribute ((interrupt(“UNDEF”)));
//void IRQ_Routine(void) attribute ((interrupt(“IRQ”)));
void boot_up(void);
void log_string(char *buf);
void card_init(void);
//static void ISR_EINT3(void) attribute ((interrupt(“IRQ”)));
void wakeUp(void);
char look_up_pin(char labeled_pin);
void set_pin_mode(char pin_number, char *buf);
char read_digital_pin(char pin_number);
void write_digital_pin(char pin_number, char pin_state);
void flash_it(int);
void error_mode(char error_number);
void delay_ms(int count);
unsigned int power_register_values;
//======================================
int main (void)
{
boot_up(); //Init LPC, IO pins, and FAT
log_string(“Log started\n\r”);
set_pin_mode(4, “DI”);
VICIntEnable = EINT3_INT;
//Enable Interrupt
//PCON = (1<<0); //Go into IDLE mode
while(1)
{
}
return 0;
}
any help is greatly appreciate and I’m very new to all of this so apologies for any elementary mistakes
thanks