'DDRB' was not declared in the scope
When I try to compile this example this is the first error I get. I believe there are others behind this one as well.
These are the errors I receive when I try to compile in the Arduino IDE:
Arduino: 1.8.8 (Mac OS X), Board: "M5Stack-Core-ESP32, QIO, 80MHz, Default, 921600, Verbose"
/Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino: In function 'void setup()': Calculator:25:11: error: 'DDRB' was not declared in this scope Set_Bit(DDRB, 0); ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:5:32: note: in definition of macro 'Set_Bit' #define Set_Bit(val, bitn) (val |=(1<<(bitn))) ^ Calculator:21:23: error: 'PORTB' was not declared in this scope #define IRQ_1 Set_Bit(PORTB,0) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:5:32: note: in definition of macro 'Set_Bit' #define Set_Bit(val, bitn) (val |=(1<<(bitn))) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:26:3: note: in expansion of macro 'IRQ_1' IRQ_1; ^ Calculator:27:3: error: 'DDRC' was not declared in this scope DDRC = 0x00; ^ Calculator:28:3: error: 'PORTC' was not declared in this scope PORTC = 0xff; ^ Calculator:29:3: error: 'DDRD' was not declared in this scope DDRD = 0xff; ^ Calculator:30:3: error: 'PORTD' was not declared in this scope PORTD = 0x00; ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino: In function 'void requestEvent()': Calculator:21:23: error: 'PORTB' was not declared in this scope #define IRQ_1 Set_Bit(PORTB,0) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:5:32: note: in definition of macro 'Set_Bit' #define Set_Bit(val, bitn) (val |=(1<<(bitn))) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:44:5: note: in expansion of macro 'IRQ_1' IRQ_1; ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino: In function 'void loop()': Calculator:53:11: error: 'PORTD' was not declared in this scope Clr_Bit(PORTD, 2); ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:6:33: note: in definition of macro 'Clr_Bit' #define Clr_Bit(val, bitn) (val&=~(1<<(bitn))) ^ Calculator:59:11: error: 'PINC' was not declared in this scope switch (PINC & 0x0f) ^ Calculator:22:23: error: 'PORTB' was not declared in this scope #define IRQ_0 Clr_Bit(PORTB,0) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:6:33: note: in definition of macro 'Clr_Bit' #define Clr_Bit(val, bitn) (val&=~(1<<(bitn))) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:68:27: note: in expansion of macro 'IRQ_0' hadPressed = 1; IRQ_0; ^ Calculator:22:23: error: 'PORTB' was not declared in this scope #define IRQ_0 Clr_Bit(PORTB,0) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:6:33: note: in definition of macro 'Clr_Bit' #define Clr_Bit(val, bitn) (val&=~(1<<(bitn))) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:74:35: note: in expansion of macro 'IRQ_0' temp = 'A'; hadPressed = 1; IRQ_0; return; break; ^ Calculator:85:11: error: 'PINC' was not declared in this scope switch (PINC & 0x0f) ^ Calculator:22:23: error: 'PORTB' was not declared in this scope #define IRQ_0 Clr_Bit(PORTB,0) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:6:33: note: in definition of macro 'Clr_Bit' #define Clr_Bit(val, bitn) (val&=~(1<<(bitn))) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:87:83: note: in expansion of macro 'IRQ_0' case 0x0e: temp = '7'; while ((PINC & 0x0f) != 0x0f)delay(1); hadPressed = 1; IRQ_0; return; break; ^ Calculator:98:11: error: 'PINC' was not declared in this scope switch (PINC & 0x0f) ^ Calculator:22:23: error: 'PORTB' was not declared in this scope #define IRQ_0 Clr_Bit(PORTB,0) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:6:33: note: in definition of macro 'Clr_Bit' #define Clr_Bit(val, bitn) (val&=~(1<<(bitn))) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:100:83: note: in expansion of macro 'IRQ_0' case 0x0e: temp = '4'; while ((PINC & 0x0f) != 0x0f)delay(1); hadPressed = 1; IRQ_0; return; break; ^ Calculator:112:11: error: 'PINC' was not declared in this scope switch (PINC & 0x0f) ^ Calculator:22:23: error: 'PORTB' was not declared in this scope #define IRQ_0 Clr_Bit(PORTB,0) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:6:33: note: in definition of macro 'Clr_Bit' #define Clr_Bit(val, bitn) (val&=~(1<<(bitn))) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:114:83: note: in expansion of macro 'IRQ_0' case 0x0e: temp = '1'; while ((PINC & 0x0f) != 0x0f)delay(1); hadPressed = 1; IRQ_0; return; break; ^ Calculator:125:11: error: 'PINC' was not declared in this scope switch (PINC & 0x0f) ^ Calculator:22:23: error: 'PORTB' was not declared in this scope #define IRQ_0 Clr_Bit(PORTB,0) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:6:33: note: in definition of macro 'Clr_Bit' #define Clr_Bit(val, bitn) (val&=~(1<<(bitn))) ^ /Users/rickkalman/Documents/Arduino/Calculator/Calculator.ino:127:83: note: in expansion of macro 'IRQ_0' case 0x0e: temp = '.'; while ((PINC & 0x0f) != 0x0f)delay(1); hadPressed = 1; IRQ_0; return; break; ^ exit status 1 'DDRB' was not declared in this scope
This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.
I don't know this for a fact, but I think the sketches "Calculator", "Gameboy" and "KeyBoard" are the code that are on the modules - the modules have an ATMEGA328 on them, and if you change the board over to the UNO in the IDE, they compile....That being said, I'm not sure how to reprogram the ATMEGA328 that is onboard.... maybe with the 6 pin connector that is on them, I'm not sure. Some examples that uses these modules would be good.
Any fix for this? I have the exact same issue
框架不同,UNO是AVR框架,DUE、ESP32是 ARM框架,程序不通用,在AVR中有portb 但是在ARM中就没有。