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

#INT_xxx HIGH

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








#INT_xxx HIGH
PostPosted: Wed Sep 14, 2005 2:13 pm     Reply with quote

Hello everybody,

Has anyone tried to use the #INT_xxx HIGH? (version 2.231 or later)Iīve tried to use it and iīve got some trouble.

When I put #DEVICE HIGHT_INTS on my code. It doesnīt run. When the program runs the first interruption, it locks.

Will I have to setup my INTs manually (such a fast INT)? Confused

Thanks for any help.
bfemmel



Joined: 18 Jul 2004
Posts: 40
Location: San Carlos, CA.

View user's profile Send private message Visit poster's website

INT_xxx HIGH?
PostPosted: Wed Sep 14, 2005 2:49 pm     Reply with quote

If you mean a FAST int then the answer is yes; you must do all the work yourself. Where as the global interrupt hadler saves all sorts of registers, the FAST handler does nothing, if you need a register saved you need to do it yourself. Look at the assembly code generated by the compiler to see what registers it is using in your interrupt routine.

You said that your code is locking up. I would imagine that if you looked at the code you might find that it is re-entering the interrupt routine as soon as it leaves. Try toggling a bit in your interrupt routine and watching it on the scope to see if this is the case. I found this with when I tried to implement a FAST interrupt. Try clearing the appropriate interrupt bit manually in your code before you exit the routine.
Ttelmah
Guest







PostPosted: Wed Sep 14, 2005 2:56 pm     Reply with quote

What are you doing in your interrupt handler?.
I tried a couple of experiments with it, and it seemed to work OK. It develops a second global routine, and correctly saved the registers. However it doesn't appear to generate the default 'interrupt protection', that is applied if the same routine is used in the main code, and in an interrupt handler, between the two interrupt handlers, so you have to be careful to ensure that any routines used in both locations are coded as 'inline', or disable the high priority interrupts temporarily in the low priority code. Remember also that it still has the high overhead of a standard handler...

Best Wishes
Pbernardi



Joined: 14 Sep 2005
Posts: 12

View user's profile Send private message

PostPosted: Wed Sep 14, 2005 3:06 pm     Reply with quote

(The post is mine, i wasnīt logged in)

Well, the HIGH is a recent implementation. Looks very similar to FAST, buts the readme says that a high interruption can stop another interruption (such a FAST), but the registers are saved.

So, I though I didīt have to configurate manually the INTs...do I have to do it?
_________________
Paulo Bernardi
Pbernardi



Joined: 14 Sep 2005
Posts: 12

View user's profile Send private message

PostPosted: Wed Sep 14, 2005 3:15 pm     Reply with quote

Ttelmah,

Well, actually I donīt have a interrupt handler. Crying or Very sad So I relly need?

It would be so nice if this "HIGH" just modify the priority, and let the athers things untouched. Twisted Evil

Thanks for helping.
_________________
Paulo Bernardi
Pbernardi



Joined: 14 Sep 2005
Posts: 12

View user's profile Send private message

PostPosted: Wed Sep 14, 2005 4:13 pm     Reply with quote

Well, I think it can be a bug.

The CCS generated the following code:

Code:
0000    EF04     GOTO 0x5c08
  0008    EF5E     GOTO 0xbc
  000C    0000     NOP
  000E    0000     NOP
  0010    0000     NOP
  0012    0000     NOP
  0014    0000     NOP
  0016    0000     NOP
  0018    CFE8     MOVFF 0xfe8, 0x5
  001C    CFD8     MOVFF 0xfd8, 0x6
  0020    CFE0     MOVFF 0xfe0, 0x7
  0024    0100     MOVLB 0
  0026    CFE9     MOVFF 0xfe9, 0xd
  002A    CFEA     MOVFF 0xfea, 0x8
  002E    CFE1     MOVFF 0xfe1, 0x9
  0032    CFE2     MOVFF 0xfe2, 0xa
  0036    CFD9     MOVFF 0xfd9, 0xb
  003A    CFDA     MOVFF 0xfda, 0xc
  003E    CFF3     MOVFF 0xff3, 0x14
  0042    CFF4     MOVFF 0xff4, 0x15
  0046    CFFA     MOVFF 0xffa, 0x16
  004A    C000     MOVFF 0, 0xf
  004E    C001     MOVFF 0x1, 0x10
  0052    C002     MOVFF 0x2, 0x11
  0056    C003     MOVFF 0x3, 0x12
  005A    C004     MOVFF 0x4, 0x13
  005E    A2A0     BTFSS 0xfa0, 0x1, ACCESS
  0060    EF35     GOTO 0x6a
  0064    B2A1     BTFSC 0xfa1, 0x1, ACCESS
  0066    EF1C     GOTO 0x238
  006A    A09D     BTFSS 0xf9d, 0, ACCESS
  006C    EF3B     GOTO 0x76
  0070    B09E     BTFSC 0xf9e, 0, ACCESS
  0072    EFBD     GOTO 0x17a
  0076    C00F     MOVFF 0xf, 0
  007A    C010     MOVFF 0x10, 0x1
  007E    C011     MOVFF 0x11, 0x2
  0082    C012     MOVFF 0x12, 0x3
  0086    C013     MOVFF 0x13, 0x4
  008A    C00D     MOVFF 0xd, 0xfe9
  008E    C008     MOVFF 0x8, 0xfea
  0092    C009     MOVFF 0x9, 0xfe1
  0096    C00A     MOVFF 0xa, 0xfe2
  009A    C00B     MOVFF 0xb, 0xfd9
  009E    C00C     MOVFF 0xc, 0xfda
  00A2    C014     MOVFF 0x14, 0xff3
  00A6    C015     MOVFF 0x15, 0xff4
  00AA    C016     MOVFF 0x16, 0xffa
  00AE    C005     MOVFF 0x5, 0xfe8
  00B2    C007     MOVFF 0x7, 0xfe0
  00B6    C006     MOVFF 0x6, 0xfd8
  00BA    0010     RETFIE 0
  00BC    0100     MOVLB 0
  00BE    CFE9     MOVFF 0xfe9, 0x1e
  00C2    CFEA     MOVFF 0xfea, 0x19
  00C6    CFE1     MOVFF 0xfe1, 0x1a
  00CA    CFE2     MOVFF 0xfe2, 0x1b
  00CE    CFD9     MOVFF 0xfd9, 0x1c
  00D2    CFDA     MOVFF 0xfda, 0x1d
  00D6    CFF3     MOVFF 0xff3, 0x25
  00DA    CFF4     MOVFF 0xff4, 0x26
  00DE    CFFA     MOVFF 0xffa, 0x27
  00E2    C000     MOVFF 0, 0x20
  00E6    C001     MOVFF 0x1, 0x21
  00EA    C002     MOVFF 0x2, 0x22
  00EE    C003     MOVFF 0x3, 0x23
  00F2    C004     MOVFF 0x4, 0x24
  00F6    A4A0     BTFSS 0xfa0, 0x2, ACCESS
  00F8    EF81     GOTO 0x102
  00FC    B4A1     BTFSC 0xfa1, 0x2, ACCESS
  00FE    EFFE     GOTO 0x5fc
  0102    C020     MOVFF 0x20, 0
  0106    C021     MOVFF 0x21, 0x1
  010A    C022     MOVFF 0x22, 0x2
  010E    C023     MOVFF 0x23, 0x3
  0112    C024     MOVFF 0x24, 0x4
  0116    C01E     MOVFF 0x1e, 0xfe9
  011A    C019     MOVFF 0x19, 0xfea
  011E    C01A     MOVFF 0x1a, 0xfe1
  0122    C01B     MOVFF 0x1b, 0xfe2
  0126    C01C     MOVFF 0x1c, 0xfd9
  012A    C01D     MOVFF 0x1d, 0xfda
  012E    C025     MOVFF 0x25, 0xff3
  0132    C026     MOVFF 0x26, 0xff4
  0136    C027     MOVFF 0x27, 0xffa
  013A    0011     RETFIE 0x1


So, basically there are two parts, as comentted before.

The first(0018 - 00BA) is for the "low priority" and the second (00BC- 013A) is for the "high priority" interruption.

Deppuring the code, i saw when the "high priority" returns (line 013A), it returns to line 0x08, and this line calls the high priority interruption again, in a infinite loop.

Is this my fail or a bug? Iīm using A 18F452
_________________
Paulo Bernardi
bfemmel



Joined: 18 Jul 2004
Posts: 40
Location: San Carlos, CA.

View user's profile Send private message Visit poster's website

Interrupt routine in a loop
PostPosted: Wed Sep 14, 2005 4:31 pm     Reply with quote

Pbernardi wrote:
Quote:

Deppuring the code, i saw when the "high priority" returns (line 013A), it returns to line 0x08, and this line calls the high priority interruption again, in a infinite loop.


I still think the interrupt bit is not being cleared. Can you find in the assembly listing where the interrupt bit for your particular interrupt is being cleared? If not then, maybe you need to clear it yourself the same way you would do if you were using the NOCLEAR option.

- Bruce
Pbernardi



Joined: 14 Sep 2005
Posts: 12

View user's profile Send private message

PostPosted: Wed Sep 14, 2005 4:48 pm     Reply with quote

I clear the flag in each interruption.

But bfemmel, look at it and see if it isnīt strange.

The program goes to line 0008 when the timer1 overflows.

But the timer1 is a low priority interruption, and the adress 0008 is for high priority interruption.

So, actually it doesnīt run any interruption! (the flag for timer1 is on low priority code - 0018, so it doesnīt enter the function)

It would be easy to debug if were the flag. Iīd put a breakpoint inside each interruption and the program would find it, but it doesīn happen.
_________________
Paulo Bernardi
bfemmel



Joined: 18 Jul 2004
Posts: 40
Location: San Carlos, CA.

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 14, 2005 5:23 pm     Reply with quote

Pbernardi wrote:
Quote:
The program goes to line 0008 when the timer1 overflows.

But the timer1 is a low priority interruption, and the adress 0008 is for high priority interruption.


So, it actually is the bit not being cleared but just not like we thought. If the interrupt is vectored to the wrong handler there is not much you can do about that. You are entering the routine because your timer1 interrupt has triggered an interrupt but by going into the fast interrupt routine, the wrong bit is being cleared! The timer1 interrupt is still set and around you go as soon as you get out. Sounds like a compiler bug to me. Rolling Eyes

Could you post the interrupt code at least if not the entire code so we could see the declarations for all your interrupts. Do you use prototypes in another *.h file. If so make sure that you declare the same things, like "INT_XXX" and "INT_XXX FAST" ahead of those declarations also.

I gave up on FAST interrupts a while back and made do with only one level of interrupt. I ran into the same problem you have now. I solved it by getting rid of my need to run a FAST interrupt! Laughing
Ttelmah
Guest







PostPosted: Thu Sep 15, 2005 4:05 am     Reply with quote

It most definately should not return to address 0008. The instruction here is a goto, not a 'call', so the Retfie should return to the original caller.
I have a test program that I originally used to try this feature, which seems to work fine. I had the transmit buffer empty interrupt set as 'high', and the timer2 interrupt using the normal handler. Both correctly cleared the interrupt bits concerned, and vectored to the right routines:

Code:

.................... #INT_TIMER2
.................... void tick(void) {
....................    if (time) --time;
018C:  MOVF   28,W
018E:  IORWF  29,W
0190:  BZ    019C
0192:  MOVF   28,W
0194:  BTFSC  FD8.2
0196:  DECF   29,F
0198:  DECF   28,F
....................    else time=1000;
019A:  BRA    01A4
019C:  MOVLW  03
019E:  MOVWF  29
01A0:  MOVLW  E8
01A2:  MOVWF  28
.................... }
....................
01A4:  BCF    F9E.1
01A6:  GOTO   006E

.................... #INT_TBE HIGH /* Transmit buffer empty interrupt */
.................... void TXINT(void) {
....................    if (isempty(RSTbuff,RSTin,RSTout,STBUFF)) {
*
0160:  MOVF   4B,W
0162:  SUBWF  4A,W
0164:  BNZ   016A
....................       DISABLE_INTERRUPTS(INT_TBE);
0166:  BCF    F9D.4
....................    }
....................    else {
0168:  BRA    0186
....................       TXREG=ifrombuff(RSTbuff,RSTin,RSTout,STBUFF);
016A:  MOVFF  4B,4D
016E:  INCF   4B,F
0170:  MOVLW  1F
0172:  ANDWF  4B,F
0174:  CLRF   03
0176:  MOVF   4D,W
0178:  ADDLW  2A
017A:  MOVWF  FE9
017C:  MOVLW  00
017E:  ADDWFC 03,W
0180:  MOVWF  FEA
0182:  MOVFF  FEF,FAD
....................    }
.................... }
....................
0186:  BCF    F9E.4
0188:  GOTO   00FA


This won't run in the simulator (because it won't emulate the hardware UART), but on a ICE system, worked perfectly.
Remember though, that there are a lot of caveats about using 'high'. Some chips have problems with particular combinationsof these interrupts (read the errata sheets), and also if 'high' is enabled, and you use an 'int0' interrupt, this _automatically_ becomes a high priority interrupt on chips like the 18F452, even if you don't specify this. I'd be very 'wary' about whether the compiler will figure this out for itself, and would always set this interrupt to 'high' if the high priority feature is used. This might be the cause of the problems seen by the original poster, since it'd result in this interrupt arriving at the wrong handler, and a permanent loop...
Some very careful reading of the data sheets, and errata, is needed before using this feature.

Best Wishes
Pbernardi



Joined: 14 Sep 2005
Posts: 12

View user's profile Send private message

PostPosted: Thu Sep 15, 2005 5:12 am     Reply with quote

Well, I found the light. Idea

I thought the CCS could be missconfigurating the priority bits for any reason and - bingo. The priorities were wrong.

So I configurated it by myself.

Ttelmah and bfemmel, many thanks for helping.
_________________
Paulo Bernardi
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