PIT interrupt on SAM7

Apr 05, 2007 0 Replies

Greetings all,



I have tried to make the PIT Interrupt working on a SAM7X256 and I can't make it work. I only have one file file - main.c so it's a really simple piece of code. Can anybody help me by telling me why this doesn't work ?


#include #include



void swi_handler (void) __attribute__ ((interrupt ("SWI"))); void swi_handler (void) { }


void vISR (void); void InitPIT (unsigned long int ulPeriod);



void vISR (void) { static unsigned char ucLED = 1; unsigned long ulDummy;



// Toggle back light here. if (ucLED) { AT91F_PIO_ClearOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20); ucLED = 0; } else { AT91F_PIO_SetOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20); ucLED = 1; }



ulDummy = AT91C_BASE_PITC->PITC_PIVR; AT91C_BASE_AIC->AIC_EOICR = ulDummy; }



void InitPIT (unsigned long int ulPeriod) { //initialize PIT (Periodic Interrupt Timer), base time microseconds AT91F_PITInit(AT91C_BASE_PITC,ulPeriod,48);



//Enable interrupts AT91F_PITEnableInt(AT91C_BASE_PITC);



//Interrupt Handler AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_SYS, AT91C_AIC_PRIOR_HIGHEST, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, vISR);



// Enable Peripheral clock in PMC for PITC AT91F_PITC_CfgPMC();



AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SYS); }


int main( void ) { // Setup hardware AT91F_PIO_CfgPeriph (AT91C_BASE_PIOB, AT91C_PIO_PB20, 0); AT91F_PIO_CfgOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20);



// Setup PIT InitPIT (1000);



while( 1 ); }



Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required