CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Interrupt-Problems

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
P51D



Joined: 25 Jan 2010
Posts: 36

View user's profile Send private message

Interrupt-Problems
PostPosted: Sat May 29, 2010 8:13 am     Reply with quote

Hello all

I have some problems with the using of one and more interrupts:

First:
Is it possible to have a timer-interrupt at compare-match like the ctc at the avr controllers??
Because at this time I can only create a timer interrupt with set the timer to a value like this:
Code:

setup_timer1(TMR_INTERNAL|TMR_DIV_BY_1);
set_timer1(65535-40);
enable_interrupts(INTR_GLOBAL|INT_TIMER1);
/*
*/
#int_TIMER1
void SysTime_isr(void){
   sys_timer ++;
   set_timer1(65535-40);
}


then I have a problem with using more than one interrupt routine with a dsPIC30F6012A:
Code:

setup_timer1(TMR_INTERNAL|TMR_DIV_BY_1);
set_timer1(65535-40);
ext_int_edge(H_to_L);
enable_interrupts(|INT_TIMER1);
enable_interrupts(INT_EXT0);
enable_interrupts(INTR_GLOBAL);
/*
*/
#int_TIMER1
void SysTime_isr(void){
   sys_timer ++;
   set_timer1(65535-40);
}
#int_EXT0
void FT245_isr(void){
   // Read data
}

In this way, the second interrupt doesn't work and I don't know why.

Can any one help me?

Best regards
P51D
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sat May 29, 2010 8:41 am     Reply with quote

On the PIC, the _timer_ is separate from the _CTC_.
The timer itself cannot have a 'compare match'. It has no such ability. However the CTC, can test specific timers, and interrupt when they reach a particular value.

On the second, the problem is time. 65535-40, corresponds to 40 instruction times. The first interrupt will be happening so often, that the second is unlikely to ever get called...

Best Wishes
P51D



Joined: 25 Jan 2010
Posts: 36

View user's profile Send private message

PostPosted: Sat May 29, 2010 9:17 am     Reply with quote

Quote:

On the second, the problem is time. 65535-40, corresponds to 40 instruction times. The first interrupt will be happening so often, that the second is unlikely to ever get called...


The problem is, that I need a time-reference with an exactitude at 1us.
The highest time that I could have is 30us.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sat May 29, 2010 9:54 am     Reply with quote

Are you actually saying you want an interrupt event at 1MHz frequency, or you want a clock to run, counting at 1MHz?. If the former, then I'd have to say 'forget it'. It is technically possible to have an interrupt at this sort of frequency, but if you want to do anything else, there _will_ be problems, even on your PIC, which does have separate interrupt vectoring...
If you want a clock that counts in ticks of 1MHz, then on this PIC, I think you'd have to use two timers. Timer 3, setup as a PWM, with it's comparator set to clear it at 40 counts, and then feed this output to another timer, which will then be counting at the required frequency.
Look at the 'setup_compare' function for the CTC control.

Best Wishes
P51D



Joined: 25 Jan 2010
Posts: 36

View user's profile Send private message

PostPosted: Sat May 29, 2010 12:17 pm     Reply with quote

Yes, I would have an interrupt event at 1MHz frequency.

The Problem is, that I have to update the peripheral with a frequency of ~27000kHz which is at ~37us.

I see 2 possible solutions:
1) I set the timer down to a interrupt-frequency of 100kHz or just to 27kHz
2) I compare the timer with a variable

which do you think is the better one?

best regards
P51D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group