Port Code From Arduino Duemilanove to UNO R4 WIFI

I’m attempting to use an UNO R4 WIFI to drive a circuit that was originally designed for the Duemilanove. It uses direct port access that has changed over the years.

Would someone be able to help me port it over, please?

The code is below:

// Rough-and-ready Arduino code for testing, calibrating and using core memory shield.
//
// Copyright 2011 Ben North and Oliver Nash.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.


#define ADDRSIZE      5
#define WORDSIZE      (1 << ADDRSIZE)
#define ENABLE        B00000100 // PORTD
#define DRD           B00000010 // PORTB
#define DWR           B00000001 // PORTB

static unsigned int WRITE_ON_US  = 2;
static unsigned int WRITE_OFF_US = 2; // May not be necessary.

static unsigned long errs = 0;
static unsigned int sense_test_addr = 0;
static int n_test_iters = 1000;
static char report_errors_p = 0;
static char trace_core_calls_p = 0;

void write_bit(byte n, const int v)
{
  if (trace_core_calls_p)
  {
    char buf[64];
    sprintf(buf, "x[0%02o] <- %d", n, v);
    Serial.println(buf);
  }

  // Assert 0 <= n <= 31, v == 0 or 1.
  noInterrupts();
  if(v == 0)
  {
    PORTB &= (~DWR);
  }
  else
  {
    PORTB |= DWR;
  }
  PORTD = ((n << 3) & (~ENABLE));
  PORTD |= ENABLE; // Enable separately to be safe.
  delayMicroseconds(WRITE_ON_US);
  PORTD &= (~ENABLE);
  delayMicroseconds(WRITE_OFF_US);
  interrupts();
}

int exchg_bit(byte n, const int v)
{
  write_bit(n, v);

  if(PINB & DRD)
  {
    // Switching occurred so core held opposite of
    // what we just set it to.

    if (trace_core_calls_p)
      Serial.println("___ -> CHANGE");

    return !v;
  }
  else
  {
    // No switching occurred so core held whatever
    // we just wrote to it.

    if (trace_core_calls_p)
      Serial.println("___ -> NO-CHANGE");

    return v;
  }
}

int read_bit(const int n)
{
  char buf[64];
  if (trace_core_calls_p)
  {
    sprintf(buf, "x[0%02o] -> ___", n);
    Serial.println(buf);
  }

  write_bit(n, 0);
  if(PINB & DRD)
  {
    // Switching occurred so core held 1.

    if (trace_core_calls_p)
      Serial.println("___ -> 1");

    write_bit(n, 1); // Put it back!
    return 1;
  }
  else
  {
    // No switching occurred so core held 0 (and still holds it).

    if (trace_core_calls_p)
      Serial.println("___ -> 0");

    return 0;
  }
}

void write_word(unsigned long v)
{
  int n;
  for(n = 0; n < WORDSIZE; n++)
  {
    write_bit(n, v & 1);
    v >>= 1;
  }
}

unsigned long read_word(void)
{
  unsigned long v = 0;
  int n;
  for(n = WORDSIZE-1; n >= 0; n--)
  {
    v <<= 1;
    v |= read_bit(n);
  }
  return v;
}

unsigned long exchg_word(unsigned long v)
{
  unsigned long v_prev;
  int n;
  for (n = 0; n < WORDSIZE; ++n)
  {
    unsigned long b = exchg_bit(n, v & 1);
    v >>= 1;
    v_prev >>= 1;
    v_prev |= (b << 31);
  }
  return v_prev;
}

static void maybe_report_error(int i, int j, const char * lbl)
{
  char buf[64];

  if (!report_errors_p)
    return;

  sprintf(buf, "(%o, %o): %s", i, j, lbl);
  Serial.println(buf);
}

static void toggle_error_reporting()
{
  char buf[64];
  report_errors_p = !report_errors_p;
  sprintf(buf, "report-errors-p now %d", report_errors_p);
  Serial.println(buf);
}

static void toggle_tracing()
{
  char buf[64];
  trace_core_calls_p = !trace_core_calls_p;
  sprintf(buf, "trace-core-calls-p now %d", trace_core_calls_p);
  Serial.println(buf);
}

static void current_calibration()
{
  Serial.print("pulsing for current calibration...");
  while (Serial.available() == 0)
  {
    int i;
    for (i = 0; i < WORDSIZE; ++i)
    {
      write_bit(i, 0);
      write_bit(i, 1);
    }
    delayMicroseconds(100);
  }
  Serial.println(" stopped");
  Serial.read(); /* discard typed character */
}

static void timing_exchange_word()
{
  unsigned long val_0 = read_word();
  unsigned long i;
  
  Serial.print("start...");
  for (i = 0; i < 12000; ++i)
  {
    exchg_word(val_0);
    exchg_word(val_0);
    exchg_word(val_0);
    exchg_word(val_0);
    exchg_word(val_0);
    exchg_word(val_0);
    exchg_word(val_0);
    exchg_word(val_0);
    exchg_word(val_0);
    exchg_word(val_0);
  }
  Serial.println("stop");
}

static void echo_comment()
{
  Serial.print("# ");
  char c;
  do {
    while (Serial.available() == 0);
    c = Serial.read();
    Serial.print(c, BYTE);
  } while (c != '\r');
  Serial.println("");
}

static void corewise_set_test()
{
  char buf[64];
  for (int b = 0; b < 2; ++b)
  {
    errs = 0;
    for (int n = 0; n < n_test_iters; ++n)
      for (int i = 0; i < WORDSIZE; ++i)
      {
        write_bit(i, b);
        if (read_bit(i) != b) ++errs;
      }
    sprintf(buf, "set %d %lu %d", b, errs, n_test_iters);
    Serial.println(buf);
  }
}

static void corewise_interfere_test()
{
  char buf[64];
  for (int b0 = 0; b0 < 2; ++b0)
  {
    for (int b1 = 0; b1 < 2; ++b1)
    {
      errs = 0;
      for (int n = 0; n < n_test_iters; ++n)
      {
        for (int i = 0; i < WORDSIZE; ++i)
        {
          for (int j = 0; j < WORDSIZE; ++j)
          {
            if (j == i) continue;
            
            write_bit(i, b0);
            write_bit(j, b1);
            if (read_bit(i) != b0) {
              if (report_errors_p)
              {
                // Redundant test but sprintf() takes time.
                sprintf(buf, "%d %d", b0, b1);
                maybe_report_error(i, j, buf);
              }
              ++errs;
            }
          }
        }
      }
      sprintf(buf, "interfere %d %d %lu %d", b0, b1, errs, n_test_iters);
      Serial.println(buf);
    }
  }
}

static void corewise_tests()
{
  corewise_set_test();
  corewise_interfere_test();
}

static void R_test()
{
  unsigned long d = read_word();
  Serial.print("Core data read: 0x");
  Serial.print(d, HEX);
  Serial.print(" = B");
  Serial.println(d, BIN);
}

static void s_test()
{
  char buf[64];
  write_bit(sense_test_addr, 0);
  write_bit(sense_test_addr, 0);
  write_bit(sense_test_addr, 1);
  write_bit(sense_test_addr, 1);
  sprintf(buf, "Pulsed core 0%02o", sense_test_addr);
  Serial.println(buf);
}

static void report_sense_addr()
{
  char buf[64];
  sprintf(buf, "Ready to pulse core 0%02o", sense_test_addr);
  Serial.println(buf);
}

static void a_test()
{
  sense_test_addr += 1;
  sense_test_addr %= 32;
  report_sense_addr();
}

static void A_test()
{
  sense_test_addr -= 1;
  sense_test_addr %= 32;
  report_sense_addr();
}

static void W_test()
{
  int i, x;
  unsigned long d = 0;
  Serial.print("Please enter 8 hexadecimal digits: ");
  for(i = 0; i < 8; i++)
  {
    d <<= 4;
    while(Serial.available() == 0) ;
    x = Serial.read();
    if('0' <= x && x <= '9')
    {
      d += x - '0'; 
    }
    else if('A' <= x && x <= 'F')
    {
      d += x - 'A' + 10;
    }
    else if('a' <= x && x <= 'f')
    {
      d += x - 'a' + 10;
    }
    else
    {
      Serial.print("Assuming 0 for non-hexadecimal digit: ");
      Serial.println(x, BYTE);
    }
  }
  write_word(d);
  Serial.print("\r\nCore data write: 0x");
  Serial.print(d, HEX);
  Serial.print(" = B");
  Serial.println(d, BIN);
}

static void X_test()
{
  char buf[64];
  int i, x;
  unsigned long d1, d = 0;
  Serial.print("Please enter 8 hexadecimal digits: ");
  for(i = 0; i < 8; i++)
  {
    d <<= 4;
    while(Serial.available() == 0) ;
    x = Serial.read();
    if('0' <= x && x <= '9')
    {
      d += x - '0'; 
    }
    else if('A' <= x && x <= 'F')
    {
      d += x - 'A' + 10;
    }
    else if ('a' <= x && x <= 'f')
    {
      d += x - 'a' + 10;
    }
    else
    {
      Serial.print("Assuming 0 for non-hexadecimal digit: ");
      Serial.println(x, BYTE);
    }
  }
  d1 = exchg_word(d);
  Serial.print("\r\nCore data write: 0x");
  sprintf(buf, "%08lx; read 0x%08lx", d, d1);
  Serial.println(buf);
}

static void r_test()
{
  int i, x, a = 0;
  Serial.print("Please enter address of bit to read: ");
  for(i = 0; i < ADDRSIZE; i++)
  {
    a <<= 1;
    while(Serial.available() == 0) ;
    x = Serial.read();
    if(x != '0') // Assert x == '1'
    {
      a += 1;
    }
  }
  Serial.print("\r\nCore data read from address: ");
  Serial.print(a, BIN);
  Serial.print(" found: ");
  Serial.println(read_bit(a));
}

static void w_test()
{
  int i, x, a = 0;
  Serial.print("Please enter address of bit to write: ");
  for(i = 0; i < ADDRSIZE; i++)
  {
    a <<= 1;
    while(Serial.available() == 0) ;
    x = Serial.read();
    if(x != '0') // Assert x == '1'
    {
      a += 1;
    }
  }
  Serial.print("\r\nPlease enter bit to write: ");
  while(Serial.available() == 0) ;
  x = Serial.read();
  Serial.print("\r\nCore data write to address: ");
  Serial.print(a, BIN);
  Serial.print(" value: ");
  if(x == '0')
  {
    write_bit(a, 0);
    Serial.println("0");
  }
  else // Assert x == '1'
  {
    write_bit(a, 1);
    Serial.println("1");
  }
}

static void t_test()
{
  int i;
  unsigned long d;
  for(i = 0; i < WORDSIZE; i++)
  {
    write_bit(i, 0);
    d = read_bit(i);
    Serial.print("Address (");
    Serial.print(i >> 3);
    Serial.print(i & 7);
    Serial.print(") ");
    Serial.print(i, BIN);
    Serial.print("   wrote 0 read ");
    Serial.print(d);
    write_bit(i, 1);
    d = read_bit(i);
    Serial.print("   wrote 1 read ");
    Serial.println(d);
  }
}

static void T_test()
{
  unsigned long d;
  int i, j;
  Serial.print("log10(iters)? ");
  while(Serial.available() == 0) ;
  int n = Serial.read() - '0';
  if (n < 0 || n > 9)
      Serial.println("bad power-of-10 arg to T");
  else
  {
    unsigned long n_iters = 1, n_iters_done = 0;
    while (n--) n_iters *= 10;
    errs = 0;
    for (n_iters_done = 0; n_iters_done < n_iters; ++n_iters_done)
    {
      for(i = 0; i < WORDSIZE; i++)
      {
        for(j = 0; j < WORDSIZE; j++)
        {
          if(j == i) { continue; }

          write_bit(i, 0);
          d = read_bit(i);
          if(d != 0) { errs++; maybe_report_error(i, j, "0-0"); }
          d = read_bit(i);
          if(d != 0) { errs++; maybe_report_error(i, j, "0-1"); }

          write_bit(i, 0);
          write_bit(j, 0);
          d = read_bit(i);
          if(d != 0) { errs++; maybe_report_error(i, j, "000"); }
          d = read_bit(i);
          if(d != 0) { errs++; maybe_report_error(i, j, "001"); }

          write_bit(i, 0);
          write_bit(j, 1);
          d = read_bit(i);
          if(d != 0) { errs++; maybe_report_error(i, j, "010"); }
          d = read_bit(i);
          if(d != 0) { errs++; maybe_report_error(i, j, "011"); }

          write_bit(i, 1);
          d = read_bit(i);
          if(d != 1) { errs++; maybe_report_error(i, j, "1-0"); }
          d = read_bit(i);
          if(d != 1) { errs++; maybe_report_error(i, j, "1-1"); }

          write_bit(i, 1);
          write_bit(j, 0);
          d = read_bit(i);
          if(d != 1) { errs++; maybe_report_error(i, j, "100"); }
          d = read_bit(i);
          if(d != 1) { errs++; maybe_report_error(i, j, "101"); }

          write_bit(i, 1);
          write_bit(j, 1);
          d = read_bit(i);
          if(d != 1) { errs++; maybe_report_error(i, j, "110"); }
          d = read_bit(i);
          if(d != 1) { errs++; maybe_report_error(i, j, "111"); }
        }
      }
      if (n_iters_done % 100 == 0)
      {
        Serial.print(n_iters_done, DEC);
        Serial.print(" iters; ");
        Serial.print(errs, DEC);
        Serial.println(" errors");
      }
    }
    Serial.print(n_iters_done, DEC);
    Serial.print(" iters; ");
    Serial.print(errs, DEC);
    Serial.println(" errors");
  }
}

static void U_test()
{  
  unsigned long n_iters_done = 0;
  unsigned long prev_datum = 0UL;
  errs = 0;
  write_word(prev_datum);
  while (1)
  {
    if (Serial.available() > 0)
    {
      (void)Serial.read();
      Serial.println("stopping");
      break;
    }
    unsigned rnd_0 = random(0x10000);
    unsigned rnd_1 = random(0x10000);
    unsigned long rnd = (unsigned long)(rnd_1) << 16 | rnd_0;
    unsigned long read_datum = exchg_word(rnd);
//          sprintf(buf, "rnd %08lx; read %08lx", rnd, read_datum);
//          Serial.println(buf);
    if (read_datum != prev_datum)
      ++errs;
    prev_datum = rnd;
    if (n_iters_done % 20000 == 0)
    {
      char buf[64];
      sprintf(buf, "%lu iters-done; %lu errors", n_iters_done, errs);
      Serial.println(buf);
    }
    ++n_iters_done;
  }
}

void setup(void) 
{
  DDRD |= B11111100;
  PORTD = (~ENABLE);
  DDRB |= DWR;
  DDRB &= (~DRD);
  Serial.begin(115200);
  randomSeed(0xdeadbeef);
  Serial.println("Welcome! If you're new, try using the commands 'r', 'w', 't' and 'R', 'W', 'T' to get started.");
}

void loop(void)
{
  byte c;
  if(Serial.available() > 0)
  {
    c = Serial.read();
    switch(c)
    {
    case 'c':
      current_calibration();
      break;
    case '#':
      echo_comment();
      break;
    case 'e':
      corewise_tests();
      break;
    case 'v':
      toggle_tracing();
      break;
    case 'f':
      toggle_error_reporting();
      break;
    case 'm':
      timing_exchange_word();
      break;
    case 'R':
      R_test();
      break;
    case 's':
      s_test();
      break;
    case 'a':
      a_test();
      break;  
    case 'A':
      A_test();
      break;
    case 'W':
      W_test();
      break;
    case 'X':
      X_test();
      break;
    case 'r':
      r_test();
      break;
    case 'w':
      w_test();
      break;
    case 't':
      t_test();
      break;
    case 'T':
      T_test();
      break;
    case 'U':
      U_test();
      break;
    case 'z':
      errs = 0;
      Serial.println("error-count = 0");
      break;
    default:
      Serial.print("Ignoring unknown command: ");
      Serial.print(c, HEX);
      Serial.print(" ");
      Serial.println(c, BYTE);
    }
  }
}

Does it compile ok? If not, post the verbose error log in code tags.

Thanks for the response. Please see below.

Thanks!

/run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino: In function 'void write_bit(byte, int)':
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:47:5: error: 'PORTB' was not declared in this scope      PORTB &= (~DWR);      ^~~~~ 

/run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:51:5: error: 'PORTB' was not declared in this scope      PORTB |= DWR;      ^~~~~ 

/run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:53:3: error: 'PORTD' was not declared in this scope    PORTD = ((n << 3) & (~ENABLE));    ^~~~~
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino: In function 'int exchg_bit(byte, int)':
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:65:6: error: 'PINB' was not declared in this scope    if(PINB & DRD)       ^~~~
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:65:6: note: suggested alternative: 'PIN'    if(PINB & DRD)       ^~~~       PIN
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino: In function 'int read_bit(int)':
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:97:6: error: 'PINB' was not declared in this scope    if(PINB & DRD)       ^~~~
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:97:6: note: suggested alternative: 'PIN'    if(PINB & DRD)       ^~~~       PIN
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino: In function 'void echo_comment()':
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:227:21: error: 'BYTE' was not declared in this scope      Serial.print(c, BYTE);                      ^~~~
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino: In function 'void W_test()':
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:357:25: error: 'BYTE' was not declared in this scope        Serial.println(x, BYTE);                          ^~~~
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino: In function 'void X_test()':
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:393:25: error: 'BYTE' was not declared in this scope        Serial.println(x, BYTE);                          ^~~~
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino: In function 'void setup()':
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:589:3: error: 'DDRD' was not declared in this scope    DDRD |= B11111100;    ^~~~
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:589:3: note: suggested alternative: 'DRD'    DDRD |= B11111100;    ^~~~    DRD
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:590:3: error: 'PORTD' was not declared in this scope    PORTD = (~ENABLE);    ^~~~~
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:591:3: error: 'DDRB' was not declared in this scope    DDRB |= DWR;    ^~~~
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:591:3: note: suggested alternative: 'DRD'    DDRB |= DWR;    ^~~~    DRD
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino: In function 'void loop()':
 /run/arduino/sketches/Arduino_shield_magnetic_core_memory/Arduino_shield_magnetic_core_memory.ino:665:25: error: 'BYTE' was not declared in this scope        Serial.println(c, BYTE);                          ^~~~

Sorry, what are you using to do the compile, IDE1 or IDE2?

Ok, but your log output isn't anything I evert saw. Here is what I get. It still fails but differently.

FQBN: arduino:renesas_uno:unor4wifi
Using board 'unor4wifi' from platform in folder: /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0
Using core 'arduino' from platform in folder: /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0

Detecting libraries used...
/Users/ronalexander/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -w -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -nostdlib -DF_CPU=48000000 -DNO_USB -DBACKTRACE_SUPPORT -DARDUINO_UNOR4_WIFI -std=gnu++17 -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -w -x c++ -E -CC -DARDUINO=10607 -DPROJECT_NAME="/Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch_aug25a.ino" -DARDUINO_UNOWIFIR4 -DARDUINO_ARCH_RENESAS_UNO -DARDUINO_ARCH_RENESAS -DARDUINO_FSP -D_XOPEN_SOURCE=700 -mthumb @/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/variants/UNOWIFIR4/defines.txt -DCFG_TUSB_MCU=OPT_MCU_RAXXX -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/tinyusb -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/deprecated -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/deprecated-avr-comp -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/variants/UNOWIFIR4 -iprefix/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0 @/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/variants/UNOWIFIR4/includes.txt /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp -o /dev/null
Generating function prototypes...
/Users/ronalexander/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -w -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -nostdlib -DF_CPU=48000000 -DNO_USB -DBACKTRACE_SUPPORT -DARDUINO_UNOR4_WIFI -std=gnu++17 -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -w -x c++ -E -CC -DARDUINO=10607 -DPROJECT_NAME="/Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch_aug25a.ino" -DARDUINO_UNOWIFIR4 -DARDUINO_ARCH_RENESAS_UNO -DARDUINO_ARCH_RENESAS -DARDUINO_FSP -D_XOPEN_SOURCE=700 -mthumb @/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/variants/UNOWIFIR4/defines.txt -DCFG_TUSB_MCU=OPT_MCU_RAXXX -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/tinyusb -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/deprecated -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/deprecated-avr-comp -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/variants/UNOWIFIR4 -iprefix/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0 @/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/variants/UNOWIFIR4/includes.txt /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp -o /private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/556933416/sketch_merged.cpp
/Users/ronalexander/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/556933416/sketch_merged.cpp

Compiling sketch...
/Users/ronalexander/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -MMD -nostdlib -DF_CPU=48000000 -DNO_USB -DBACKTRACE_SUPPORT -DARDUINO_UNOR4_WIFI -MMD -std=gnu++17 -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin -DARDUINO=10607 "-DPROJECT_NAME=\"/Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch_aug25a.ino\"" -DARDUINO_UNOWIFIR4 -DARDUINO_ARCH_RENESAS_UNO -DARDUINO_ARCH_RENESAS -DARDUINO_FSP -D_XOPEN_SOURCE=700 -mthumb @/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/variants/UNOWIFIR4/defines.txt -DCFG_TUSB_MCU=OPT_MCU_RAXXX -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/tinyusb -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/deprecated -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/deprecated-avr-comp -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino -I/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/variants/UNOWIFIR4 -iprefix/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0 @/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/variants/UNOWIFIR4/includes.txt /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp -o /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp.o
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino: In function 'void write_bit(byte, int)':
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:49:5: error: 'PORTB' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:25:23: warning: 'B00000001' is deprecated: use 0b00000001 instead [-Wdeprecated-declarations]
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:49:16: note: in expansion of macro 'DWR'
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:53:3: note: declared here
   B00000001 DEPRECATED(0b00000001) = 1,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:53:5: error: 'PORTB' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:25:23: warning: 'B00000001' is deprecated: use 0b00000001 instead [-Wdeprecated-declarations]
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:53:14: note: in expansion of macro 'DWR'
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:53:3: note: declared here
   B00000001 DEPRECATED(0b00000001) = 1,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:55:3: error: 'PORTD' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:23:23: warning: 'B00000100' is deprecated: use 0b00000100 instead [-Wdeprecated-declarations]
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:55:25: note: in expansion of macro 'ENABLE'
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:73:3: note: declared here
   B00000100 DEPRECATED(0b00000100) = 4,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:23:23: warning: 'B00000100' is deprecated: use 0b00000100 instead [-Wdeprecated-declarations]
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:56:12: note: in expansion of macro 'ENABLE'
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:73:3: note: declared here
   B00000100 DEPRECATED(0b00000100) = 4,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:23:23: warning: 'B00000100' is deprecated: use 0b00000100 instead [-Wdeprecated-declarations]
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:58:14: note: in expansion of macro 'ENABLE'
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:73:3: note: declared here
   B00000100 DEPRECATED(0b00000100) = 4,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino: In function 'int exchg_bit(byte, int)':
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:67:6: error: 'PINB' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:67:6: note: suggested alternative: 'PIN'
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:24:23: warning: 'B00000010' is deprecated: use 0b00000010 instead [-Wdeprecated-declarations]
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:67:13: note: in expansion of macro 'DRD'
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:60:3: note: declared here
   B00000010 DEPRECATED(0b00000010) = 2,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino: In function 'int read_bit(int)':
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:99:6: error: 'PINB' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:99:6: note: suggested alternative: 'PIN'
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:24:23: warning: 'B00000010' is deprecated: use 0b00000010 instead [-Wdeprecated-declarations]
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:99:13: note: in expansion of macro 'DRD'
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:60:3: note: declared here
   B00000010 DEPRECATED(0b00000010) = 2,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino: In function 'void echo_comment()':
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:229:21: error: 'BYTE' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino: In function 'void W_test()':
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:359:25: error: 'BYTE' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino: In function 'void X_test()':
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:395:25: error: 'BYTE' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino: In function 'void setup()':
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:591:3: error: 'DDRD' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:591:3: note: suggested alternative: 'DRD'
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:591:11: warning: 'B11111100' is deprecated: use 0b11111100 instead [-Wdeprecated-declarations]
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:544:3: note: declared here
   B11111100 DEPRECATED(0b11111100) = 252,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:592:3: error: 'PORTD' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:23:23: warning: 'B00000100' is deprecated: use 0b00000100 instead [-Wdeprecated-declarations]
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:592:13: note: in expansion of macro 'ENABLE'
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:73:3: note: declared here
   B00000100 DEPRECATED(0b00000100) = 4,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:593:3: error: 'DDRB' was not declared in this scope
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:593:3: note: suggested alternative: 'DRD'
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:25:23: warning: 'B00000001' is deprecated: use 0b00000001 instead [-Wdeprecated-declarations]
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:593:11: note: in expansion of macro 'DWR'
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:53:3: note: declared here
   B00000001 DEPRECATED(0b00000001) = 1,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:24:23: warning: 'B00000010' is deprecated: use 0b00000010 instead [-Wdeprecated-declarations]
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:594:13: note: in expansion of macro 'DRD'
In file included from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/ArduinoAPI.h:26:0,
                 from /Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/Arduino.h:4,
                 from /Users/ronalexander/Library/Caches/arduino/sketches/2D87F202D1B4FE6D16EC87C759FE8643/sketch/sketch_aug25a.ino.cpp:1:
/Users/ronalexander/Library/Arduino15/packages/arduino/hardware/renesas_uno/1.5.0/cores/arduino/api/Binary.h:60:3: note: declared here
   B00000010 DEPRECATED(0b00000010) = 2,
   ^~~~~~~~~
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino: In function 'void loop()':
/private/var/folders/r5/fjhtttf952x9mvr0j_pdkt9h0000gn/T/.arduinoIDE-unsaved2025725-61646-syk1xr.bsfrm/sketch_aug25a/sketch_aug25a.ino:667:25: error: 'BYTE' was not declared in this scope
exit status 1

Compilation error: 'PORTB' was not declared in this scope

I ran it again…still looks similar to the first time and nothing like yours…

C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino: In function 'void write_bit(byte, int)':
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:47:5: error: 'PORTB' was not declared in this scope
     PORTB &= (~DWR);
     ^~~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:51:5: error: 'PORTB' was not declared in this scope
     PORTB |= DWR;
     ^~~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:53:3: error: 'PORTD' was not declared in this scope
   PORTD = ((n << 3) & (~ENABLE));
   ^~~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino: In function 'int exchg_bit(byte, int)':
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:65:6: error: 'PINB' was not declared in this scope
   if(PINB & DRD)
      ^~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:65:6: note: suggested alternative: 'PIN'
   if(PINB & DRD)
      ^~~~
      PIN
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino: In function 'int read_bit(int)':
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:97:6: error: 'PINB' was not declared in this scope
   if(PINB & DRD)
      ^~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:97:6: note: suggested alternative: 'PIN'
   if(PINB & DRD)
      ^~~~
      PIN
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino: In function 'void echo_comment()':
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:227:21: error: 'BYTE' was not declared in this scope
     Serial.print(c, BYTE);
                     ^~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino: In function 'void W_test()':
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:357:25: error: 'BYTE' was not declared in this scope
       Serial.println(x, BYTE);
                         ^~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino: In function 'void X_test()':
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:393:25: error: 'BYTE' was not declared in this scope
       Serial.println(x, BYTE);
                         ^~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino: In function 'void setup()':
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:589:3: error: 'DDRD' was not declared in this scope
   DDRD |= B11111100;
   ^~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:589:3: note: suggested alternative: 'DRD'
   DDRD |= B11111100;
   ^~~~
   DRD
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:590:3: error: 'PORTD' was not declared in this scope
   PORTD = (~ENABLE);
   ^~~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:591:3: error: 'DDRB' was not declared in this scope
   DDRB |= DWR;
   ^~~~
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:591:3: note: suggested alternative: 'DRD'
   DDRB |= DWR;
   ^~~~
   DRD
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino: In function 'void loop()':
C:\Users\12813\Documents\Arduino\UNO\Magnetic core memory reborn\Magnetic_Core_Memory\Magnetic_Core_Memory.ino:665:25: error: 'BYTE' was not declared in this scope
       Serial.println(c, BYTE);
                         ^~~~
exit status 1

Compilation error: 'PORTB' was not declared in this scope

You don't have verbose turned on in the prefs. That error is just saying those variables ONLY apply to AVR based boards.
This is beyond my paygrade but hopefully someone else can help.

Thank you for looking at it. I appreciate your time.

Rather than trying to use an Arduino Uno R4 WiFi, have you considered using an Arduino Uno R3, which is closer to a Duemilanove?

If you do, you only get 4 errors.

Using IDE version 2.3.6:

FQBN: arduino:avr:uno
Using board 'uno' from platform in folder: C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\johnr\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\johnr\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\johnr\AppData\Local\arduino\sketches\45CFC6BE1F17CAABD35944C250FB047E\sketch\Arduino_Forum_2.ino.cpp -o nul
Generating function prototypes...
C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\johnr\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\johnr\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\johnr\AppData\Local\arduino\sketches\45CFC6BE1F17CAABD35944C250FB047E\sketch\Arduino_Forum_2.ino.cpp -o C:\Users\johnr\AppData\Local\Temp\3497498012\sketch_merged.cpp
C:\Users\johnr\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\johnr\AppData\Local\Temp\3497498012\sketch_merged.cpp

Compiling sketch...
"C:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\johnr\\AppData\\Local\\arduino\\sketches\\45CFC6BE1F17CAABD35944C250FB047E\\sketch\\Arduino_Forum_2.ino.cpp" -o "C:\\Users\\johnr\\AppData\\Local\\arduino\\sketches\\45CFC6BE1F17CAABD35944C250FB047E\\sketch\\Arduino_Forum_2.ino.cpp.o"
C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino: In function 'void echo_comment()':
C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino:227:21: error: 'BYTE' was not declared in this scope
     Serial.print(c, BYTE);
                     ^~~~
C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino: In function 'void W_test()':
C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino:357:25: error: 'BYTE' was not declared in this scope
       Serial.println(x, BYTE);
                         ^~~~
C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino: In function 'void X_test()':
C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino:393:25: error: 'BYTE' was not declared in this scope
       Serial.println(x, BYTE);
                         ^~~~
C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino: In function 'void loop()':
C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino:665:25: error: 'BYTE' was not declared in this scope
       Serial.println(c, BYTE);
                         ^~~~
exit status 1

Compilation error: 'BYTE' was not declared in this scope

However if you use IDE version 1.8.19, then you get a different error message, which suggests a solution:

Arduino: 1.8.19 (Windows 10), TD: 1.59, Board: "Arduino Uno"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\johnr\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\johnr\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\johnr\OneDrive\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10819 -build-path C:\Users\johnr\AppData\Local\Temp\arduino_build_431498 -warnings=default -build-cache C:\Users\johnr\AppData\Local\Temp\arduino_cache_731088 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -verbose C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\johnr\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\johnr\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\johnr\OneDrive\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10819 -build-path C:\Users\johnr\AppData\Local\Temp\arduino_build_431498 -warnings=default -build-cache C:\Users\johnr\AppData\Local\Temp\arduino_cache_731088 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -verbose C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino

Using board 'uno' from platform in folder: C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Using core 'arduino' from platform in folder: C:\Users\johnr\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...

"C:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\johnr\\AppData\\Local\\Temp\\arduino_build_431498\\sketch\\Arduino_Forum_2.ino.cpp" -o nul

Generating function prototypes...

"C:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\johnr\\AppData\\Local\\Temp\\arduino_build_431498\\sketch\\Arduino_Forum_2.ino.cpp" -o "C:\\Users\\johnr\\AppData\\Local\\Temp\\arduino_build_431498\\preproc\\ctags_target_for_gcc_minus_e.cpp"

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\johnr\\AppData\\Local\\Temp\\arduino_build_431498\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\johnr\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\johnr\\AppData\\Local\\Temp\\arduino_build_431498\\sketch\\Arduino_Forum_2.ino.cpp" -o "C:\\Users\\johnr\\AppData\\Local\\Temp\\arduino_build_431498\\sketch\\Arduino_Forum_2.ino.cpp.o"

C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino: In function 'void echo_comment()':

Arduino_Forum_2:227:21: error: The 'BYTE' keyword is no longer supported.
As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.



     Serial.print(c, BYTE);

                     ^~~~

C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino: In function 'void W_test()':

Arduino_Forum_2:357:25: error: The 'BYTE' keyword is no longer supported.
As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.



       Serial.println(x, BYTE);

                         ^~~~

C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino: In function 'void X_test()':

Arduino_Forum_2:393:25: error: The 'BYTE' keyword is no longer supported.
As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.



       Serial.println(x, BYTE);

                         ^~~~

C:\Users\johnr\OneDrive\Documents\Arduino\Arduino_Forum_2\Arduino_Forum_2.ino: In function 'void loop()':

Arduino_Forum_2:665:25: error: The 'BYTE' keyword is no longer supported.
As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.



       Serial.println(c, BYTE);

                         ^~~~

exit status 1

The 'BYTE' keyword is no longer supported.

This can be summarised as:

As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.

just replace
Serial.print(c, BYTE);
with
Serial.write(c);

and
Serial.println(x, BYTE);
with
Serial.write(x); Serial.println("");.

Fix the four errors, and then the code compiles, and will run.

It's not so much the age; it's the fact that your board has a different processor.

Before you start, why did you use direct port access? I haven't looked at your code. digitalRead/digitalWrite might be a lot faster on the Renesas processor of the R4 boards than on AVR based boards and might be fast enough for you application.

Not really help in the sense of providing a solution. But this is the approach that I would take.

  1. Locate the Arduino15 directory on your computer; see https://support.arduino.cc/hc/en-us/articles/4415103213714-Find-sketches-libraries-board-cores-and-other-files-on-your-computer#boards.
  2. Navigate to the subdirectory packages\arduino\hardware\renesas_uno\1.5.0\cores\Arduino.
  3. Open the file digital.cpp.
    This file contains the functions pinMode, digitalWrite and digitalRead and they are basically very simple (compared to AVR).
    You will e.g. find R_IOPORT_PinRead(NULL, g_pin_cfg[pin].pin, &ret); for the digitalRead.
  4. Start searching your PC for R_IOPORT_PinRead. You will find it in the variants sub directory in the board package packages\arduino\hardware\renesas_uno\1.5.0\variants\yourBoard\includes\ra\fsp\inc\api (line 283/287).
  5. Lightbulb moment
    If there is a R_IOPORT_PinRead, there is more than likely also a PortRead so you can search for that and that would be the function that you're interested in for direct port manipulation.
    And yes, there is.

And that is where I stopped as I don't have a R4 board so can't test, it gives you the idea. You're using Linux (I think) and grep will be your friend. I use grepWin under Windows.

Based on that I think that your code is very old. I found somewhere a reference on the web (can't remember where) that stated that BYTE was dropped long ago (before my time); it should probably be Serial.write(c).

PS
Did you write your code yourself?

1 Like

I've found a topic in the 'Showcase' section of the forum from one of the original authors of the code.

// Rough-and-ready Arduino code for testing, calibrating and using core memory shield.
//
// Copyright 2011 Ben North and Oliver Nash.

It is at: core-memory-shield.

Messrs. North and Nash also have a website with full details of how to make the magnetic core memory, at corememoryshield.com.

There is also a report that they produced on May 11th, 2011 — the 60th anniversary of the original core memory patent.

Ah, in the post above mine :frowning:

Yes, I had considered getting an Uno R3 to use instead of using my Uno R4 WiFi. They aren’t expensive and it would simplify the implementation.

That’s a great idea. So do I uninstall 2.3.6 and install 1.8.19 or can I have both IDE’s installed?

Now that we have some direction on the error in question, maybe the advice of 1.8.19 can be utilized in the 2.3.6 build, but as I mentioned above, I’m not opposed to using the older IDE.

Thanks for your help!

Hi @JohnLincoln and @sterretje,

Yes, this is code originally designed by Mr. North and Mr. Nash. I am recreating their core memory experiment. Once I have it working, I want to expand on it to read some antique core memories I have that might contain data.

I’ve sent the pcb files off to a fast prototyping company and should have them delivered in about two weeks. I have the components in the cart at DigiKey and will be getting those soon. I can get the Uno R3 from Amazon any time.

I’ve been in touch with Mr. Nash and gotten some good advice on the hardware side from him, since my cores will be different than the ones they used.

It seems that if we can put these few programming errors to bed, that the whole project will come together quite nicely.

I appreciate everyone’s help!

I don't think that there is any need to use direct port access.

As far as I can see, the only 'critical' timing is the width of the enable pulse.

The width of the pulse is meant to be 2µs.

This is how it is generated:
static unsigned int WRITE_ON_US = 2;

PORTD |= ENABLE; // Enable separately to be safe.
delayMicroseconds(WRITE_ON_US);
PORTD &= (~ENABLE);

I know that for the Uno R3 (and I assume the Duemilanove as well) that there is a slight discrepancy between the value specified for delayMicroseconds() and the actual delay.
On an Arduino Uno R3, the code actually produces a 1µs delay, instead of 2µs.
So the pulse width can't be that critical.

On an Uno R4, digitalWrite() is faster than on an Uno R3 or Duemilenova.

I have generated 3 pulses of different widths on a Uno R4 using the following code:

digitalWrite(PIN, HIGH);
digitalWrite(PIN, LOW);

digitalWrite(PIN, HIGH);
delayMicroseconds(1);
digitalWrite(PIN, LOW);

digitalWrite(PIN, HIGH);
delayMicroseconds(2);
digitalWrite(PIN, LOW);

Viewed on an oscilloscope they look like:


The pulse widths are approximately 0.65µs, 1.65µs and 2.65µs.
I'm sure one of these will be suitable .

1 Like

You can have both versions of the IDE installed at the same time.
I have both.

1 Like

Hi John,

So here’s some backstory.

I’ve been designing for MPU’s and MCU’s pretty much since their inception. I used assembly language for most of that time, with some BASIC when it was available.

I’m an old dog and teaching me new tricks is somewhat of a struggle LOL.

With that said, I do find the syntax of the C based languages a bit difficult to get my mind around. Simple Arduino code is OK for me, but if we get into much complexity, I loose the plot.

I can typically follow the logic and flow of someone else’s code without too much of a problem, but if I have to make too many changes, the syntax clouds my mind and I loose the flow. Make sense?

This code is more what I’m used to from past experience and seems cleaner.

So how would I roll this into the existing code? Would it be easier to dissect their program flow and try to re-write it for the R4 or should I try to leverage it into the R3?

Thanks!

Find the PINX/PORTX/DDRX (where X is a port) in your code and replace them with the usual. For reference: https://docs.arduino.cc/retired/hacking/software/PortManipulation/

1 Like

Although I said that I didn't think it was necessary to use direct port manipulation for the speed, I'm beginning to wonder.

It is useful for example to be able to change all 5 address lines simultaneously in one operation. Setting each one sequentially might end up being a bit tedious.

If I was doing the project, I think I would stick with the Uno R3, as I have both R3s and R4s available, and the code is historically known to work.

As you already have an Uno R4, and would have to buy an R3, things might be different for you.