SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By HandyGuy
#192440
Hi all,

I am building a new clock project using the Adafruit 7" 800x480 TFT display, RA8875 driver board, DS3231 RTC, and an Arduino Pro Mini with an FTDI Basic breakout board to load the sketch to the Pro Mini. Part of my sketch is a programmatic reset of the Arduino. I do this by connecting Arduino Pin 3 to the Reset pin through a 1K resistor. The pin is initially set high. When I set it low the Arduino reboots.

Here's a code example to show what I'm doing:
Code: Select all
/*
Name:      Test4.ino
*/

#include <Adafruit_RA8875.h>
// Definitions for connecting the RA8875 Board
#define RA8875_INT 2
#define RA8875_CS 10
#define RA8875_RESET 9

Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);  // 800x600 TFT Display 

void setup() {
   if (!tft.begin(RA8875_800x480))
   {
      Serial.println("RA8875 not found ... check your wires!");
      while (1);
   }

   /* Enables the display and sets up the backlight */
   tft.displayOn(true);
   tft.GPIOX(true); // Enable TFT - display enable tied to GPIOX
   tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
   tft.PWM1out(255);

   // Set up hardware reset on pin D3
   // THESE TWO LINES ARE THE PROBLEM CODE
   pinMode(3, OUTPUT);
   digitalWrite(3, HIGH);

   // Display test pattern, just to show the screen is working OK.
   tft.fillScreen(RA8875_WHITE);   delay(100);
   tft.fillScreen(RA8875_RED); delay(100);
   tft.fillScreen(RA8875_YELLOW); delay(100);
  }

void loop() {


   // Blink a circle on the screen (just to do something)
   tft.fillCircle(400, 240, 20, RA8875_WHITE);
   delay(1000);
   tft.fillCircle(400, 240, 20, RA8875_BLACK);
   delay(1000);


   // Code to reset Arduino 
   // if (some program condition)
   //      digitalWrite(3, LOW);


   return;
}
Here's the problem: When I leave the D3 pin initialization code (pinMode() and digitalWrite()) in the sketch it runs fine with the FTDI Basic board attached to the Pro Mini. As soon as I remove the FTDI board and reset the Pro Mini (running the exact same code) the Mini goes into a boot loop. If I comment out the pin initialization lines and reload the code the sketch runs fine whether or not the FTDI board is attached.

Unfortunately, I'm mostly a software guy. I know enough hardware to get myself into trouble like this, but that's about it. I'm assuming that the FTDI board also uses either the Arduino Pin 3 or the Reset pin in some capacity and that's where the conflict is, but lots of consultation with Dr. Google didn't yield any definitive results. I could also try other unused D-pins on the Arduino, but the board's already wired and soldered (this problem didn't show up in any of my prototype testing), so before I go tearing it apart and making changes I would like to do so methodically and with a plan.

I've already tried "watchdog" code and function pointers to address 0 as alternative reset procedures and neither of those worked as expected. I really like the simplicity of sending a signal to reset, but obviously I'm missing something fundamental. I am hoping you kind folks can give me a clue and a pointer to a possible solution. Is there some way to code this up so I don't need to leave the FTDI Basic board permanently attached to the Pro Mini?

Thanks in advance.