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

RB change interrupt

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



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

RB change interrupt
PostPosted: Tue Jun 28, 2005 1:34 am     Reply with quote

hi,

I want to use the RB change interrupt on port RB4.

RB5, RB6 ,RB7 are configured as outputs and RB4 is configured as an input.

So if state of RB5 .. RB7 changes as output, will the RB_isr() fire? This is unwanted.

The goal of this is, while the processor sleeps < 5uA; he will wake of RB4 going low, this means that the battery voltage is below 3.15; when this has happened, the PIC should do some things and then goes to sleep again.

When RB4 goes high again (I need some kind of schmitt trigger input), the battery voltage is back OK and the PIC should do some things again, and go back to sleep. Is that all possible?

many thanks
Ttelmah
Guest







PostPosted: Tue Jun 28, 2005 6:50 am     Reply with quote

RB change will fire if any of the top 4 bits change.
You can 'program round' it with something like:

disable_interrupts(INT_RB);
output_high(PIN_B4)
dummy=input_B;
clear_interrupt(INT_RB);
enable_interrupts(INT_RB);

Potentially an external trigger, will be 'missed' if it occurs in the instructions represented by this, but at least you won't get the interrupt when you output data. Obviously you could add a manual test for the RB4 but having changed to cover this contingency.

Best Wishes
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Tue Jun 28, 2005 8:05 am     Reply with quote

dear,

this I read in AN566

Quote:
The feature this application note will focus on is the
Interrupt on Change of the PORTB pins. This “interrupt
on change” is triggered when any of the RB7:RB4 pins,
configured as an input, changes level.


=> configured as an input; so if RB5 - configured as an output - changes from L to H, will the isr() fire?
Ttelmah
Guest







PostPosted: Tue Jun 28, 2005 8:44 am     Reply with quote

You don't mention what chip is involved?.
You can see how the logic works, by looking at the layout of the I/O pins concerned. The behaviour changes between chips. A couple of the very early chips simply compare the input with the latched value, to trigger the interrupt. Latter chips generally have an extra 'and' gate, that disable the comparison on pins configured as an output, but some also have the ability to enable the comparison on a 'per pin' basis.
You need to check the data sheet for your specific chip.

Best Wishes
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Tue Jun 28, 2005 8:54 am     Reply with quote

Dear,

I just tested it. It does fire when RB5, RB6 and RB7 change state as an output; that is unwanted!

In main I state

Code:
set_tris_b(0x11);                // B0 en B4 zijn inputs


I'm using RB5, RB6 and RB7 to scan my keyboard, as outputs! :\

R7 = RB5
R8 = RB6
R9 = RB7

Code:
 // RIJ 7
         Output_low(R7);
         temp = input_d();
         Output_float(R7);
         if ((buffer[6] & temp) != buffer[6])
            Pressed = TRUE;
         buffer[6] = buffer [6] & temp;
         if (temp != 255)
            Alles_los = FALSE;

         // RIJ 8
         Output_low(R8);
         temp = input_d();
         Output_float(R8);
         if ((buffer[7] & temp) != buffer[7])
            Pressed = TRUE;
         buffer[7] = buffer [7] & temp;
         if (temp != 255)
            Alles_los = FALSE;

         // RIJ 9
         Output_low(R9);
         temp = input_d();
         Output_float(R9);
         if ((buffer[8] & temp) != buffer[8])
            Pressed = TRUE;
         buffer[8] = buffer [8] & temp;
         if (temp != 255)
             Alles_los = FALSE;


I'll try your workaround and post the results after checking the datasheet (didn't fiind the part on interrupts that easy, I'll look again)
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Tue Jun 28, 2005 9:05 am     Reply with quote

Code:
Four of the PORTB pins, RB7:RB4, have an interrupton-
change feature. Only pins configured as inputs can
cause this interrupt to occur (i.e., any RB7:RB4 pin
configured as an output is excluded from the interrupton-
change comparison). The input pins (of RB7:RB4)
are compared with the old value latched on the last
read of PORTB. The “mismatch” outputs of RB7:RB4
are OR’ed together to generate the RB port change
interrupt with flag bit RBIF (INTCON<0>).


Only inputs :\ Still it fires continuously
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Wed Jun 29, 2005 8:10 am     Reply with quote

Hi

if I state:

output_float(PIN_B5);

can that cause an interrupt RB on change?

My program is continuously interrupting
Ttelmah
Guest







PostPosted: Wed Jun 29, 2005 8:17 am     Reply with quote

If the pin actually is floating (not driven by something else), then 'yes'. Enable the weak 'pull-ups' on port B, and it'll ensure that a pin that is floating stays 'high'. All 'output_float' does, is set the pin as an input...

Best Wishes
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