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

Help me about CCP interupt

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



Joined: 25 Jun 2004
Posts: 2

View user's profile Send private message

Help me about CCP interupt
PostPosted: Fri Jun 25, 2004 6:29 am     Reply with quote

Hello everyone..
I can't run my code.
I used a ADXL202 to measure 2 pulse width with Capture modual.
And I want to view the output from Hyper Terminal.
But I can't see anything from my HT.
Please help me..
Thanks alot
Code:

#include <16f877.h>
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12

long rise,rise2;
float A1,A2;

#int_ccp1
void isr1()  {
      rise  = CCP_1;// CCP_1 is the time the pulse went high 
      A1 = ((CCP_1-7750)/7750)/0.125; //(Accleration=(T1-T2)/T2)/12.5%
}

#int_ccp2
void isr2()  {

      rise2 = CCP_2;// CCP_2 is the next time the pulse went high
      A2 = ((CCP_2-7750)/7750)/0.125; //(Accleration=(T1-T2)/T2)/12.5
}

main() {

   printf("\r\nHigh time (sampled every second):\r\n");
   setup_ccp1(CCP_CAPTURE_RE);
   setup_ccp2(CCP_CAPTURE_RE);
   setup_timer_1(T1_INTERNAL);    // Start timer 1 CCP Module time source;

   enable_interrupts(INT_CCP1);
   enable_interrupts(INT_CCP2);   // Setup interrupt on rising edge
   enable_interrupts(GLOBAL);

   while(TRUE) {

         delay_ms(100);
         disable_interrupts(INT_CCP1);
         disable_interrupts(INT_CCP2);

         //A1=((ccp_1-7750)/7750)/0.125; //(Accleration=(T1-T2)/T2)/12.5%
         //A2=((ccp_2-7750)/7750)/0.125; //(Accleration=(T1-T2)/T2)/12.5%

         printf("\r\n\%8.4f us ,%8.4f us \r\n", A1,A2 );

         delay_ms(100);
         enable_interrupts(INT_CCP1);
         enable_interrupts(INT_CCP2);
   }
}





Thanks you two guys help.
I think I didn't describe my question very well.
I mean the RS232 can't work.
The CCP_1 and CCP_2 is the value of capture.
But I didn't define CCP_1 and CCP_2, the code still be compiled by CCS Compiler.
I've checked the reference already. CCP_1 and CCP_2 is the value returned by CCP module. So I thought I need not to define CCP_1 and CCP_2.
I want to ask one more question. My question is,can I run two ISR at the same time?


Last edited by damsel on Fri Jun 25, 2004 8:51 am; edited 1 time in total
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Fri Jun 25, 2004 6:45 am     Reply with quote

1. Your program does not have #fuses. It is good practice to always set the fuses.

2. What are the definitions for CCP_1 and CCP_2?

3. What do you mean you can't see anything on HT? Do you mean you can't see anything at all? Or you just can't see the expected values? Can you see the "\r\nHigh time (sampled every second):\r\n" message?
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

RS232 to HT
PostPosted: Fri Jun 25, 2004 6:48 am     Reply with quote

When you say you cant see anything from HT do you mean that nothing appears or you are getting garbage or not getting the right numbers?

It sounds like you have hardware connection problems. How do you have things hooked up from the board to the PC? Have you ever gotten anything to display in HT before to prove your hardware connections?

If you are getting nothing at all you need to comment out comment out both interrupts and everything in your main routine except the single printf() and so the program will do nothing but print over and over and get the hardware checked out first. Then add sections back and test until you get everything back in.
damsel



Joined: 25 Jun 2004
Posts: 2

View user's profile Send private message

PostPosted: Fri Jun 25, 2004 7:38 am     Reply with quote

Thanks you two guys help.
I think I didn't describe my question very well.
I mean the RS232 can't work.
The CCP_1 and CCP_2 is the value of capture.
But I didn't define CCP_1 and CCP_2, the code still be compiled by CCS Compiler.
I've checked the reference already. CCP_1 and CCP_2 is the value returned by CCP module. So I thought I need not to define CCP_1 and CCP_2.
I want to ask one more question. My question is,can I run two ISR at the same time?
Guest








PostPosted: Wed Jun 29, 2005 3:10 pm     Reply with quote

Hi,

I think that only one ISR can be served at same time.
that's, when one ISR is being executed, NO other interrupt can be served until first of them is finished.
However, you can define two levels of prioriry interrupts depending your PIC.

I hope my poor English can help you.

Alda 705
Guest








PostPosted: Wed Jun 29, 2005 3:11 pm     Reply with quote

Anonymous wrote:
Hi,

I think that only one ISR can be served at same time.
that's, when one ISR is being executed, NO other interrupt can be served until first of them is finished.
However, you can define two levels of prioriry interrupts depending your PIC.

I hope my poor English can help you.

Alfa 705
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Wed Jun 29, 2005 4:30 pm     Reply with quote

Here's another recent accelerometer-related topic.

http://www.ccsinfo.com/forum/viewtopic.php?t=23377[/url]
Guest








Re: Help me about CCP interupt
PostPosted: Thu Dec 22, 2005 2:51 am     Reply with quote

damsel wrote:
Hello everyone..
I can't run my code.
I used a ADXL202 to measure 2 pulse width with Capture modual.
And I want to view the output from Hyper Terminal.
But I can't see anything from my HT.
Please help me..
Thanks alot
Code:

#include <16f877.h>
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12

long rise,rise2;
float A1,A2;

#int_ccp1
void isr1()  {
      rise  = CCP_1;// CCP_1 is the time the pulse went high 
      A1 = ((CCP_1-7750)/7750)/0.125; //(Accleration=(T1-T2)/T2)/12.5%
}

#int_ccp2
void isr2()  {

      rise2 = CCP_2;// CCP_2 is the next time the pulse went high
      A2 = ((CCP_2-7750)/7750)/0.125; //(Accleration=(T1-T2)/T2)/12.5
}

main() {

   printf("\r\nHigh time (sampled every second):\r\n");
   setup_ccp1(CCP_CAPTURE_RE);
   setup_ccp2(CCP_CAPTURE_RE);
   setup_timer_1(T1_INTERNAL);    // Start timer 1 CCP Module time source;

   enable_interrupts(INT_CCP1);
   enable_interrupts(INT_CCP2);   // Setup interrupt on rising edge
   enable_interrupts(GLOBAL);

   while(TRUE) {

         delay_ms(100);
         disable_interrupts(INT_CCP1);
         disable_interrupts(INT_CCP2);

         //A1=((ccp_1-7750)/7750)/0.125; //(Accleration=(T1-T2)/T2)/12.5%
         //A2=((ccp_2-7750)/7750)/0.125; //(Accleration=(T1-T2)/T2)/12.5%

         printf("\r\n\%8.4f us ,%8.4f us \r\n", A1,A2 );

         delay_ms(100);
         enable_interrupts(INT_CCP1);
         enable_interrupts(INT_CCP2);
   }
}





Thanks you two guys help.
I think I didn't describe my question very well.
I mean the RS232 can't work.
The CCP_1 and CCP_2 is the value of capture.
But I didn't define CCP_1 and CCP_2, the code still be compiled by CCS Compiler.
I've checked the reference already. CCP_1 and CCP_2 is the value returned by CCP module. So I thought I need not to define CCP_1 and CCP_2.
I want to ask one more question. My question is,can I run two ISR at the same time?
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