I made OLED timer/watch using Attiny85, but as internal clock isnt accurate i need external crystal. On Attiny85 im short on pins so i am switching to Attiny84 but i have problems to compile/upload same code to Attiny84. Even if i stay on Attiny84 8mhz internal clock as on Attiny85 i still cant compile. Im using Arduino UNO as ISP.
Error what i have:
WDT_Time.cpp: In function 'void setup_watchdog(uint8_t)':
WDT_Time.cpp:272: error: 'WDTCR' was not declared in this scope
WDTCR |= (1 << WDCE) | (1 << WDE);
^
In file included from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\io.h:99:0,
from c:\program files (x86)\arduino\hardware\tools\avr\avr\include\avr\pgmspace.h:88,
from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,
from WDT_Time.cpp:12:
WDT_Time.cpp:276: error: 'PCIE' was not declared in this scope
sbi(GIMSK, PCIE); // Turn on Pin Change interrupts (Tell Attiny85 we want to use pin change interrupts (can be any pin))
^
WDT_Time.cpp:276:3: note: in expansion of macro 'sbi'
sbi(GIMSK, PCIE); // Turn on Pin Change interrupts (Tell Attiny85 we want to use pin change interrupts (can be any pin))
^
WDT_Time.cpp:277: error: 'PCMSK' was not declared in this scope
sbi(PCMSK, PCINT3);
^
WDT_Time.cpp:277:3: note: in expansion of macro 'sbi'
sbi(PCMSK, PCINT3);
^
'WDTCR' was not declared in this scope
1 Answer 1
There are slight differences between registers, register names and registers bit names:
WDTCR
is namedWDTCSR
PCIE
doesn't exist inGIMSK
as there are two IO ports, so there are two pin change channels:PCIE0
andPCIE1
- and
PCMSK
is similar toPCIE
. There'll be two of them too.
Basically you have to look into both datasheets and compare what you are using and check if it's correct.
-
1In code i changed: WDTCR to WDTCSRMartins– Martins2016年10月14日 10:09:14 +00:00Commented Oct 14, 2016 at 10:09
-
1and other changes:
GIMSK = bit (PCIE0); sbi(GIMSK, PCIE0); // Turn on Pin Change interrupts (Tell Attiny85 we want to use pin change interrupts (can be any pin)) PCMSK0 = bit (PCINT1) | bit (PCINT2); sbi(PCMSK0, PCINT1);
Now its working. Thanks!Martins– Martins2016年10月14日 10:11:19 +00:00Commented Oct 14, 2016 at 10:11