Arduino PORTB and PORTD broken?

Hey all,

I was experimenting the other day with my Arduino Nano 3.0 trying to make a 16-bit PWM output.
It actually worked quite well, but to get a decent frequency I had to switch the pin on/off very fast.
I used the 16-bit Timer1 and opted for no prescalers, thus resulting in a frequency of 31.25kHz.
( see http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235060559/4#4 ).

I set the pin on when my timer overflowed and off when the timer matches a set compare value.
It actually worked great, my LED was fading very smoothly. Untill it suddenly became very dim (after experimenting about an hour or 2).
I thought it was just the pin that may have been faulty, but it turns out it happened on all the pins of PORTD (0-7).
So I figured the entire PORTD output was defective, and thought it was just some kind of manufacturing fault.
The other pins (8-13), which are PORTB, still worked fine and I continued developing my PWM output on those pins.
Until disaster struck and they became dim as well !

I tested the pins with a multimeter and still get normal voltage values, a nice +5V and a linear course with increasing PWM value.
However, the current it could output was only 4mA with a resistor of 120 ohms and a blue LED, where it should have been around 16-17!

I have no idea what just happened with my Arduino, did I switch the pin on/off too fast so the entire PORTB/PORTD became corrupt or some lanes melted or something?
Has anybody ever experienced this or has an idea how to solve this?

Thanks in advance,
Youran

did you try a reset and start again?

you do have a resistor in series with your LED don't you?!?
(oops just read ALL your post - seems you do!)

mmcp42:
did you try a reset and start again?

you do have a resistor in series with your LED don't you?!?
(oops just read ALL your post - seems you do!)

Thanks for your input, and yes I did have a resistor in place :wink:

I tried several times to fully power it down and boot it from there.
I even uploaded the most basic sketch imaginable:

void setup()
{
digitalWrite(xx, HIGH);
}

and the pin was still acting up, so I really think something is broken/faulty in my board ..

I have no idea what just happened with my Arduino...

Maybe something happened to your LED.

Don

floresta:

I have no idea what just happened with my Arduino...

Maybe something happened to your LED.

Don

Ah, forgot to mention that:
LED is working perfect when connected to +5V ..

What happens when you run this with the led and resistor?
void setup()
{
pinMode(xx, OUTPUT)
digitalWrite(xx, HIGH);
}

also are you using the correct pins for PWM

Digital I/O Pins 14 (of which 6 provide PWM output)
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

Have you tried your program code using D13 (PB5) and the on-board LED?

Don

what are you powering it from?
maybe PSU has died?

Problem solved !

Turns out I accidentally deleted
pinMode(x, OUTPUT)
(apparently twice) which caused my PWM not to work on those pins !

I got it all figured out now, thanks for the help everyone.
In case anyone is interested, here's my code for realising 16-bit PWM on all digital pins (0-13).
Just attach an LED with a resistor and you'll see it fade extremely smooth :wink:
For use on an atmega328.

#include <avr/interrupt.h>  
#include <avr/io.h>

byte och = 0;
byte ocl = 0;

ISR(TIMER1_OVF_vect) {  
  OCR1AH = och;
  OCR1AL = ocl;
  
  if(och != 0 && ocl != 0) {
    PORTB |= 63;
    PORTD = 255;
  }
};  

ISR(TIMER1_COMPA_vect) {
  PORTB &= 192;
  PORTD = 0;
};

void setup() {
  for(int i = 0; i < 14; i++)
    pinMode(i, OUTPUT);
  
  TCCR1A = 0;
  TCCR1B = 0;

  TCCR1B = _BV(CS10);
  TIMSK1 = _BV(OCIE1A) | _BV(TOIE1);
  
  OCR1AH = 255;
  OCR1AL = 0;
  
  TIFR1 = 1;
}

void loop()
{
  for(byte i = 0; i < 255; i++)
  {
    for(byte j = 0; j < 255; j++)
    {
      och = i;
      ocl = j;
      delayMicroseconds(50);
    }
  }
  
  och = 0;
  ocl = 0;
  delay(200);
}