chipKIT® Development Platform

Inspired by Arduino™

MAX32 SPI Loopback

Created Wed, 27 Jul 2011 20:18:23 +0000 by majolsurf


majolsurf

Wed, 27 Jul 2011 20:18:23 +0000

Hello,

I have a new MAX32 and am using mpide-0022-chipkit-win20110619. I have been unable to get the SPI interface to work. Below is a small code snippet I use for debugging, with MOSI looped back to MISO. The read-back byte is all 1's. I have also grounded MISO and still the read-back is 0x255. Am I misusing this library?

#include <SPI.h>


void setup()
{
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV128);

  Serial.begin(9600);
}


void loop()
{
  int mosi_data = 0x55;
  int miso_data = SPI.transfer(mosi_data);
  Serial.println(miso_data,BIN);
  delay(500);  
}

Thanks!

Eric


rtestardi

Wed, 27 Jul 2011 20:44:33 +0000

Are you sure you have MISO (pin 1) and MOSI (pin 4) looped back?

And the other jumpers are in the MASTER position?

Your program seems to work fine for me.

However, I am running one of the daily test builds, mpide-0022-win-20110710-test

1010101
1010101
1010101
1010101
1010101

majolsurf

Wed, 27 Jul 2011 22:02:23 +0000

Ah.... I see... I was using the UNO32 MISO/MOSI pins 12/11 instead of the MAX32 pins 50/51. :lol: The problem was in the cockpit.