Sorry, my language maybe wrong becuase I'm Thai'student.
I use pic18f4620. I want to count pulse form input(motion sensor).I want count pulse by count pulse chang 1 to 0 becuase I use pull up at sensor.
Give me app note or example note for guild me please. I use mplab c18.
I begin practice use controller by mplab c18.
Thank you
Just read the input at regular intervals (let's say in the main loop of your program or during timed interrupt) and store the value in a variable.
When you re-read the value, if the new value is 0 and the old is 1, then increment counter.
Just read the input at regular intervals (let's say in the main loop of your program or during timed interrupt) and store the value in a variable.
When you re-read the value, if the new value is 0 and the old is 1, then increment counter.
Thank you for your answer.
Assume, I want use port RC0 connect to sensor for count pulse.
I want to read pulse for keep in new_value. What do I have to write the code or make any functions? I try to read MPLAB_C18_Users_Guide but my language have a problem,so show me the example code.
thank you
/*
* For PIC18xxxx devices, the low interrupt vector is found at 000000018h.
* Change the default code section to the absolute code section named
* low_vector located at address 0x18.
*/
#pragma code low_vector=0x18
void low_interrupt (void)
{
/*
* Inline assembly that will jump to the ISR.
*/
/*
* Returns the compiler to the default code section.
*/
#pragma code
/*
* Specifies the function timer_isr as a low-priority interrupt service
* routine. This is required in order for the compiler to generate a
* RETFIE instruction instead of a RETURN instruction for the timer_isr
* function.
*/
#pragma interruptlow int0_isr
/*
* Define the timer_isr function. Notice that it does not take any
* parameters, and does not return anything (as required by ISRs).
*/
void int0_isr (void)
{
INTCONbits.INT0IF = 0;
/*
* For PIC18xxxx devices, the low interrupt vector is found at 000000018h.
* Change the default code section to the absolute code section named
* low_vector located at address 0x18.
*/
#pragma code low_vector=0x18
void low_interrupt (void)
{
/*
* Inline assembly that will jump to the ISR.
*/
/*
* Returns the compiler to the default code section.
*/
#pragma code
/*
* Specifies the function timer_isr as a low-priority interrupt service
* routine. This is required in order for the compiler to generate a
* RETFIE instruction instead of a RETURN instruction for the timer_isr
* function.
*/
#pragma interruptlow int0_isr
/*
* Define the timer_isr function. Notice that it does not take any
* parameters, and does not return anything (as required by ISRs).
*/