AnsweredAssumed Answered

BF592 timer interrupt

Question asked by neoplay on Nov 16, 2013
Latest reply on Nov 28, 2013 by Prashant

Dear Friends;

 

I am using the BF592 Ezkit to see how to use a Timer to generate an interrupt. Here is the code I wrote:

 

#include <stdio.h>

#include "cdefBF592-A.h"

#include "defBF592-A.h"

#include <sys\exception.h>

 

int a = 1;

long read;

 

EX_INTERRUPT_HANDLER(TIMER0_ISR);

 

main()

{

 

register_handler(ik_ivg11, TIMER0_ISR); //Assign Timer0 to generate interrupt

*pSIC_IMASK0 |= 0x80000; //Enable interrupt

 

*pTIMER0_CONFIG = 0x035d;

*pTIMER0_PERIOD = 0xFFFFFFF;

*pTIMER0_WIDTH = 0x7FFFFFF;

 

*pTIMER_ENABLE |= 0x0001;

*pTIMER_DISABLE |= 0x0001;

 

while (a == 1)

{

 

printf("WHILE LOOP\n");

 

}

 

printf("While Loop is finished");

 

return (0);

 

}

 

EX_INTERRUPT_HANDLER(TIMER0_ISR)

{

 

read = *pTIMER0_COUNTER;

printf("TIMER0_COUNTER = %d\n", read);

a = 0;

 

}

 

The intention is simple, when the timer reach 0x0FFFFFFF, it should generate a interrupt and then goes to the subroutine EX_INTERRUPT_HANDLER(TIMER0_ISR)

where the a is set to zero to stop the while loop.

 

When I execute the code, the While loop never stops and the counter is not always at 0x0FFFFFFF. Please have a look and let me know what is wrong.

 

 

Thanks very much in advance

 

 

 

--Neo

Outcomes