Au sujet de certains pins et de leur etat

Bonjour , j ' ai une question subsidiaire :worried: au sujet des pins et de leur etats dans mon cas j ' utilise un arduino mega 2560 , shield ethernet , pas de carte SD .

d ' apres ce commentaire il faut activer certains pins et les mettre en sortie haute ou pas , est ce que c ' est toujours vrai ?

 /*
Arduino communicates with both the Ethernet Shield and SD card using the SPI bus
  This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega.
  Pin 10 is used to select the Ethernet chip and pin 4 for the SD card.
  These pins cannot be used for general I/O.
  On the Mega, the hardware SS pin, 53, is not used to select either the Ethernet chip or the SD card,
  but it must be kept as an output or the SPI interface won't work.
  Note that because the Ethernet chip and SD card share the SPI bus, only one at a time can be active.
  If you are using both peripherals in your program, this should be taken care of by the corresponding libraries.
  
  If you're not using one of the peripherals in your program, however, you'll need to explicitly deselect it.
  To do this with the SD card, set pin 4 as an output and write a high to it.
  For the Ethernet chip, set digital pin 10 as a high output.

// ?????????????????????????? i use a mega 2560 , so should i put pin 4, 10, 53 as an output and write a high to it ??????????????
On the Mega, the hardware SS pin, 53, is not used to select either the Ethernet chip or the SD card,
  but it must be kept as an output or the SPI interface won't work.
  ???????????
*/

et donc est ce que je devrais mettre certains pins non connectés en mode output avec etat HIGH ?

oui. Juste la pin 53

Bonjour , alors je dois ajouter la gestion de ce pin dans mon programme , car actuellement , rien ne s ' occupe de ce pin N° 53 .
Dans le commentaire , il n' est pas precisé dans quel etat le placer apres l' avoir mis en OUTPUT .

Si j' ai bien compris ce que veut dire ca :

If you're not using one of the peripherals in your program, however, you'll need to explicitly deselect it.
To do this with the SD card, set pin 4 as an output and write a high to it.
For the Ethernet chip, set digital pin 10 as a high output.

le pin 4 a HIGH sert a dire qu ' on n ' utilise pas de sdcard , ne faudrait il pas que je l' ajoute aussi ?

vous avez un module Ethernet de base ou la version 2?

je pense qu'avec la version de base il faut conserver la pin 53 en OUTPUT et HIGH

Votre carte ethernet contient 2 composants qui parlent sur le bus SPI: la puce ethernet et la carte SD.

Sur le bus les composants partagent MISO, MOSI mais ont chacun une pin dite Slave Select (SS) qui est en sortie sur le micro-contrôleur et est à HIGH pour indiquer que la requête en cours n'est pas pour ce composant et qu'on passe à LOW quand on veut lui parler. (notez que vous trouverez maintenant que le wokisme est passé par là la dénomination Chip Select (CS) au lieu de SS et COPI/CIPO pour “Controller Out, Peripheral In” et “Controller In, Peripheral Out”. Il n'y a plus de maître ni d'esclave).

La UNO ou MEGA disposent d'une pin "matérielle" dédiée au CS et la bibliothèque SPI a besoin que cette pin CS hardware soit en sortie (et HIGH pour ne pas sélectionner ce device). Sans cela la bibliothèque SPI ne fonctionne pas.

Votre shield est branché sur le port ICSP qui duplique les bonnes pins pour le SPI.

sur un UNO le CS matériel c'est la pin 10 et c'est ce qui est utilisé pour Ethernet, la pin 4 sert de CS pour la carte SD.
sur un MEGA le CS matériel c'est la pin 53 mais on continue à utiliser pour la carte SD utilise la pin 4 et la pin 10 sert de CS pour Ethernet. On n'utilise donc pas la pin "matérielle" mais pour le bon fonctionnement de la bibliothèque SPI il faut que cette pin soit en output en HIGH.

Si vous utilisez le nouveau shield avec la bibliothèque Ethernet2 (qui s'appelle Ethernet je crois maintenant) je ne suis pas sûr que ce soit nécessaire

La raison est dans le code source de la bibliothèque
la fonction init prend une valeur par défaut de 10 parce que ça a été écrit pour ce shield qui était fait pour UNO à l'origine.

static void init(uint8_t sspin = 10);

donc si on ne dit rien c'est cette pin qui est prise par défaut. Si vous regardez les exemples, vous verrez qu'on peut aussi passer une autre pin

void setup() {
  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH Shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit FeatherWing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit FeatherWing Ethernet
...

ok merci @J-M-L .
j ' ai ajouté la pin 53 en HIGH dans mon code , je ne vois pas de changement pour le moment .

le shiel est un shiel ethernet W5500 je crois bien .