View previous topic :: View next topic |
Author |
Message |
damsel
Joined: 25 Jun 2004 Posts: 2
|
Help me about CCP interupt |
Posted: Fri Jun 25, 2004 6:29 am |
|
|
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
|
|
Posted: Fri Jun 25, 2004 6:45 am |
|
|
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: 1933 Location: Norman, OK
|
RS232 to HT |
Posted: Fri Jun 25, 2004 6:48 am |
|
|
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
|
|
Posted: Fri Jun 25, 2004 7:38 am |
|
|
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
|
|
Posted: Wed Jun 29, 2005 3:10 pm |
|
|
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
|
|
Posted: Wed Jun 29, 2005 3:11 pm |
|
|
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
|
|
|
Guest
|
Re: Help me about CCP interupt |
Posted: Thu Dec 22, 2005 2:51 am |
|
|
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? |
|
|
|
|