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

IOC strange behavior

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








IOC strange behavior
PostPosted: Thu Jul 30, 2009 3:15 am     Reply with quote

Hello,

Although my interrupt routine works, I don't understand it's behavior.

I need the interrupt-on-change at a certain Pin (RA4). I thought that only edges would cause the IOC to start and it only would happen once per one edge.

So, I have the following simple code:
Code:

#int_RA
   void ext_isr() {
      INT_CNT++;
   }

main(){

   EXT_INT_EDGE(H_TO_L);
   enable_interrupts(INT_RA4);
   enable_interrupts(GLOBAL);

   INT_CNT = 0;

   while (TRUE){
     //here is my code}
   }


What happens is, the counter INT_CNT increments as long as RA4 is LOW. Using a button, the longer it is pressed and pulls to GND, the higher is the number of my counter. I thought it would just count ONE for ONE edge (even the switch bounces, it just could be three or four, but it is thousands for a short pressing.
So, the only explanation could be, that it is not edge triggered but pulse triggered.

Regards

Dieter
Bulova



Joined: 30 Jul 2009
Posts: 2

View user's profile Send private message

Further info
PostPosted: Thu Jul 30, 2009 4:46 am     Reply with quote

Hello,

sorry I forgot to mention:

Compiler:
CCS PCM C Compiler, Version 3.239

Microcontroller:
PIC12F683

Best regards

Dieter
Bulova



Joined: 30 Jul 2009
Posts: 2

View user's profile Send private message

Solved
PostPosted: Thu Jul 30, 2009 5:15 am     Reply with quote

Hello,

I found the answer by myself. Like so often, the answer is written in the datasheet:

Quote:
... clears the interrupt by
a) Any read or write of GPIO. This will end the mismatch condition.
b) Clear the flag bit GPIF.

A mismatch condition will continue to set flag bit GPIF.


This also answers other questions of my code revisions, where the RA4 is read within the ISR and causes the interrupt to be stopped after its execution. And thus causes "normal" behavior.

Regards

Dieter
Ttelmah
Guest







PostPosted: Thu Jul 30, 2009 6:17 am     Reply with quote

A forum search would have found this.
The 'B' changed interrupt, is one of about three common interrupts, where there are hardware things that 'must' be done in the interrupt handler.
Serial receive - you must read the character.
Serial transmit - you must either write another character, or turn off the interrupt.
Port B receive - read the port.

Glad you found it from the data sheet.

Best Wishes
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