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

18f4520 : EXT interrupt not working

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



Joined: 26 Feb 2007
Posts: 2

View user's profile Send private message

18f4520 : EXT interrupt not working
PostPosted: Mon Feb 26, 2007 5:15 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 26, 2007 12:42 pm     Reply with quote

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));
  }

}
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