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

PWM freezing due to PWMChannels mapping

PWM Netduino PWMChannels

Best Answer NooM, 11 April 2013 - 12:30 PM

i dont think the netduino 1 has pwm on the led.

also only 4 pwm channs

(5,6,9,10);

 

so iam not suprised your code crashes :)

 

http://www.netduino....duino/specs.htm

Go to the full post


  • Please log in to reply
3 replies to this topic

#1 Sinan

Sinan

    Member

  • Members
  • PipPip
  • 10 posts

Posted 11 April 2013 - 10:05 AM

I am trying to work with PWM but failed to access the onboard led. None of the examples found on the forum will function as expected.

 

The simple example below crashes on a Netduino1 with the 4.2.01 framework.

 

[font="'courier new', courier, monospace;"]using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace NetduinoApplication1
{
  public class Program
  {
  public static void Main()
  {
  PWM pwm = new PWM(PWMChannels.PWM_ONBOARD_LED, 100, 0.5, false);
  pwm.Start();
  Thread.Sleep(Timeout.Infinite);
  }
  }
}[/font]

 

 

As soon as it hits the pwm initialization, the board freezes. After many variations of this code and too many erase&reboot sessions, I have checked the enumeration of the available PWMChannels.

 

[font="'courier new', courier, monospace;"]   Debug.Print("None: " + PWMChannels.PWM_NONE.ToString());
  Debug.Print("LED: " + PWMChannels.PWM_ONBOARD_LED.ToString());
  Debug.Print("Pin 3: " + PWMChannels.PWM_PIN_D3.ToString());
  Debug.Print("Pin 5: " + PWMChannels.PWM_PIN_D5.ToString());
  Debug.Print("Pin 6: " + PWMChannels.PWM_PIN_D6.ToString());
  Debug.Print("Pin 9: " + PWMChannels.PWM_PIN_D9.ToString());
  Debug.Print("Pin 10: " + PWMChannels.PWM_PIN_D10.ToString());
  Debug.Print("Pin 11: " + PWMChannels.PWM_PIN_D11.ToString());[/font]

 

Rather disturbing debug.print results:

[font="'courier new', courier, monospace;"]None: -1
LED: -1
Pin 3: -1
Pin 5: 0
Pin 6: 1
Pin 9: 2
Pin 10: 3
Pin 11: -1[/font]
 

 

Same code for PWM_Pin_D6 works as expected (checked with a logic analyzer).

 

Is the code freezing due to the missing mappings for these pins? And, can I do something to access the onboard led and the pins 3 and 11?

 

Regards, Sinan



#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 11 April 2013 - 12:30 PM   Best Answer

i dont think the netduino 1 has pwm on the led.

also only 4 pwm channs

(5,6,9,10);

 

so iam not suprised your code crashes :)

 

http://www.netduino....duino/specs.htm



#3 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 11 April 2013 - 02:01 PM

NooM is correct.  Specs for the Netduino 1 I/O are:

 

digital i/o features

? all 20 digital and analog pins: GPIO

? digital pins 0-1: UART 1 RX, TX

? digital pins 2-3: UART 2 RX, TX

[color=#ff0000;]? digital pins 5-6: PWM, PWM[/color]

? digital pins 7-8: UART 2 RTS, CTS

[color=#ff0000;]? digital pins 9-10: PWM, PWM[/color]

? digital pins 11-13: SPI MOSI, MISO, SPCK

? analog pins 4-5: I2C SDA, SCL



#4 Sinan

Sinan

    Member

  • Members
  • PipPip
  • 10 posts

Posted 11 April 2013 - 04:00 PM

i dont think the netduino 1 has pwm on the led.

also only 4 pwm channs

(5,6,9,10);

 

so iam not suprised your code crashes :)

 

http://www.netduino....duino/specs.htm

 

Noom,

Thanks for the answer, I missed that in the specs.

 

Intellisense for .NetMF can be annoyingly misleading some times. 

 

Thanks again,

Cheers, Sinan







Also tagged with one or more of these keywords: PWM, Netduino, PWMChannels

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.