Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: TC0 doesn't work
PostPosted: Fri Dec 03, 2010 10:50 am 
Offline

Joined: Fri Dec 03, 2010 10:04 am
Posts: 1
Hi!
I have some problem starting the TC0 on my AT91 SAM7S. The timer doesn't work and there is no interrupt and I don't know what is wrong.
UART and RTT are working with interrupts on same interrupt_init code.
I hope you can help me.

Here my code:

void init_timer0(void){
unsigned int dummy;
TC0_CCR = (1<<1); //disable timer
TC_BMR = (1<<0); // set no external clock
TC0_IDR = 0xFFFFFFFF; // Disable interrupts
dummy = TC0_SR; // Clear status register
dummy = dummy; // do something -> no warning
TC0_CMR = ((1<<0)|(0<<1)|(0<<4)|(0<<5)|(0<<8)|(0<<9)|(1<<14));
TC0_RC = (0x3E8); // run to
TC0_CCR = ((1<<0) | (1<<2)); //enable timer
TC0_IER = (1<<TC0_IER_CPCS_BIT); //interrupt enable
}

void ISR_TC0(void){
unsigned int dummy;
dummy = TC0_SR;
dummy = dummy;
time2++;
}

int main(void){
init_clock();
init_periphery ();
init_timer0();
enable_periphery_clock(TC0_ID);
config_AIC(TC0_ID, 4, 0, ISR_TC0);
while(1){
//blink LED with timer0
}
}


void config_AIC(unsigned int source, unsigned int mode, unsigned char trigger, void(*handler)(void)){
AIC_IDCR = 1 << source;
// Configure mode and handler
AIC_SVR(source) = ((unsigned int) handler);
AIC_SMR(source) = (mode | (trigger<<5));

// Clear interrupt
AIC_ICCR = (1 << source);
AIC_IECR = (1 << source); //enable interrupt
}


Top
 Profile  
 
 Post subject: Re: TC0 doesn't work
PostPosted: Wed Feb 16, 2011 4:36 am 
Offline

Joined: Fri Nov 19, 2010 8:46 pm
Posts: 9
Have you found a solution yet ?
I've been stuck with a very similar problem for quite some time now, and since I couldn't get it working, I haven't been looking at it for around a month.
I think, though, that I'll start looking at again, maybe a from new approach.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: