chipKIT® Development Platform

Inspired by Arduino™

Max32 not all IO pins appear to work?

Created Tue, 27 Mar 2012 03:24:07 +0000 by KurtE


KurtE

Tue, 27 Mar 2012 03:24:07 +0000

As I have mentioned in different threads, I have been playing around with a shield that allows me to connect lots of things to a Arduino Mega as well as the Max32.

I finished assembling one of them and it is working reasonably well. So I decide to try hooking up my servos and try out my Hexapod code... I ran into an issue that some of my IO pins were not working properly with the servo code. I have used both the Servo library as well as the SoftPWMServo libraries to talk to the pins. The digital pins that I have found so far include: 24, 26, 27, 32, 34

I have tried this on both the latest released build as well as the recent test build. My guess is that the stock AllServo... example program will show it as well. One test program I was using looks like:

#include <SoftPWMServo.h>

const int lowestPin = 2;  // Leave a few for me to test some stuff with...
// Use highestPin = 85 for the Max32 board, and highestPin = 41 for the Uno32
const int highestPin = 38;
int pin;

void setup() {
  Serial.begin(57600);
  
  // The SoftPWMServo library sets any used pins to be outputs, so that's not needed here
  for (pin= lowestPin; pin <= highestPin; pin++) {
    SoftPWMServoServoWrite(pin, 1500);
  }
  pin = lowestPin;
}

void loop() {
  // Go from 1ms to 2ms
  int pos;
  
  Serial.print("Pin: ");
  Serial.println(pin, DEC);
  for (pos = 1500; pos < 1800; pos += 50) {
    SoftPWMServoServoWrite(pin, pos);
    delay(25);
  } 
  
  for (pos = 1800; pos > 1200; pos -= 50) {
    SoftPWMServoServoWrite(pin, pos);
    delay(25);
  } 
  for (pos = 1200; pos <= 1500; pos += 50) {
    SoftPWMServoServoWrite(pin, pos);
    delay(25);
  } 
  pin++;
  if (pin > highestPin)
    pin = lowestPin;
}

I used my Saleae Logic analyzer to also verify that the signal was not being generated. Likewise I removed all servos and removed my shield and verified with analyzer that pins 24, 26, 27 still did not generate a pulse. Note: at this point I only tested the 8 pin (22-29).

Is this normal?

Thanks Kurt


EmbeddedMan

Tue, 27 Mar 2012 06:00:08 +0000

When I run your attached code on my UNO32, the only pins that do not have PWM output are 0, 1, 39, 40 and 41 (all as expected). Every other I/O pin has PWM on it.

Maybe you're doing something wrong when capturing the data?

*Brian


KurtE

Tue, 27 Mar 2012 13:17:10 +0000

Thanks Brian,

I can test it as well on my UNO32 if that would help.

I am pretty sure I am capturing the data properly. That is on my Shield, these pins as well as others are routed to 3 pin servo headers, with power and ground. When I ran my program and later other test programs, the other servos moved as expected.

So I got the analyzer out, plugged into the appropriate pins and checked to see which IO pins were getting what pulses. I found that several pins were not getting any signal. To double check that my own stuff was interfering I removed everything and tested again...

Here is an example trace: [attachment=0]Logic-Trace---No-servo-puls.jpg[/attachment] I had the logic inputs connected starting at digital IO pin 22, so are seeing the traces of pins 22-29. In this you can see for example pin 24 is doing nothing. Looking at the spec sheet for the Max32, I see this pin is listed simply as VBUS. So was wondering if it acted like a normal IO pin. In Board_data.c I see this pin shown as : digital_pin...PORT...: _IOPORT_PC, // 24 VBUS digital_pin...bit_mask...: _BV( 0 ), // 24 VBUS ... NOT_ON_TIMER...

So not sure what else to test here yet...

Kurt


EmbeddedMan

Tue, 27 Mar 2012 13:59:17 +0000

Hmm. On my UNO32, I have pins 0-7 and 27-33 on one header, then pins 8-13 and 34-41 on another header, then A0 a0-A11 on another header. Those are all of the numbered I/O pins I see on my UNO32.

The pin numbered 24 is A10, and I definitely get output on that pin when I run your code. There is no built-in USB on the PIC32MX320, so there is no VBUS to worry about.

I'm not sure why your board is working differently from mine.

*Brian


KurtE

Tue, 27 Mar 2012 15:38:51 +0000

As I mentioned, I am using a Max32 (I also have an UNO32 which I could do similar testing with, but just trying to understand what is going on, on my Max32.

My guess is that it is in some case maybe by design.

That is on the UNO32, Pin24 is marked as only VBUS. Looking at: the Pic32MX5xx\6xx\7xx manual it looks like this pin:

VBUS 34 54 H8 I Analog USB bus power monitor

Is an input only pin?

IO 26: "J9-12 56 D-/RG3" Is:

D- 36 56 J11 I/O Analog USB D
RG3 36 56 J11 I ST PORTG Input pins

IO 27: "27 J9-11 57 D+/RG2" Is:

D+ 37 57 H10 I/O Analog USB D+
RG2 37 57 H10 I ST PORTG input pins

So again it looks like these pins are Input only as well.

Checking the others I was having problems with, I see: IO 32 J9-06 3 PMD5/RE5 - Should work,

RE3 63 99 A2 I/O ST
PMD5 1 3 D3 I/O TTL/ST

IO 34 34 J9-04 99 PMD3/RE3 - Should also work,

RE3 63 99 A2 I/O ST
PMD3 63 99 A2 I/O TTL/ST

I need to double check these, to see if it is because pin can do multiple things? (PMDx - Parallel Master Port data?) and Port E...

Kurt


EmbeddedMan

Tue, 27 Mar 2012 15:46:09 +0000

Kurt,

I'm totally sorry - this has been my fault. You keep writing MAX32 and I keep reading it as UNO32. Too much Diet Dr. Pepper or something. So sorry.

I will re-run the tests on my MAX32 momentarily. Sorry for the confusing messages.

*Brian


KurtE

Tue, 27 Mar 2012 16:00:25 +0000

No Problem:

It looks like 32 and 34 are fine without my shield, now will plug in and try again.

Thanks again for your help.

Kurt

Update: I tried reinstalling my shield and 32 and 34 are not making contact... checked solder joint, looks fine, checked with multimeter and verified that trace is going where I think it is, and that not connected to voltage or ground... 34 makes contact sometimes... Tried pressing in real hard... So for now simply change code to avoid these pins... Will be interesting to see later with different board.


EmbeddedMan

Tue, 27 Mar 2012 17:15:53 +0000

Kurt,

I just went through and upped the 'highestPin' value to 85, and have confirmed that on my MAX32, the only pins that do not generate correct output are 24, 26 and 27.

And it does look like these pins can not be used for digital output, even if USB is disabled. That's too bad.

*Brian


KurtE

Tue, 27 Mar 2012 20:44:07 +0000

Thanks that is what I found as well.

It might be nice if the Max32 Reference Manual mentioned this about those pins.

As for my two other pins that are not working, for now I will just avoid them. I verified that I have continuity from the pin of the stackable header to my IO pin of the 3 pin servo connection, but it is not working. So my stackable header must not be making good contact with the header on the Max32...

Thanks again

Kurt