|
|
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Dec 13, 2011 1:55 pm |
|
|
Don't compile with the "Build Configuration" in MPLAB set to "DEBUG".
The PROTECT, WDT, BROWNOUT, and maybe some other fuses are
automatically disabled for Debug mode.
You can set the Build Configuration in the Drop-Down box at the top of
the main MPLAB window. If this box is "grayed out", then do this:
Shut down MPLAB. Install the latest CCS "plug-in" for MPLAB, and
re-start MPLAB. You should now be able to select Release or Debug.
http://www.ccsinfo.com/downloads/setup_mplab_plugin.exe
MPLAB defaults to a build configuration of DEBUG. To change this
behavior so it defaults to RELEASE mode, see the instruction in this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=46818&start=21 |
|
|
zotymo
Joined: 12 Dec 2011 Posts: 5
|
|
Posted: Tue Dec 13, 2011 2:07 pm |
|
|
You solved my problems. Thank you again. |
|
|
doguhanpala
Joined: 05 Oct 2016 Posts: 120
|
|
Posted: Fri Oct 21, 2016 5:38 am |
|
|
Ttelmah wrote: |
Now, you don't say what pin the signal is actually on, or what else is connected to PORTB. You do understand that as you have it programmed _every_ input pin on PORTB _will_ trigger the interrupt. So B0,1,4,5,6 & 7 will all trigger the event if they change in level. If any are floating they will trigger at times. Do you really want the interrupt triggers by six sources?. This is the 'point' of the more complex setting when enabling the interrupt.
For example:
ENABLE_INTERRUPTS(INT_RB4_H2L);
Will set INT_RB to only trigger when pin B4 goes low.
So what pin is the signal on, and which direction will it change when you want to trigger the event?.
Best Wishes |
I have a few questions. I want to increase counter value each time on int_rb interrupt, but i want to do it from just RB4.
As i understand, ENABLE_INTERRUPTS(INT_RB4_H2L) line, does this work for me ? If i want to use just RB5, i change the code as ENABLE_INTERRUPTS(INT_RB5_H2L) ?
If i want to use both pins i have to write ENABLE_INTERRUPTS(INT_RB4_H2L | INT_RB5_H2L)
Are these 2 assumptions correct?
I did some research and found some sources that say the pic can not understand which pin changed.
http://www.just.edu.jo/~amjaradat/_ee445/_doc/interrupt-rb4-7.pdf
also another source says that.
https://www.ccsinfo.com/faq.php?page=int_ext_button (same but without example).
So i could not understand which is correct. Is it possible or not possible? And if possible, how? My compiler doesn't accept the line: ENABLE_INTERRUPTS(INT_RB4_H2L)
I thought it is because of 18f2550 but it accepts int_rb line and works properly. I read the datasheet and it says there is int_rb for 18f2550.
Another possibility is that Ttelmah and sources say the same thing but i misunderstood what Ttelmah said. Can anyone explain please?
Note: I use 18f2550.
Best wishes
Doğuhan |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Fri Oct 21, 2016 7:08 am |
|
|
Key is different chips....
The original PIC INT_RB, had no ability to know 'which' pin triggers the interrupt. This is normally only on RB4 to RB7. It also worked on every change (both high to low, and low to high), on all the pins enabled as inputs. This is the INT_RB on the 2550/4550, and probably 90% of PIC's.
Some later chips have an 'improved' INT_RB (and often an INT_RA as well). On these there is a separate mask to say which pins are to be included, and often a mask to specify which edge(s) are used. These chips also have a separate latch register, to say which pin has triggered. These then offer the ability to set these masks with the INT_RB4_H2L type syntax.
On the standard chips. Only INT_RB. No edges or bits.
On the 'improved RB' chips. Settings like INT_RB4, and INT_RB4_H2L.
On these later chips you also have to clear the latch yourself. This is the IOCBF register that PCM_programmer is pointing to. It's left 'uncleared', since it then allows your INT_RB code to check which bit has caused the interrupt. |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Sat Oct 22, 2016 7:39 pm |
|
|
I am using port B interrupt in two ways:
* Using RB4 as input for the interrupt and RB5,6,7 as outputs so I know the interrupt is from RB4
* Using more than one RB for interrupt, for example RB4 & RB5 and testing the changes of the pins in the isr
For both cases if I want just interrupt H to L (or L to H) ignoring the other case
Best wishes
Joe |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Sun Oct 23, 2016 12:41 am |
|
|
If your PIC only has INT_RB, you can't. INT_RB, is an interrupt on change. It'll trigger on _every_ change. (High to low, and low to high). You will just have to add a test in the routine for the edge.
So on a PIC like a 4550, just using INT_RB
Code: |
void INT_RB(void)
{
static int1 old_RB4=1;
static int1 old_RB5=1;
//Assuming lines are pulled up, so idle high.
if (input(PIN_B4)==1)
{
//input is high
if (old_RB4==0)
{
//low to high
old_RB4=1;
//do nothing except record the level
}
}
else
{
//input is low
if (old_RB4==1)
{
//here signal has changed high to low
old_RB4=0;
//your code here for RB4 having dropped
}
}
//Now the same for B5
if (input(PIN_B5)==1)
{
//input is high
if (old_RB5==0)
{
//low to high
old_RB5=1;
//do nothing except record the level
}
}
else
{
//input is low
if (old_RB5==1)
{
//here signal has changed high to low
old_RB5=0;
//your code here for RB5 having dropped
}
}
}
|
This is only a handful of machine instructions. |
|
|
|
|
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
|