|
|
View previous topic :: View next topic |
Author |
Message |
josedebrest
Joined: 26 Feb 2007 Posts: 2
|
18f4520 : EXT interrupt not working |
Posted: Mon Feb 26, 2007 5:15 am |
|
|
Hello, I'm new to CCS compiler and I don't understand why my code dont work (it's on a picdem2 board). I tried to get an external interrupt when pressing a button which is connected to RB0. the strangest thing is that if i put the interrupt on rb1 it is working.
Tanks for your answer
J.M.
Code: |
#INT_EXT
void ext_isr(void)
{
output_high(PIN_B2);
}
void main(void)
{
output_drive(PIN_B0);
output_low(PIN_B0);
input(PIN_B0);
ext_int_edge(0,L_TO_H); // init interrupt triggering for button press
enable_interrupts(INT_EXT);// turn on interrupts
enable_interrupts(GLOBAL);
output_drive(PIN_B1);
output_drive(PIN_B2);
while(1){
output_bit(PIN_B1,input(PIN_B0));
;}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 26, 2007 12:42 pm |
|
|
I revised your program to clean it up, but it still doesn't work.
The reason is that PicDem2-Plus has an LED on Pin B0.
So even though the push-button switch circuit has a 4.7K pullup
on Pin B0, the forward voltage drop of the LED holds the pin
at about 2.0v. This is too low. It never allows the External
interrupt input on the PIC to reach a "logic high" level.
Therefore the External interrupt is never going to be triggered.
If you pull off the jumper to the LEDs and then measure the
voltage levels with a voltmeter, then it will work. It's not as
convenient (or fun) as with the LEDs, but at least you can see
that it works.
It's unfortunate the the PicDem2-Plus board is built this way.
Also, I noticed that on the very latest version of that board,
called the "Rohs update", that Microchip has changed the
circuits quite a bit. They've moved pushbutton S3 from
pin B0 to pin B1. What were they thinking ? You don't mess
with a demo board. Now all programs written for the PicDem2-Plus
won't work anymore. People will now have to have two versions,
based on the board revision. That, and the new power enable
pin on the LCD and the fact that the new LCD's busy flag is
not readable. I don't know.... What is up with Microchip ?
Who is the project manager on this thing ? They've gone off
into space.
Code: |
#include <18F452.H>
#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#INT_EXT
void ext_isr(void)
{
output_high(PIN_B2);
}
//=======================
void main()
{
ext_int_edge(0, L_TO_H);
clear_interrupt(INT_EXT);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(1)
{
output_bit(PIN_B1, input(PIN_B0));
}
} |
|
|
|
|
|
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
|