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

#int_ext not working

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



Joined: 05 Oct 2007
Posts: 31

View user's profile Send private message

#int_ext not working
PostPosted: Tue Feb 26, 2008 6:23 pm     Reply with quote

Hi,
This is really weird because the code below was working a while back, but when I tried incorporating it with some other code, it kept on generating interrupts even without any pin connected to RB0. So I hard reset the whole system and the next time I ran the code, it would not generate any interrupts at all on int_ext. I tried the same code with int_ext1 and it worked.

I measured the voltage on RB0, and it measures around 300mV, thus explaining why it would not interrupt. I don't think the PIC is seeing a rising edge because RB0 is never high even though I make it high. There is a voltage drop somewhere. I did the same thing with int_ext1 and it measures 5 V as expected going from Low to High. I'm just using a switch with a pull-up 10K resistor to simulate an interrupt on the rising edge/falling edges.

Does anyone know
1. Why the PIC would interrupt at random even without any trigger on the pin?
2. Why RB0 is not going to 5V when I switch on the switch. Why is there a voltage drop?

Code:

#include <18F8722.h>
#device ADC=10
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
#fuses HS,NOWDT,NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=N, bits=8)
#use standard_io(B)
#use standard_io(D)
#use standard_io(E)

#define   ENABLE      PIN_B0

long time;
float time2;
int count   =   0;

void main()
{
output_d(0);
output_e(0);
set_tris_d(0x20);
set_tris_e(0);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(ALL_ANALOG);


ext_int_edge(H_TO_L);
enable_interrupts(int_ext);
enable_interrupts(global);

while(1)
{



}  //while

}  //main

#int_ext
void pulse_width(void)
{
   int state   =   0;
   state      =   input(ENABLE);   
   
   if(state   ==   0)   
   {   
      setup_timer_0(RTCC_INTERNAL|RTCC_DIV_128);
      set_timer0(0);
      clear_interrupt(int_rtcc);
      enable_interrupts(int_rtcc);   
      printf("H TO L\r");
      clear_interrupt(int_ext);
      ext_int_edge(L_TO_H);
   }
   if(state   ==   1)
   {
      time   =   get_timer0();
      disable_interrupts(int_rtcc);
      setup_timer_0(RTCC_OFF);
      time2 = ((float)(count * 3.36) + (float)(0.0000512 * time));
      printf("L TO H\r");
      printf("Count = %d\r",count);
      printf("Time  = %lu\r",time);
      printf("Time taken = %f\r",time2);
      clear_interrupt(int_ext);
      count   =   0;
      time   =   0;
      ext_int_edge(H_TO_L);

   }
}

#int_rtcc
void timer_int(void)
{
   count   =   count + 1;
   clear_interrupt(int_rtcc);
   printf("Count = %d\r",count);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 26, 2008 7:11 pm     Reply with quote

Strip down the program so that it consists of only a while(1); statement
in main(). See if it still loads down the switch voltage. This will tell you
if the problem is caused by the program, or if it's the hardware.
cypher



Joined: 05 Oct 2007
Posts: 31

View user's profile Send private message

PostPosted: Wed Feb 27, 2008 7:57 pm     Reply with quote

So I tried doing that and it still loads down the voltage. It's a hardware problem. I tried it on another PIC and now it responds to the interrupts and the voltage is 5 V as expected on RB0. I think that pin might be toast.
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