Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Netduino Plus I2C crashed?


  • Please log in to reply
10 replies to this topic

#1 Lionel95

Lionel95

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationParis - France

Posted 07 April 2013 - 07:02 PM

Hi,

 

First, I'm sorry for my poor English, I'll try to explain my problem as good as possible.

 

I've started with Netduino Plus (firmware 4.2.0) and I2C bus to attach a MCP23017 (16 GPIO Ports expander) and it works great.

 

But sometimes, when there are a lot of read/write operations, I reach a crash of the "I2C layer". Then only way I have to make this works again is to switch off then on the power supply of the N+.

 

I've unsuccesfully tried the reset pin or the onboard button. I've also tried to redeploy the solution on the board with no success.

 

The rest of the program continues to work corrrectly, only the I2C is crashed.

 

When I look at the SCL and SDA signals, I can see that the bit stream seem to be uncomplete.

 

For example a write of a "0" to GPIOA at address 0x020

 

When it's working :

Attached File  Normal.bmp   25.07KB   21 downloads

 

And when crashed :

Attached File  Crashed.bmp   20.99KB   15 downloads

 

Thanks in advance for your help.

 

Lionel


Schizophrenic bug creator and hunter


#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 08 April 2013 - 07:15 AM

maybe adjust your pull-up resistor values on sda/scl lines. also try lock() your i2c code when you use multiple threads.



#3 Lionel95

Lionel95

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationParis - France

Posted 08 April 2013 - 08:02 AM

Hi Noom, thank a lot for helping me.

 

For now, I'm using 4,7KOhms pull-up resistors on SDA and SCL attached to +5v.

 

I've investigated in my code and find something maybe interresting. Contrary to what I thought I'ts not exactly the amount of read/write operations that makes the crash happend.

 

The board I create is also using serial ports (COM1 & COM2) with a Max232 connected to D0/D1 and D2/D3.

 

I've tried this :

 

-Create a timer to periodically (100ms interval) read the GPIOB which is set as inputs by writing the adress of register then reading the returned value (In my normal operation I use an interrupt port attached to D4 but that way I make it crash in a simplier way than to change the input state to make a read)

 

-Open COM1 (115200 8N1) and connect it to my PC with HyperTerminal and attach a reading routine via onreceive event.

 

The I2C is crashing when I send multiple characters on Serial by simply pressing continuously the same key with HyperTerminal for a time between 5 to 30 secs.

 

I've tried to add thread.sleep(10) after the I2C reading and Serial reading but no succes It stll crashes (less rapidly).

 

Any Idea about an issue between I2C and Serial Ports?

 

The thing that makes me crazy with this is the fact that I have no other way to make it works again than electricaly switch off then on the N+?

 

 

Lionel

 

 

P.S. : Ive tried with my own class then with MultiI2C from .Net MF Toolbox and I've the same issue.


Schizophrenic bug creator and hunter


#4 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 08 April 2013 - 10:54 AM

the mcp also operates at 5v? id go 3.3v with everything, also pullups.

 

you may try the multi-i2c class from the link in my signature, its similiar to netmf-toolbox but includes lock's

(i had troubles w/o them)

 

your pullup resistors are fine.



#5 Lionel95

Lionel95

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationParis - France

Posted 08 April 2013 - 12:29 PM

Hi NooM,

 

Yes, according to the datasheet, the mcp can operate up to 5,5v power supply.

 

I'll try your class and let you know if it solves my issue. Thanks again.

 

Lionel


Schizophrenic bug creator and hunter


#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 April 2013 - 08:05 PM

Hi Lionel, The serial port and i2c features are separate (hardware- and software-wise). When you say that I2C crashes, it sounds like the rest of your app keeps running? If so, pressing the reset button should definitely reboot your Netduino gen1 board. Chris

#7 Lionel95

Lionel95

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationParis - France

Posted 08 April 2013 - 09:20 PM

Hi Chris, Hi Noom,

 

I've tried the class from Noom's playground and unfortunately I'm reaching the same issue.

 

@Chris : When I say I2C crashes, the rest of my app is still running but pressing  reset button just reboot my app, the I2C is still crashed. The only way to make it works again is an electrical off/on.

 

To make a "stress-test" I've made this with Noom's class :

 

A timer is reading GPIOA at Address 0x20 each 2 ms and the routine is returning the value I apply to the inputs. Then I'm playing very fast with a wire on the bit0 of the input (via an optocoupler), I can see the value (with a debug.print) changing from 1 to 0 and 0 to 1 but in about 15 secs the value returned is allways 255.

 

In this case if I reset my N+, the value is still 255, if i redeploy the app, the value is still 255 but if electrically off then on my N+, it works again.

 

With Noom's class, I can see the signals SCL and SDA are still correct, I can see the response from the MCP is correct too by counting the bits and seeing them still changing according to the value I code with inputs... This is why I think the bug is a crash from onboard I2C layer.

 

It turns my brain upside down and make it overheat!!!

 

@Noom and Chris : Maybe I could send you my project to make you see what happens. I'm a little bit disapointed with this issue. I have to deploy a card running 24/24 and I can't let it crashes without even the possibility to have a watchdog resetting it in case of failure.

 

Thanks again for your precious help.

 

Lionel


Schizophrenic bug creator and hunter


#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 April 2013 - 01:49 AM

Hi Lionel, When you say that I2C "crashes", even after a reboot...do you mean that the signal on the I2C pins is permanently high (pulled up)? Or that the device stops responding? If it's an issue with the device no longer responding, you may want to add a FET to power on/off the device. That way you can power-cycle that I2C device whenever it stops responding. If it's an issue with I2C not working after a reboot, I'm going to make an odd suggestion: can you try using the 4.1 firmware on Netduino Plus? If that fixes the issue for you...then we may need to file a bug report with the NETMF team (as that means some state is invalid within NETMF itself after a "software reboot" in 4.2). P.S. The 4.2.0.0 firmware used the old MFUSB drivers and hardware reset IIRC--so that may help with your scenario as well. Also...the new gen2 boards were all designed electrically to support hardware reset. Chris

#9 Lionel95

Lionel95

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationParis - France

Posted 11 April 2013 - 07:33 PM

Hi Chris,

 

In fact it's more complicated, when I say the I2C is crashed it means :

 

-In Reading function, the N+ is polling correctly the device, the device is responding but the value returned by N+ is false (allways 0x0FF instead of the right value) :

 

Attached File  Reading Normal.BMP   22.93KB   9 downloads

Attached File  Reading Crashed.BMP   22.86KB   6 downloads

 

-In Writing function, the bit Stream from N+ is incomplete :

 

Attached File  Writing Normal.BMP   25.43KB   5 downloads

Attached File  Writing Crashed.BMP   21.2KB   5 downloads

 

To make a good test, my breadboard is powered by a stabilized 12v power supply and a 7805 makes the 5v power supply. My N+ is powered by the USB port (the GNDs are common). In this way I can switch on and off the breadboard and the N+ separately.

 

Resetting the breadboard doesn't resolve the problem, the device still runs normally.

The N+ is still running but the I2C makes strange stuffs as you can see.

 

I'm going to flash the firmware v4.1 as you ask me and I'll tell you the result.

 

Lionel


Schizophrenic bug creator and hunter


#10 Lionel95

Lionel95

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationParis - France

Posted 13 April 2013 - 11:51 AM

Hi Chris,

 

As you asked me, I've tried to deploy my project on Microframework v4.1 and the problem is still the same. :(

 

To go forward with my projet, I'm going to try to use SPI instead of I2C (fortunatelly the 16 bits GPIO extender MCP23017 exists as an MPC23S17, the same but with SPI port!) but the problem is not really solved this way and I2C port is much more interresting to use than SPI for me.

 

Let me know what I can test to help you to find the problem.

 

Lionel


Schizophrenic bug creator and hunter


#11 Lionel95

Lionel95

    Member

  • Members
  • PipPip
  • 10 posts
  • LocationParis - France

Posted 18 April 2013 - 07:57 PM

up!


Schizophrenic bug creator and hunter





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.