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

18F46K22 EXTERNAL INT [Solved]

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



Joined: 27 Apr 2008
Posts: 168

View user's profile Send private message Send e-mail MSN Messenger

18F46K22 EXTERNAL INT [Solved]
PostPosted: Thu May 26, 2022 8:07 am     Reply with quote

Hi there.

Do I need to do any other thing when I use external int 0 on this chip? Because I feed the RB0 with 1Hz pulse, it seems that the ISR ignores the low state of the pulse.

Code:
   SETUP_ADC_PORTS(NO_ANALOGS);
    SETUP_COMPARATOR(NC_NC_NC_NC);
      SETUP_COUNTERS(RTCC_INTERNAL,RTCC_DIV_16);
   SETUP_TIMER_1(T1_DISABLED|T1_DIV_BY_1);   
      SETUP_TIMER_2(T2_DISABLED,0xFF,16);
      SETUP_TIMER_3(T3_DISABLED|T3_DIV_BY_8);
      SETUP_TIMER_4(T4_DISABLED,0xFF,16);
      SETUP_TIMER_5(T5_DISABLED|T5_DIV_BY_8);
      SETUP_TIMER_6(T6_DISABLED,0xFF,16);
   SET_TRIS_A(0b00000000); 
   SET_TRIS_B(0b11100001);
   SET_TRIS_C(0b11111111);
   SET_TRIS_D(0b11111111);
   SET_TRIS_E(0b11111111);
   PORT_B_PULLUPS(FALSE);
   EXT_INT_EDGE(0, L_TO_H);
   SETUP_CCP1(CCP_CAPTURE_RE);
   ENABLE_INTERRUPTS(INT_EXT);   //ENABLE RTC INTERRUPTS
//   ENABLE_INTERRUPTS(INT_CCP1); //INABLE INFRARED INTERRUPTION
   ENABLE_INTERRUPTS(GLOBAL); //ENABLE GLOBAL INTERRUPTS


Code:
#INT_EXT   //RTC SR
void RB0_ISR(void)
   {
   SEGUNDOS++;
   if(SEGUNDOS>=60)
      {
      SEGUNDOS=0;
      MINUTOS++;
      }
   if(MINUTOS==60)
        {
      MINUTOS=0;
      HORAS++;
      }
   if(HORAS==24)HORAS=0;
   CLK=1;   
   }


When bit CLK is set, I do some other things on the program, but, somehow, it seems to be always been set on the ISR.

Taking a look at datasheet, I saw that RB0 is also used on SR LATCH and ECCP, but I cannot see any relation to these functions.

Regards;
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 26, 2022 10:17 am     Reply with quote

What is the Vdd voltage of your PIC ?
What are the voltage levels (high and low) of the 1 Hz pulse ?

If your PIC is running at 5.0v, the 1 Hz pulse needs to be at
least 4.0v for the high level. Ideally it should be higher.

The low voltage level should be a max of 0.8v and ideally lower.
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Thu May 26, 2022 10:53 am     Reply with quote

Er. Not sure what you mean, but it will 'ignore the low state'. The
interrupt will trigger when the signal goes high....
rudy



Joined: 27 Apr 2008
Posts: 168

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Thu May 26, 2022 11:29 am     Reply with quote

Weird!!!!

I may did some mistake. Suddenly, the problem vanishes....

The 1HZ is 0-5V.

It is OK now, working fine.

Regards!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 26, 2022 11:41 am     Reply with quote

Quote:
EXT_INT_EDGE(0, L_TO_H);

In your original posted code, show above, you have it set to trigger on
the rising edge. When it goes from low to high, it will trigger.

Quote:
interrupt will trigger when the signal goes high....

It's doing exactly what you told it to do above.
rudy



Joined: 27 Apr 2008
Posts: 168

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Thu May 26, 2022 11:46 am     Reply with quote

No issues..

There is an BC-548 transistor driving the signal before it enter on RB0, the +5V was loose on the collector, and that's was the problem.

I sorry to disturb.. Once that this thread don't help much, please delete it from the forum.

I apologize the mistake.

Regards,
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