Página 1 de 1

Interrupção no PWM Match

MensagemEnviado: 26 Out 2010 09:13
por ivan
PessoAll,

Estou usando o LPC2148 pra fazer uns testes. No manual diz que é possível gerar um interrupção no match0 do PWM, então fiz o código abaixo:


Código: Selecionar todos
#include <LPC21XX.H>


void pwmISR(void) __irq;

int count=0;

int main(void)
{

   count = 0;

   PINSEL0 |= 0x00028000;   //Enable pin 0.7   as PWM2
   PWMPR     = 0x00000000;   //Load prescaler
   
   PWMPCR = 0x0000400;      //PWM channel 2 single edge control, output enabled
   PWMMCR = 0x00000003;   //On match with timer reset the counter, generates interrupts
   PWMMR0 = 0x00000960;   //set cycle rate to 2400 ticks
   PWMMR1 = 0x00000000;   //set rising edge of PWM2 to 0 ticks
   PWMMR2 = 0x00000480;   //set falling edge of PWM2 to 1200 ticks
   PWMLER = 0x00000007;   //enable shadow latch for match 0 - 2
   PWMTCR = 0x00000002;   //Reset counter and prescaler
   PWMTCR = 0x00000009;   //enable counter and PWM, release counter from reset

   VICVectCntl0    = 0x0000002F;                    //select a priority slot for a given interrupt
   VICVectAddr0    = (unsigned)pwmISR;            //pass the address of the IRQ into the VIC slot

   VICIntEnable    = 0x00000100;                     //enable interrupt
   
   while(1) ;

}

void pwmISR(void) __irq   {
   count++;
   PWMIR = 0x0001;
}

Na tela peripherals do uVision4.0 o PWM está funcionando, a int está sendo gerada mas não desvia para a minha rotina de tratamento. Onde estou errando?

All_bs.

MensagemEnviado: 26 Out 2010 09:20
por fabim
antes de sair da interrupção, você deve zerar o apontador de flag de interrupção global...

MensagemEnviado: 26 Out 2010 14:02
por ivan
Vlw Fabim.