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

Setting multiple interrupt bits and global at same time.

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



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

Setting multiple interrupt bits and global at same time.
PostPosted: Sat Jun 26, 2004 11:43 am     Reply with quote

Is there any problem?

like:

enable_interrupts(int_ext|int_timer0|global);
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jun 26, 2004 12:02 pm     Reply with quote

Quote:
enable_interrupts(int_ext|int_timer0|global);

It won't work. If you look at the .H file for your PIC,
you'll see that the INT_xxx definitions consist of the
register address in the high byte and a bitmask in
the lower byte.

If you OR together different constants, you could
destroy the register address. If you OR together
different bitmasks, the compiler will only use the
first '1' bit that it finds. It will ignore the others.

In short, the compiler is not designed to allow
multiple INT_xxx constants to be OR'ed together.
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Sat Jun 26, 2004 12:43 pm     Reply with quote

I tried that with a 18f452.

#byte INTCON = 0xFF2
enable_interrupts(int_ext|int_timer0|global);

Generated code:
....................enable_interrupts(int_ext|int_timer0|global);
084A: MOVLW F0
084C: IORWF FF2,F

F0=11110000 // sets GIE,PIE,TMR0IE,INT0IE

And works Smile

But I dont know if I should set GIE and another int at the same.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jun 26, 2004 2:54 pm     Reply with quote

Before I posted, I did a test with the 16F877 and PCM 3.190
and it didn't work.
ckielstra



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

View user's profile Send private message

PostPosted: Sat Jun 26, 2004 4:02 pm     Reply with quote

I guess Future was lucky in choosing his combination of interrupts.

For the 18F452:
Code:
#define GLOBAL                    0xF2C0
#define INT_RTCC                  0xF220
#define INT_TIMER0                0xF220
#define INT_TIMER1                0x9D01
#define INT_TIMER2                0x9D02
#define INT_TIMER3                0xA002
#define INT_EXT                   0xF210
.
.
.

It only works because GLOBAL, RTCC and INT_EXT are all in the same register. Replacing INT_TIMER0 by INT_TIMER1 would have resulted in disaster.

I personally disagree off using undocumented features like this because it might result to hard to find bugs in the future, for example when upgrading to a new compiler version or other chip. You have to consider if this future trouble is worth the 4 bytes you save now.
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