chipKIT® Development Platform

Inspired by Arduino™

Why does Wire.begin() mess with pins 5 and 6?

Created Sat, 11 Jul 2015 13:38:28 +0000 by EmbeddedMan


EmbeddedMan

Sat, 11 Jul 2015 13:38:28 +0000

I have a user on a Fubarino Mini who has run into something very strange. Using the sketch below, if you comment out the Wire.begin(), then pins 5 and 6 toggle. If you leave it in, they are unusable as outputs and just stick at 0.9V. On a Fubarino Mini, these correspond to PIC32MX250F128D pins 19 and 20, which have the following functions:

19 = PGED3/VREF+/CVERF+/AN0/C3INC/RPA0/CTED1/PMD7/RA0 20 = PGEC3/VREF-/CVERF-/AN1/RPA1/CTED2/PMD6/RA1

Neither pin appears to have anything to do with I2C, so why is Wire.begin() messing with them?

*Brian

#include <Wire.h>         //I2C
 
unsigned long tStart = 0;
 
void setup()
{
    Serial.begin(9600);
    delay(3000);
   
    Serial.println("test IO.........");   
   
    pinMode(5,OUTPUT);          
    pinMode(6,OUTPUT);
    pinMode(7,OUTPUT);
   
    Wire.begin(); //comment out and pins 5 and 6 will toggle - execute and pins 5 and 6 seize at 0.9v
   
}
void loop()
{
 
  //------------------------------------------------------------------------- 
   if ((((unsigned) millis()) - tStart) > 1000 )//---------------------------
   {
       //Place a function here to run every second
      Serial.println("Looping...");     //DEBUG
       digitalWrite(5, !digitalRead(5));
       digitalWrite(6, !digitalRead(6));
       digitalWrite(7, !digitalRead(6));
       tStart = millis();
   }//1 Second routine End----------------------------------------------------
  
}

majenko

Sat, 11 Jul 2015 13:56:14 +0000

MPIDE version?


EmbeddedMan

Sun, 12 Jul 2015 04:38:29 +0000

0023-windows-20140316

*Brian


majenko

Sun, 12 Jul 2015 10:43:10 +0000

Ok, so ancient stuff from before we switched to a DTWI wrapper. To diagnose I am going to have to dig out an old version of Wire.h.

Do you still get the same issue with the newer DTWI based Wire.h? (I suspect not)

Edit: I can see no reason at all for the behaviour you are mentioning. By the way, what does pin 7 do, which is showing the negation of pin 6?


EmbeddedMan

Mon, 13 Jul 2015 04:05:44 +0000

So same exact behavior with 20150626. (latest test build)

*Brian