UNO R4 - PORTD was not declared

Hi everyone! I'm new to Arduino and this is my first time posting.

I tried to upload a sketch that used to work with unoR3 to the new R4 and got this error. I running IDE 1.8.19 on RasPi. Already select Board: UNO R4 MINIMA and PORT: ACM0 (UNO R4 MINIMA)

The error message is quite descriptive but I am confused about what I should exactly do. Any suggestion would be appreciated. Thank you in advance.

'PORTD', 'UCSR0A', 'TXEN0', 'DDRD', and '_BV' are not defined for your current board (Renesas UNO Minima).
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino: In function 'void sendBits(byte)':
sketch_aug04:843:21: error: 'PORTD' was not declared in this scope
 #define PIXEL_PORT  PORTD  // Data register of the pins the pixels are connected to
                     ^
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino:885:35: note: in expansion of macro 'PIXEL_PORT'
       [port]    "I" (_SFR_IO_ADDR(PIXEL_PORT)),
                                   ^~~~~~~~~~
sketch_aug04:885:22: error: '_SFR_IO_ADDR' was not declared in this scope
       [port]    "I" (_SFR_IO_ADDR(PIXEL_PORT)),
                      ^~~~~~~~~~~~
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino:885:22: note: suggested alternative: 'FSP_IP_ADC'
       [port]    "I" (_SFR_IO_ADDR(PIXEL_PORT)),
                      ^~~~~~~~~~~~
                      FSP_IP_ADC
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino: In function 'void show()':
sketch_aug04:902:3: error: '_delay_us' was not declared in this scope
   _delay_us( (RES_NS / 1000UL) + 1);       // Round up since the delay must be _at_least_ this long (too short might not work, too long not a problem)
   ^~~~~~~~~
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino:902:3: note: suggested alternative: 'delay'
   _delay_us( (RES_NS / 1000UL) + 1);       // Round up since the delay must be _at_least_ this long (too short might not work, too long not a problem)
   ^~~~~~~~~
   delay
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino: In function 'void serialPollRX()':
sketch_aug04:939:7: error: 'UCSR0A' was not declared in this scope
   if (UCSR0A & _BV(RXC0) ) {      // If there is a byte ready in the recieve buffer
       ^~~~~~
sketch_aug04:939:20: error: 'RXC0' was not declared in this scope
   if (UCSR0A & _BV(RXC0) ) {      // If there is a byte ready in the recieve buffer
                    ^~~~
sketch_aug04:939:16: error: '_BV' was not declared in this scope
   if (UCSR0A & _BV(RXC0) ) {      // If there is a byte ready in the recieve buffer
                ^~~
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino:939:16: note: suggested alternative: '_B'
   if (UCSR0A & _BV(RXC0) ) {      // If there is a byte ready in the recieve buffer
                ^~~
                _B
sketch_aug04:940:21: error: 'UDR0' was not declared in this scope
     appendToBuffer( UDR0 );       // Read it and add to our buffer. Note reading the byte clears the RXC0 flag
                     ^~~~
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino:940:21: note: suggested alternative: 'UART'
     appendToBuffer( UDR0 );       // Read it and add to our buffer. Note reading the byte clears the RXC0 flag
                     ^~~~
                     UART
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino: In function 'void setup()':
sketch_aug04:1055:3: error: 'UCSR0B' was not declared in this scope
   UCSR0B &= ~ _BV( TXEN0 );   // Disable the serial TX pin (digital pin 1) so we can use it as digital IO for an LED string
   ^~~~~~
sketch_aug04:1055:20: error: 'TXEN0' was not declared in this scope
   UCSR0B &= ~ _BV( TXEN0 );   // Disable the serial TX pin (digital pin 1) so we can use it as digital IO for an LED string
                    ^~~~~
sketch_aug04:1055:15: error: '_BV' was not declared in this scope
   UCSR0B &= ~ _BV( TXEN0 );   // Disable the serial TX pin (digital pin 1) so we can use it as digital IO for an LED string
               ^~~
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino:1055:15: note: suggested alternative: '_B'
   UCSR0B &= ~ _BV( TXEN0 );   // Disable the serial TX pin (digital pin 1) so we can use it as digital IO for an LED string
               ^~~
               _B
sketch_aug04:844:21: error: 'DDRD' was not declared in this scope
 #define PIXEL_DDR   DDRD   // Direction register of the pins the pixels are connected to
                     ^
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino:1061:3: note: in expansion of macro 'PIXEL_DDR'
   PIXEL_DDR |= 0xff;         // Set all 8 pins to output mode (note that digital pin 0 is controlled by the serial port so this has no effect on it)
   ^~~~~~~~~
sketch_aug04:843:21: error: 'PORTD' was not declared in this scope
 #define PIXEL_PORT  PORTD  // Data register of the pins the pixels are connected to
                     ^
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino:1064:3: note: in expansion of macro 'PIXEL_PORT'
   PIXEL_PORT |= 0xff;       // Set all outputs to 1
   ^~~~~~~~~~
sketch_aug04:1079:3: error: 'cli' was not declared in this scope
   cli();
   ^~~
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino:1079:3: note: suggested alternative: 'ceil'
   cli();
   ^~~
   ceil
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino: In function 'void loop()':
sketch_aug04:1099:5: error: '_delay_us' was not declared in this scope
     _delay_us(900);   // Pool just often enough that we do not miss any serial bytes at 9600bd (1 byte about 1ms)
     ^~~~~~~~~
/home/afc/Desktop/sketch_aug04/sketch_aug04.ino:1099:5: note: suggested alternative: 'delay'
     _delay_us(900);   // Pool just often enough that we do not miss any serial bytes at 9600bd (1 byte about 1ms)
     ^~~~~~~~~
     delay
exit status 1
'PORTD' was not declared in this scope

Because PORTD is CPU specific, the R4 doesn't use the same processor.

This is an example of code that was written with elements that are "outside" the Arduino API, which is mostly processor agnostic.

Thank you @anon57585045 . Is there a way to do little twist to the script or does it need to be newly written from the start?

You didn't post the code so nobody can say, with any certainty. Does it use any libraries?

You need to refer to the Renasas RA4M1 User Manual for information about the microcontroller used in the Uno R4.

Section 19.2.5 is useful.

There is more information in this topic. See susan-parker's posts in particular.

Thank you for all your suggestions! My code uses a library to run addressable LED strips. As for the time limitation of the project, I think I will use the R3 this time and will go through the resource for R4 soon!

Your topic has nothing to do with "Avrdude, stk500, Bootloader issues" and hence has been moved to a more suitable location on the forum.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.