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 support@ccsinfo.com

interrupt with PIC18F6722

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



Joined: 01 Feb 2005
Posts: 21
Location: Paris

View user's profile Send private message

interrupt with PIC18F6722
PostPosted: Wed Aug 29, 2007 10:01 am     Reply with quote

Hello,
I'm actualy using a software with a PIC18F4520, and i want to use this code on a PIC18F6722.

I've got a problem to configure my interrupt (RTCC), the code on the interruption is not launched,

On my configuration i put the following code :

// Hardware SPI :
// - Master mode
// - Data valid when clock goes High to Low
// - SPI clock divide by 64 (115.2 kHz)
setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_CLK_DIV_64);
setup_spi2(FALSE);


// Timer 0 (RTCC) :
// - Resolution 138 µs
// - Overflow 35.7 ms
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256|RTCC_8_BIT);

// Timer 1 :
// - Resolution 4.3 µs
// - Overflow 284 ms
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
enable_interrupts(INT_TIMER1);

enable_interrupts(GLOBAL);


If somebody can help
Thank you

Bruno
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 29, 2007 11:27 am     Reply with quote

You need to enable interrupts for Timer0 (the RTCC). Currently, you
only have interrupts enabled for Timer1.
global



Joined: 01 Feb 2005
Posts: 21
Location: Paris

View user's profile Send private message

PostPosted: Thu Aug 30, 2007 1:57 am     Reply with quote

Hello, thanks for the answerd,
I enable the timer 0 on the main. But when the code is executing :
enable_interrupts(INT_RTCC);

the PIC stop.
i check the code launched by the interrupt and everything is good.
Bruno
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 30, 2007 2:40 am     Reply with quote

Quote:
I enable the timer 0 on the main. But when the code is executing :
enable_interrupts(INT_RTCC);

the PIC stop.
This is completely different from what you told us in your original post. This behaviour suggests the interrupt is being called but never finishes. This can be caused by:
1) A missing interrupt handling function, than the interrupt flag is never cleared.
or
2) An interrupt function taking too long to finish so the timer generates a new interrupt before handling the current one is finished. Common mistakes are a delay_ms() or printf() call from the interrupt handler.


Another problem is in your calculations for the different clock speed configurations. The SPI-bus clock is derived from Fosc but the timers use Fosc/4. This means that the xxx_DIV_BY_xxx for SPI and timers are not giving the same timing as you now assume. You didn't mention your clock speed so I can't tell which textual comments are wrong now.
global



Joined: 01 Feb 2005
Posts: 21
Location: Paris

View user's profile Send private message

PostPosted: Thu Aug 30, 2007 2:56 am     Reply with quote

Hello, ckielstra thanks for your answered,
My external clock is an 7.37Mhz, the configuration of the interrupt shorter, the code launch by the interrupt is too long for the cycle of the interrupt, case 2 in you explication.

Know i modified my code and the interrupt is working, thanks for your help
Bruno
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