View previous topic :: View next topic |
Author |
Message |
tophe59
Joined: 13 Oct 2005 Posts: 32 Location: France
|
enabling timer interrupt cause reset |
Posted: Sun Oct 23, 2005 9:12 am |
|
|
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
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
|
|
Posted: Sun Oct 23, 2005 10:39 am |
|
|
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
|
|
Posted: Sun Oct 23, 2005 10:49 am |
|
|
Thank's but the interrupt code is already before de main.
I change my first message.
Help again |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 23, 2005 1:01 pm |
|
|
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
|
|
Posted: Sun Oct 23, 2005 11:47 pm |
|
|
my configuration:
- Pic 18f4620
- ICD2 + MPLAB 7.2
- 3.183
what is H4 fuse ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 24, 2005 1:08 am |
|
|
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
|
|
Posted: Mon Oct 24, 2005 1:31 am |
|
|
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
|
|
Posted: Mon Oct 24, 2005 1:33 am |
|
|
I'm confused. I'm not use the same version at work and at home
I have this problem with the 3.235. Excuse me
I'm not using 4x Pll but a 40Mhz crystal |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Oct 24, 2005 2:14 am |
|
|
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
|
|
Posted: Mon Oct 24, 2005 2:16 am |
|
|
i'm overclocking my 4620 ? |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Mon Oct 24, 2005 2:18 am |
|
|
tophe59 wrote: | i'm overclocking my 4620 ? |
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
|
|
Posted: Mon Oct 24, 2005 2:29 am |
|
|
ok thank's ! How to use H4 fuse ? I must have 10 Mhz cristal ? |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Mon Oct 24, 2005 2:45 am |
|
|
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.
_________________ 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
|
|
Posted: Mon Oct 24, 2005 10:01 am |
|
|
I have tested with 10MHz cristal and 10Mhz (40Mhz PLL) but not work
Always reset when timer interrupt enabled |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Mon Oct 24, 2005 10:14 am |
|
|
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!! |
|
|
|