chipKIT® Development Platform

Inspired by Arduino™

Timer Interrupt

Created Fri, 23 Mar 2012 06:44:06 +0000 by Melancolia


Melancolia

Fri, 23 Mar 2012 06:44:06 +0000

Hello everyone,

I try to do a simple test with the timer of my chipkit max 32. I want to turn on a LED with an interruption of the Timer1. I try this code, but it doesn't function.

Can you help me please ?

// INITIALISATION (rapport cyclique, frequence pwm) void setup()

// MAIN void loop() { while (1) { // Ne rien faire } }

// INTERRUPTION void change_pwm() { // Une fois sur deux : rapport cyclique de 25% if (altern==1) // Une fois sur deux : rapport cyclique de 50% else }

I apologize for my English, but i'm french...

Thank you !

Melancolia,


Jacob Christ

Sat, 24 Mar 2012 05:54:24 +0000

Hello everyone, // MAIN void loop() { while (1) { // Ne rien faire } }

The while loop inside loop() is not needed...

Hello everyone, // INTERRUPTION void change_pwm() { // Une fois sur deux : rapport cyclique de 25% if (altern==1) // Une fois sur deux : rapport cyclique de 50% else }

Where does change_pwm() come from? Is this an Arduino abstraction for an interrupt?

My interrupts tend to look like this:

extern "C"
{
void __ISR(_TIMER_3_VECTOR,ipl3) pwmOn(void)
{
  mT3ClearIntFlag();  // Clear interrupt flag
}
}

Jacob


Melancolia

Sat, 24 Mar 2012 17:16:26 +0000

I apologize, i do a failure and don't give my good code...

#include <plib.h>

void setup()

void loop() { while(1) {} }

void __ISR(_TIMER_1_VECTOR, ipl3) Timer1Handler(void) { digitalWrite(13, HIGH); // changement de la led => on l'allume IFS0CLR = 0x0010; //Clear the Timer 1 interrupt status }

That's better :roll:


Melancolia

Sat, 24 Mar 2012 17:24:14 +0000

#include <plib.h>

void setup()

extern "C" { void __ISR(_TIMER_1_VECTOR,ipl3) pwmOn(void) { digitalWrite(13, LOW); mT3ClearIntFlag(); // Clear interrupt flag } }

This program functions :D I really thank you very much Jacob Christ ! You help me a lot ;)