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 freezes Netduino2

Netduino2 PWM

Best Answer Poroh-kun, 15 March 2013 - 07:05 PM

oh.. thanks, but i was already found the problem.

i was conflict between this:

static OutputPort[] leds = new OutputPort[7]{	    new OutputPort(Pins.GPIO_PIN_D7, false),	    new OutputPort(Pins.GPIO_PIN_D8, false),	    new OutputPort(Pins.GPIO_PIN_D9, false),	    new OutputPort(Pins.GPIO_PIN_D10, false),	    new OutputPort(Pins.GPIO_PIN_D11, false),	    new OutputPort(Pins.GPIO_PIN_D12, false),	    new OutputPort(Pins.GPIO_PIN_D13, false)};

and this:

PWM pwm = new PWM(Pins.GPIO_PIN_D10);

 

there are two items on D10.. omg, i so sad..

Go to the full post


  • Please log in to reply
2 replies to this topic

#1 Poroh-kun

Poroh-kun

    New Member

  • Members
  • Pip
  • 3 posts
  • LocationMoscow, Russia

Posted 14 March 2013 - 09:01 PM

SecretLabs.NETMF.Hardware.PWM pwm = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D7);
const uint period = 3 * 1000 * 1000;   // 3 ms
const uint duration = 2 * 1000 * 1000;  // 2 ms
pwm.SetPulse(period, duration);

(from here: http://10rem.net/blo...-modulation-pwm )

 

When i deploy this code, device passes in a state, where i cannot deploy any other projects.

 

It shows "Preparing to deploy asseblies to the device" for long time and then error "Unable to communicate with device - USB:Netduino".

 

When i reattaching usb cable it sends by serial port this:

 

EXCEPTION 0x05:
  cpsr=0x21000000
  pc  =0x08045306
  lr  =0x08048d17
  sp  =0x2001fc90
  r00 =0x4001fc04
  r01 =0x00000000
  r02 =0x00000001
  r03 =0xf0000000
  r04 =0x40010400
  r05 =0x00000000
  r06 =0xffffffff
  r07 =0x00000002
  r08 =0x20001764
  r09 =0x20001130
  r10 =0x00000000
  r11 =0x00000000
  r12 =0xf0000000

 

 

reflashing firmware returns it to normal mode, but what is it? How can I use PWM without this problems?



#2 Lunddahl

Lunddahl

    Advanced Member

  • Members
  • PipPipPip
  • 152 posts
  • LocationEurope, Denmark

Posted 14 March 2013 - 11:07 PM

This might help:

 

Remember to a a reference to: Microsoft.SPOT.Hardware.PWM

 

 

using System.Threading;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace NP2.Examples_PWM{    public class Program    {        static PWM led1;        public static void Main()        {            led1 = new PWM(PWMChannels.PWM_ONBOARD_LED, 1000, .5, false);                        led1.Frequency = 1000;            led1.DutyCycle = .5;            led1.Start();                        while (true)            {                double startValue, endValue;                for (startValue = 4.712; startValue < 10.995; startValue = startValue + 0.1)                {                    endValue = System.Math.Sin(startValue) * .5 + .5;                    led1.DutyCycle = endValue;                    Thread.Sleep(10);                }            }        }    }} 

- Ulrik Lunddahl



#3 Poroh-kun

Poroh-kun

    New Member

  • Members
  • Pip
  • 3 posts
  • LocationMoscow, Russia

Posted 15 March 2013 - 07:05 PM   Best Answer

oh.. thanks, but i was already found the problem.

i was conflict between this:

static OutputPort[] leds = new OutputPort[7]{	    new OutputPort(Pins.GPIO_PIN_D7, false),	    new OutputPort(Pins.GPIO_PIN_D8, false),	    new OutputPort(Pins.GPIO_PIN_D9, false),	    new OutputPort(Pins.GPIO_PIN_D10, false),	    new OutputPort(Pins.GPIO_PIN_D11, false),	    new OutputPort(Pins.GPIO_PIN_D12, false),	    new OutputPort(Pins.GPIO_PIN_D13, false)};

and this:

PWM pwm = new PWM(Pins.GPIO_PIN_D10);

 

there are two items on D10.. omg, i so sad..







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.