Interrupção no PWM Match

Software e Hardware para linha ARM

Moderadores: 51, guest2003, Renie, gpenga

Interrupção no PWM Match

Mensagempor ivan » 26 Out 2010 09:13

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.
"A mente que se abre a uma nova idéia jamais volta ao seu tamanho original." (Albert Einstein).
Avatar do usuário
ivan
Word
 
Mensagens: 618
Registrado em: 12 Out 2006 21:27

Mensagempor fabim » 26 Out 2010 09:20

antes de sair da interrupção, você deve zerar o apontador de flag de interrupção global...
Mano, ve só.
Sou responsável pelo que escrevo!!! E não pelo que você entende !!!
fabim
Dword
 
Mensagens: 5001
Registrado em: 16 Out 2006 10:18
Localização: aqui uái!!!?

Mensagempor ivan » 26 Out 2010 14:02

Vlw Fabim.
"A mente que se abre a uma nova idéia jamais volta ao seu tamanho original." (Albert Einstein).
Avatar do usuário
ivan
Word
 
Mensagens: 618
Registrado em: 12 Out 2006 21:27


Voltar para ARM

Quem está online

Usuários navegando neste fórum: Google [Bot] e 1 visitante

x