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

TSOP 1740 & pic 16F887

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 22, 2009 3:44 pm     Reply with quote

Also, in your #INT_RB function, you need to read Pin B1 to clear the
"mismatch" condition. The "mismatch" condition is what generates
the INT_RB interrupt. You need to clear it so the PIC will be ready
to detect the next "change" (edge) tha occurs on pin B1. It's cleared
by reading the pin. Add the lines shown in bold below.
Quote:

#INT_RB
void ext_isr()
{
int8 temp;

if(irdone) return;
for(ircount=0;ircount<=13;ircount++)
{
irframes[ircount]=get_timer1();
}
//irframes[ircount++]=get_timer1();
if(ircount>=13) //if 13 triggers(ie 12 bits+start) found
irdone=true; //set "done" flag
set_timer1(0); //restart timer for new bit
enable_interrupts(int_timer1);

temp = input(PIN_B1);
}

I didn't look at your code and try to figure out what you're doing.
I just wanted to mention this one thing.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Feb 23, 2009 3:23 am     Reply with quote

Yes, a very important hint by PCM Programmer. I wrongly assumed, you would be using an external edge sensitive interrupt. Cause you are actually using RB interrupt, do you intend to detect both edges? If not, the code has to be corrected to ignore the other edge for timing measurement.
pyu



Joined: 04 Feb 2009
Posts: 51

View user's profile Send private message Yahoo Messenger

PostPosted: Mon Feb 23, 2009 4:07 am     Reply with quote

Thanks for reply FvM and PCM programmer Smile

Quote:
You need to clear it so the PIC will be ready
to detect the next "change" (edge) tha occurs on pin B1. It's cleared
by reading the pin.

I had made some corrections in my code.
Code:

#INT_RB                       //IR bits detected by edge triggering
void ext_isr()
{
   int8 temp;
   if(irdone) return;

   irframes[ircount++]=get_timer1();
   if(ircount>=13)                  //if 13 triggers(ie 12 bits+start) found
      irdone=true;               //set "done" flag
   set_timer1(0);                  //restart timer for new bit
   enable_interrupts(int_timer1);      //(is this necessary? I dont really know)
    temp = input(PIN_B1);
}

The result is better than the first time.


Quote:
Cause you are actually using RB interrupt, do you intend to detect both edges? If not, the code has to be corrected to ignore the other edge for timing measurement.

Yes, I want to detect both edges, from tsop1740 ir sensor.

Now, I have some timing problems. irframes[2], irframes[3] are bigger than expected, and irframes[8], irframes[9], irframes[10] and irframes[11] are smaller. I don't know why this is happening, I will do some research.

pyu



Joined: 04 Feb 2009
Posts: 51

View user's profile Send private message Yahoo Messenger

PostPosted: Wed Feb 25, 2009 1:32 am     Reply with quote

Doesn't anybody know why I get this timers?



Because I use TSOP1740 and the source code was for 1738? My timer is not set correct?
pyu



Joined: 04 Feb 2009
Posts: 51

View user's profile Send private message Yahoo Messenger

PostPosted: Sun Mar 08, 2009 9:20 am     Reply with quote

Anyone? Sad
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