I was reading this thread:

Read RC receiver channels using Interrupt instead of PulseIn

and I have been trying to understand the code provided within.

While I was able to udnerstand most of it, I am still unable to find proper documentation on Arduino PCIFR and PINC?

Could someone please point me in the right direction?

Thanks in advance.


Welcome to Arduino.SE. The documentation that you seek on PCIFR and PINC would not be documented under Arduino, this is as these are directly related to the ATMega328 (AVR Atmel micrcontroller) which is on the Arduino, they are registers which are inside the microcontroller and PCIFR and PINC are mnemonics.

For the ATMega328 you will find the documentation to these registers in the datasheet (a good read with coffee), or in tutorials written by others explaining this information in an easy to grasp way.

The PCIFR register is the Pin Change interrupt flag register(description on pg 73 of linked datasheet), this holds the flag bit to tell the microcontroller that there was an interrupt and runs the ISR() routine that one has set out. Read this post by Nick Gammon on Pin Change Interrupts, and then read all of the post to get a better idea of interrupts in general.

The register PINC is for the inputs to the microcontroller, when one uses staus = digitalRead(A0); they are in effect using a wrapped up version of bitwise math and bit manipulation when simplified to status = PINC & (1 << PC0); thus PINx (x is for the register name ABCD) represents the state of the pin, either HIGH(1, 5V, true) or LOW(0, 0V, False). Borrowing from the below linked tutorial: maxembedded

Another nice description of the input ports in this tutorial.

From the image you see that moving a bit to a position and then bitwise & that with PINx you will have a value returned if there is a 1 in that position.

 PINC      0b00001001    
(1 << PC0) 0b00000001    
         & __________    
status  =  0b00000001

The above shows how you only get the state of the first input and how the 4th input is ignored as it was not needed. Also worth noting PIN is the register description and is not the same as a physical pin that sticks out the IC's body.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.