Very Old XIAO- before SAM21

Why doesn’t this Processor’s SPI function? There is No pin frequency on any of the spi pins, I must have an old dead XIAO. The XIAO down loads just fine, but the pins don’t function as they should? any help would be appreciated.
Unliker

Welcome

Obviously you would need code running that initializes the port(s) and tell them what you want them to do…

What a reply to my question! You must think I don’t know how to program, but I didn’t post any code so… maybe you’d think that. So I’ll post …

//XIAO M0 processor controlling 3-axis Machine processor 3.3v
 //Level shifters for SPI, I2C, and software serial comms
  #include <pcf8574.h>
  #include <SPI.h>
  #include <Ethernet.h>
  #include <EthernetUdp.h>
  #include <Wire.h>
  #include <Adafruit_MCP23017.h>
 // #include <SoftwareSerial.h>
  //SoftwareSerial ssSerial(1, 0); // RX, TX
    #define SS 7 //Ethernet shield CS spi
    #define MOSI 10
    #define MISO 9
    #define SCK 8
  int before = 0;
  Adafruit_MCP23017 mcp1; // I2C
  Adafruit_MCP23017 mcp2; // I2C 
  const int takeastepx = 4;
  const int takeastepy = 14;
  const int takeastepz = 9;
  const int directionx = 6;
  const int directiony = 15;
  const int directionz = 8;
  const int selEncoderx = D0;//was 15// Encoder LS7366 Chip x CS spi pin on MCP1
  const int selEncodery = D1;//was 13// Encoder LS7366 Chip y CS spi pin on MCP1
  const int selEncoderz = D2;//was 11// Encoder LS7366 Chip z CS spi pin on MCP1
//trunctated
byte mac[] = { 
    0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF
    };   
  IPAddress ip(192,168,15,220);
  unsigned int localPort = 50000;
  char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
  EthernetUDP Udp;
  
  PCF8574 safex(0x20);// I2C
  PCF8574 safey(0x21);// I2C
  PCF8574 safez(0x22);// I2C
//Trunciated
void setup() {
  pinMode(MOSI,OUTPUT);
  pinMode(MISO,INPUT);
  pinMode(SCK, OUTPUT);
  pinMode (SS, OUTPUT);
  digitalWrite(SS, HIGH);
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV8);//divide the clock by 8
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
    //delay (100);
  Ethernet.init(SS); // pin 7 on XIAO 3.3v to level shifter to 5v
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);
  Wire.begin();
  Wire.setClock(400000);
  mcp1.begin(3);
  mcp2.begin(4);
  
  pinMode(selEncoderx, OUTPUT); //Encoder X Counter Chip select pin
  pinMode(selEncodery, OUTPUT); //Encoder Y Counter Chip select pin
  pinMode(selEncoderz, OUTPUT); //Encoder Z Counter Chip select pin
//Truncated
 digitalWrite(selEncoderx,HIGH);  //was 15
 digitalWrite(selEncodery,HIGH); //was 13
 digitalWrite(selEncoderz,HIGH); //was 11
  
   
  Serial.begin(9600);
  //ssSerial.begin(9600);
  mcp1.digitalWrite(takeastepx, LOW);// takeastepx
  mcp2.digitalWrite(takeastepy, LOW);// takeastepy
  mcp2.digitalWrite(takeastepz, LOW);//takeastepz
    initEncoderX();
    initEncoderY();
    initEncoderZ();
    clearEncoderCountX();
    clearEncoderCountY();
    clearEncoderCountZ();
}
  

void loop() {
  
    
     Timer();
     if(seq == 1){digitalWrite(SS, LOW);recUdp();Serial.println("Hello");}
     if(seq == 3){readEncoderX();if(R == 0){diss = (pvx);TransUdp();R = 1;}}
     if(seq == 5){digitalWrite(selEncodery,LOW);readEncoderY();}
     if(seq == 7){digitalWrite(selEncoderz,LOW);readEncoderZ();}
     if(seqr == 0 && seq >=8){seq = 0;}
     if(seq == 10 && seqr == 4){Serial.println(seq);clearEncoderCountX();seqr = 0;}
     if(seq == 12 && seqr == 5){clearEncoderCountY();seqr = 0;}
     if(seq == 14 && seqr == 6){clearEncoderCountZ();seqr = 0;}
     if(seq > 14 ){seq = 0;}
     
     // determine position movement for X axis
//Truncated etc...

we assume no one knows how to program…lol 90% of the time we are correct

You probably have a problem in your code or Arduino IDE setup… make sure your board is set to use the Seeduino XIAO

The problem is in the pin definition setup i presume… You have to realize there is a difference between a define and a variable… and how the board support package is doing setup stuff in the background at compile time that is not completely obvious

also the problem is that it is old… and at a time when things were transitioning from Seeeduino to XIAO and not all XIAO are created equal… you also have problems with how the coms are set up between these devices… it is totally frustrating… thats why we are here to help and give past experience

(kinda like how you dont know how to start a model T ford… but i do…)

also the problem can be in how your supporting library is expecting and recieving the pin definitions… It is probably not recieving and setting up correctly

#define D0 (0u)
#define D1 (1u)
#define D2 (2u)
#define D3 (3u)
#define D4 (4u)
#define D5 (5u)
#define D6 (6u)
#define D7 (7u)
#define D8 (8u)
#define D9 (9u)
#define D10 (10u)

thanks for stating no frequency on the pins… that was a good troubleshooting think so obviously the pins are not being set up correctly in the software… unless you started shorting pins with a test light it is 90% sure not a hardware ussue

(kinda like how you dont know how to start a model T ford… but i do…), watch for your hand or you break your Thumb!
So can I burn a new firmware into my old rust bucket XIAO?

i assume you are using Arduino IDE? every time you upload a new sketch it does all you need to do

yes, Arduino IDE 1.8.19 , and I have read the wiki on the XIAO many times, and have the Board set correctly.

Hi there,
Captain obvious says, Try a blinky sketch…
See if its got any pulse?
LOL
HTH
GL :slight_smile: PJ
:v:

which pin is drives the LED?

// LEDs
// ----
#define PIN_LED_13 (13u)
#define PIN_LED PIN_LED_13
#define LED_BUILTIN PIN_LED

#define PIN_LED_RXL (12u)
#define PIN_LED_TXL (11u)
#define PIN_LED2 PIN_LED_RXL
#define PIN_LED3 PIN_LED_TXL

sample code on wiki will work also.

:grin: :ok_hand:

down loaded Blink to it and the led is blinking on and off