Go Down

Topic: Atmega1280 Fast 10-bit PWM (Read 1 time) previous topic - next topic

remiss

Code: [Select]

void setup() {
 
  pinMode(45, OUTPUT); // Or DDRL |= _BV(PL4);
  TCCR5A = _BV(COM5B1) | _BV(WGM51) | _BV(WGM50);
  TCCR5B = _BV(WGM52) | _BV(CS50);
  OCR5B = 512;
}

void loop() { }


This isn't doing what I think the datasheet says it should be doing.. Did I forget some registers or something? Should be no prescaling with 10 bit fast pwm and pin 45 on the arduino mega set to set on bottom and clear on match..

AFAIK timer 5 port b is on pin 45 on the arduino mega.. If I set the ocr5b to 1023 the led lights up a little bit, but not much -- at all other values it's barely visible.


MarkT

#1
Mar 16, 2012, 08:41 pm Last Edit: Mar 16, 2012, 08:43 pm by MarkT Reason: 1
That seems reasonable, had a look at the datasheet - I've not used that exact mode, I've used mode 1010 (phase-correct, programmed by ICR) before (with 16 bit timer1 on ordinary Arduino.

Does sound rather like its still in 16 bit mode rather than 10...

[edit:  why not read the various counter control registers back and print them out to double check they have the values you hope?  Perhaps one of the #defines is wrong?]
[ I won't respond to messages, use the forum please ]

remiss

#2
Mar 16, 2012, 08:48 pm Last Edit: Mar 16, 2012, 08:53 pm by remiss Reason: 1
Checked that (TCCR5A+B) already and they look ok.

Btw, the voltage seems to be around .62 when not "max" which is around 1.2 or something.

Do you have any code for pwm on atmega1280 that is known to work? I tried a couple of different settings with little luck..

On a side note, analogWrite works.

remiss

Uh, never mind, the pin is broken on the board ("made in china") for some reason.. Can't even remember using it before..

Anyway, substituing 5 with 3 solved the problem.. Thanks Mark :)

Go Up