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

enabling timer interrupt cause reset
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tophe59



Joined: 13 Oct 2005
Posts: 32
Location: France

View user's profile Send private message

enabling timer interrupt cause reset
PostPosted: Sun Oct 23, 2005 9:12 am     Reply with quote

When interrupt of timer1 is enable the mplab debuger stop and seam reset the program. (like watchdog timeout ??)

A breakpoint in the interrupt is never reached.

Help me please Crying or Very sad

Code:
#use delay (clock=40000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)
#use fast_io(E)

...
#int_timer1
   void timer1()
   {
   SET_TIMER1(0xfe0b+get_timer1());
                }

//main ...
   setup_timer_1 (T1_INTERNAL|T1_DIV_BY_8); //init timer
   enable_interrupts(INT_TIMER1);
   enable_interrupts(global);

....




Last edited by tophe59 on Sun Oct 23, 2005 10:46 am; edited 1 time in total
Ttelmah
Guest







PostPosted: Sun Oct 23, 2005 10:39 am     Reply with quote

Put the interrupt code, or a 'prototype' for it, in front of the main. Otherwise the compiler does not handle it right (remember a function must be defined _before_ it is used, and interrupts occur from inside the 'main', or it's subroutines.

Best Wishes
tophe59



Joined: 13 Oct 2005
Posts: 32
Location: France

View user's profile Send private message

PostPosted: Sun Oct 23, 2005 10:49 am     Reply with quote

Thank's but the interrupt code is already before de main.

I change my first message.

Help again Crying or Very sad
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Oct 23, 2005 1:01 pm     Reply with quote

Your oscillator frequency is specified as 40 MHz.
I don't see the H4 fuse to enable the 4x PLL. You're using HS.
Quote:

#fuses HS,NOWDT,NOPROTECT,NOLVP
use delay (clock=40000000)


What PIC are you using ?

What hardware debugger are you using ?

What is the version of your compiler ?
tophe59



Joined: 13 Oct 2005
Posts: 32
Location: France

View user's profile Send private message

PostPosted: Sun Oct 23, 2005 11:47 pm     Reply with quote

my configuration:

- Pic 18f4620
- ICD2 + MPLAB 7.2
- 3.183

what is H4 fuse ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 24, 2005 1:08 am     Reply with quote

Quote:
what is H4 fuse ?

OK, you must be using an external 40 MHz oscillator.

Quote:

Pic 18f4620
- ICD2 + MPLAB 7.2
- 3.183

I don't have PCH vs. 3.183, so I installed vs. 3.187. I found that
it doesn't have a 18F4620.H file. I also installed vs. 3.191 and it
doesn't have it either. These are slightly later versions than 3.183,
and if it was in that version, it should be in the later ones as well,
but it's not.

So I question how you can compile for 18F4620 with PCH vs. 3.183.
ckielstra



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

View user's profile Send private message

PostPosted: Mon Oct 24, 2005 1:31 am     Reply with quote

Quote:
what is H4 fuse ?
A short explanation of the fuse names can be found in the file 'PICC\fuses.txt' in your compiler directory.
When using external crystals the following fuses are used:
- XT for frequencies up to 4MHz
- HS for the range 4 - 20MHz
- H4 for the 1(?) to 10MHz range with internal 4 x PLL multiplier (effective 4 - 40MHz).

When using external clock drivers (not crystals) you need other fuse settings but I'm too lazy so you have to figure that out yourself.
tophe59



Joined: 13 Oct 2005
Posts: 32
Location: France

View user's profile Send private message

PostPosted: Mon Oct 24, 2005 1:33 am     Reply with quote

I'm confused. I'm not use the same version at work and at home Embarassed

I have this problem with the 3.235. Excuse me Embarassed

I'm not using 4x Pll but a 40Mhz crystal
ckielstra



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

View user's profile Send private message

PostPosted: Mon Oct 24, 2005 2:14 am     Reply with quote

Quote:
I'm not using 4x Pll but a 40Mhz crystal
40MHz crystals are not supported.
The maximum crystal frequency you can use is 20MHz (with the HS fuse), for some models 25MHz. For higher frequencies use the H4 fuse with crystals up to 10MHz ( x 4 = 40MHz).
tophe59



Joined: 13 Oct 2005
Posts: 32
Location: France

View user's profile Send private message

PostPosted: Mon Oct 24, 2005 2:16 am     Reply with quote

i'm overclocking my 4620 ? Embarassed
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Oct 24, 2005 2:18 am     Reply with quote

tophe59 wrote:
i'm overclocking my 4620 ? Embarassed


Yep - you need to use the PLL if you want to achieve 40MHz.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
tophe59



Joined: 13 Oct 2005
Posts: 32
Location: France

View user's profile Send private message

PostPosted: Mon Oct 24, 2005 2:29 am     Reply with quote

ok thank's ! How to use H4 fuse ? I must have 10 Mhz cristal ?
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Oct 24, 2005 2:45 am     Reply with quote

tophe59 wrote:
ok thank's ! How to use H4 fuse ? I must have 10 Mhz cristal ?


Yes - if you want the PIC to run at 40MHz.
Code:

#fuses  H4

_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
tophe59



Joined: 13 Oct 2005
Posts: 32
Location: France

View user's profile Send private message

PostPosted: Mon Oct 24, 2005 10:01 am     Reply with quote

I have tested with 10MHz cristal and 10Mhz (40Mhz PLL) but not work Crying or Very sad

Always reset when timer interrupt enabled Confused
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Oct 24, 2005 10:14 am     Reply with quote

Well your code shows ...

So I assume the test code is actually larger than you are showing.

Post the smallest code that actually demonstrates the problem.

A couple of alternatives for isolating the problem:

Manual Method A: with the small code, look at the list file produced, specifically around the interrupt handler and look at the code produced.

With tools: Set the debugger up to break in the interrupt handler and single step to see what happens
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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