I understand (please correct me if I am wrong) that:
i) PCICR and PCMSK0 are registers in Arduino UNO.
ii) That PCIE0 is a variable defined in the "Arduino.h" library which is the rank of bit 0 in the PCICR registry.
iii) That PCINT0 is bit 0 of register PCMSK0.
My questions are:
Could somebody explain the following lines of code?? PCICR |= (1 << PCIE0); PCMSK0 |= (1 << PCINT0);
Are these registers 8-bit or 16-bit wide??
I understand that rank of a bit is the number of "1" bits that appear before its position in the sequence. So, if PCIE0 is a variable defined in the "Arduino.h" library which is the rank of bit 0 (ordinal) in the PCICR registry, (sorry, I am not an EE or CS), what is the importance/relevance of knowing the rank of a bit??
Thank you. AA
Those two lines of code set the PCIE0 and PCINT0 bits in the respective registers, and enable certain pin change interrupts.
The sizes and functions of those registers and the bits in them are very completely described in Section 12 of the ATmega328 data sheet, which is the processor used in the Arduino Uno.
Those are registers common to the ATmega48/88/168/328 MCU family which are all pin compatible and can fit in the socket and after "bootloading" run on an Arduino Uno. The official Uno R3 comes with an ATmega328 installed, some knockoffs have an ATmega168. The 328 has 32K flash, 2K SRAM and 1K EEPROM while the 168 has half as much each, the 88 has half that and the 48 has 4K flash, 256 bytes SRAM and 128 bytes of EEPROM but other than that they all have the same features. The prices are not that far apart but if you made large numbers of an end product the savings would add up.
The full datasheet runs over 300 pages and is the last word about the chips.