Can't get fast pwm to do anything!

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is for an atmega644 chip. I'm just trying to get a 50% duty cycle out the OC1A pin which I read is PD5 for the 644. I get a flat 600mV reading. Anyone know what's going on?

I've read the data sheet five times through on this subject and think I'm addressing everything.

Out of ideas.

#define F_CPU 8000000UL  // 8 MHz

#include 
#include 
#include    //see note below about restrictions


int main(void)
{

	DDRD |= (1 << PD5);
	
	// Set on match, clear at bottom
	TCCR1A |= (1 << COM1A1) | (1 << COM1A0);

	// Fast PWM, 10-bit (Mode 7) Top = 0x03FF
	TCCR1A |= (1 << WGM10) | (1 << WGM11);
	TCCR1B |= (1 << WGM12);
	
	// Prescale by 8
	TCCR1B |= (1 << CS11);
	
	OCR1A = 0x1ff;  //512 (50% duty cycle)

	for(;;)
	{
	}

}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can see nothing wrong with the code.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Internal or external clock?

What are your fuse settings?

I had a similar problem where I kept reading and rereading my code, fuse settings and datasheet real frustrating. But it turned out I read my external clock capacitors wrong and put in 2200pF instead of 22pF! Long story short check your hardware specs and connectivity between devices.

I am not encumbered by the restraints of the adult mind.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Internal clock. Appears to be fused as such accordingly.

SPIEN is enabled of course.
Brown-out detection disabled.
BOOTSZ is set to a size of 4096.

All other fuses are blank.

I found another 644 on my shelf and tried the same program on it. Still no dice.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Problem solved. I was using the wrong red socket on the stk500. Grrr. Not the first time that's happened.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I was using the wrong red socket on the stk500.

And it didn't complain during programming?

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No. That's why it always gets me.