SPI+RA8875 problems with Neo

Discussion in 'UDOO NEO' started by JackChirac, Aug 10, 2016.

  1. JackChirac

    JackChirac New Member

    Joined:
    Aug 10, 2016
    Messages:
    3
    Likes Received:
    0
    Hello everyone,

    I recently try to port my project on the UDOO Neo but I have problems doing it. My project is a SPI communication between an Arduino (MEGA in my case) and a screen driven by a RA8875. I draw eyes on the screen(It's a robot project). I inspire myself from the Adafruit example and I use both of their librairies (Adafruit GFX and Adafruit RA8875). With the Arduino, the project run nicely but slowly, so I wanted to change to a more powerfull board and with more connectivity. I choose the Neo for that purpose.

    The setup of the board is done (UDOObuntu on the SDcard) and I program it from external PC (with my basic Arduino IDE). My IDE tell me that the bytes has been sent and I see somes signals on the SPI pins, so I guess the programmation has been done correctly. Moreover, the signals seems to be the same I got on the Mega (but faster of course). The SPI pins are also correctly wired from the board to my screen according to the doc (13-SCK;12-MISO;11-MOSI;10-SS)

    Despite all this, the screen doesn't start and nothing appears on it. I don't know where is my mistake and what to do next.
    Tell me please if I made a mistake :)
    ->code.ino
    Code:
    // LIBRAIRIES
    #include <SPI.h>
    #include "Adafruit_GFX.h"
    #include "Adafruit_RA8875.h"
    
    // CONNECTIONS A FAIRE
    // Connect SCLK to MEGA Digital #52 (Hardware SPI clock)
    // Connect MISO to MEGA Digital #50 (Hardware SPI MISO)
    // Connect MOSI to MEGA Digital #51 (Hardware SPI MOSI)
    
    #define RA8875_CS 53//Connect SS to 53
    #define RA8875_RESET 255//Pas utilise dans notre cas
    
    //Creation de l'instance tft (ecran drive par le RA8875)
    Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
    
    /* NE FONCTIONNE PAS EN GLOBAL (PENSER A TROUVER UNE SOLUTION)
      //DEFINITION DES VARIABLES UTILES
      int largeur = tft.width();
      int hauteur = tft.height();
    */
    
    ////////////////////////SETUP///////////////////////////////////////////////
    void setup() {
      //Pour la console
      Serial.begin(9600);
    
      Serial.println("------------------------------------------------");
      Serial.println("Initialisation du RA8875");
      /* Initialise le display avec 'RA8875_480x272' ou 'RA8875_800x480' */
      if (!tft.begin(RA8875_800x480)) {
        Serial.println("RA8875 pas trouve!");
        delay(1000);
        //Reset pour Arduino(ne fonctionne pas pour la UDOO Neo)
        //software_Reset();//On reset et on reinitialise
      }
      Serial.println("RA8875 initialise!");
    
      // INITIALISATION DE L'ECRAN
      tft.displayOn(true);  //On allume l'affichage
      tft.GPIOX(true);      //Active le TFT lie au GPIOX
      tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM du retro-eclairage
      tft.PWM1out(255);     //On le met au maximum pour avoir un eclairage maximum
      tft.fillScreen(RA8875_WHITE);
    }
    
    ///////////////////////////////////LOOP////////////////////////////////////////////
    void loop()
    {
    
      //NORMAL YEUX VERTS
      tft.fillScreen(RA8875_WHITE);
      yeuxNormal(220, tft.height() / 2, 580, tft.height() / 2, 0x0601, 0x2FE6);
      delay(5000);
    }
    
    void yeuxNormal(int xGauche, int yGauche, int xDroit, int yDroit, int couleurContourIris, int couleurInterieurIris) {
      //DESSIN DES YEUX
      //-----------GAUCHE------------
      //Cercle noir derriere 1
      tft.fillCircle(xGauche - 6, yGauche - 6, 154, RA8875_BLACK);
      delay(25);
      //Blanc de l'oeil 1
      tft.drawCircle(xGauche, yGauche, 150, RA8875_BLACK);
      delay(25);
      tft.fillCircle(xGauche, yGauche, 149, RA8875_WHITE);
      delay(25);
      //Pupille 1.1
      tft.fillCircle(xGauche + 10, yGauche, 100, couleurContourIris);
      delay(25);
      //Pupille 1.2
      tft.fillCircle(xGauche + 10, yGauche, 93, couleurInterieurIris);
      delay(25);
      //Retine 1
      tft.fillCircle(xGauche + 10, yGauche, 38, RA8875_BLACK);
      delay(25);
      //Reflet 1
      tft.fillCircle(xGauche - 30, yGauche - 60, 30, RA8875_WHITE);
      delay(25);
      //Reflet 1.2
      tft.fillCircle(xGauche + 20, yGauche + 30, 10, RA8875_WHITE);
      delay(25);
      //-----------DROIT----------------
      //Cercle noir derriere 1
      tft.fillCircle(xDroit + 6, yDroit - 6, 154, RA8875_BLACK);
      delay(25);
      //Blanc de l'oeil 1
      tft.drawCircle(xDroit, yDroit, 150, RA8875_BLACK);
      delay(25);
      tft.fillCircle(xDroit, yDroit, 149, RA8875_WHITE);
      delay(25);
      //Pupille 1.1
      tft.fillCircle(xDroit - 10, yDroit, 100, couleurContourIris);
      delay(25);
      //Pupille 1.2
      tft.fillCircle(xDroit - 10, yDroit, 93, couleurInterieurIris);
      delay(25);
      //Retine 1
      tft.fillCircle(xDroit - 10, yDroit, 38, RA8875_BLACK);
      delay(25);
      //Reflet 1
      tft.fillCircle(xDroit - 50, yDroit - 60, 30, RA8875_WHITE);
      delay(25);
      //Reflet 1.2
      tft.fillCircle(xDroit, yDroit + 30, 10, RA8875_WHITE);
      delay(25);
    }
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    There is a line
    #define RA8875_CS 53//Connect SS to 53
    But there is no Pin 53 on the Neo. I suppose this has to be 10

    And what does your Serial Monitor say?
    You are sending data to the Serial device. The Neo does not like that if you are not reading it.
    So for testing have the serial monitor always open or outcomment the serial.println lines.
     
    Last edited: Aug 10, 2016
    JackChirac likes this.
  3. JackChirac

    JackChirac New Member

    Joined:
    Aug 10, 2016
    Messages:
    3
    Likes Received:
    0
    Thank you Waltervl!

    What an idiot I am, I kept the wiring code of the Mega...
    This seems to light the screen (it starts and the screen is white) but nothing is drew on the screen. However you help me and I will try to debug it on my own from now. I'll keep in touch here if I have any problem next.

    Best Regards
     
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    One step in the right direction! Please also read my comments about the Serial.Println when debugging. I added it some minutes later.

    I also see a line about Software_Reset is not functioning for the Neo? What errors do you get?
     
    JackChirac likes this.
  5. JackChirac

    JackChirac New Member

    Joined:
    Aug 10, 2016
    Messages:
    3
    Likes Received:
    0
    For the Software_Reset function, the compiler returns the following error: " Error: bad instruction `jmp 0' ". In the Arduino squetch, I use it to restart the program whenever the screen is not initiated correctly. But, I don't manage to use it on the UDOO Neo so I comment it. For now, I just test without this function. I keep in touch :)
    Thank you for your answers and your support
     

Share This Page