chipKIT® Development Platform

Inspired by Arduino™

Program with timer compiled with MPIDE or UECIDE

Created Thu, 06 Nov 2014 14:45:14 +0000 by michastro


michastro

Thu, 06 Nov 2014 14:45:14 +0000

I have a program wich use timer 45 and function extern "C" { void __ISR(_TIMER_45_VECTOR,IPL2) comms45_handler(void) It's working fine but I need to have a program wich can be compiled also with UECIDE. So I have made a small program without extern "C" function to test timer45 but it doesn't work and I don't know why

const int LED1 = 13;      // LED on Uno32
static byte LED;

void T45()
{
	mT45ClearIntFlag(); // Clear interrupt flag
	digitalWrite(LED1, !digitalRead(LED1)); //Just Toggle LED
}



void setup()
{
	pinMode(LED1,OUTPUT);
	digitalWrite(LED1,LOW);
	OpenTimer45( T45_ON | T45_PS_1_1 | T45_SOURCE_INT, 0x0001);
	ConfigIntTimer45((T45_INT_ON | T45_INT_PRIOR_2));
	PR4=0xB400;	
	PR5=0x04C4;	
	setIntVector(_TIMER_45_VECTOR,T45);
	mT45IntEnable(1);  
}

void loop()
{
}

Have you an idea? Thanks a lot


michastro

Fri, 07 Nov 2014 09:50:36 +0000

I have found the solution, you must replace: void T45() by void attribute((interrupt)) T45() With that the compiler generates function entry and exit sequences suitable for use in an interrupt handler.