Tiny45 failed to enable PLL

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

I am trying to enable the phase lock loop frequency multiplier in a tiny45.

/*
 *    Try to enable PLL.
 *
 *
 *      Device: ATtiny45
 *    Compiler: avr-gcc 4.3.2
 *    Library : avr-libc 1.7.0
 */


#include 
#define F_CPU 1000000UL
#include 


void
ioinit (void)
{


  DDRB = _BV(DDB1);
 
  /*
   * Set up PLL
   *
   */

  PLLCSR = _BV(PLLE); //Enable PLL.
  _delay_ms(500);
  while (bit_is_clear(PLLCSR, PLOCK));
  PLLCSR = _BV(PCKE);

  /*
   * Set up 8-bit timer one PWM mode.
   * No pre-scale with PLL.
   */

  TCCR1 = _BV(CTC1) | _BV(PWM1A) | _BV(COM1A0) | _BV(CS10);
  OCR1A = 60;

}

int
main (void)
{

  ioinit ();


  for (;;)
    {

    }

  return (0);
}

What I get is an output wave pules length 60uS period 256us and I get this whether or not I enable the PLL.
The PLL is just not being put to the counter.

Would anyone care to explain what I am doing wrong ?

John

If all else fails, read the instructions.

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

Hi,

When you write

PLLCSR = _BV(PCKE); 

you will also clear the PLLE bit. Try

PLLCSR |= _BV(PCKE); 

And the datasheet says

Quote:
To set Timer/Counter1 in asynchronous mode first enable PLL and then wait 100 μs for PLL to stabilize. Next, poll the PLOCK bit until it is set and then set the PCKE bit.
So you don't have to wait 500 ms.

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

Many thanks snigelen that worked.

John

If all else fails, read the instructions.

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

The long delay was because I had my doughts about the new delay command.

John

If all else fails, read the instructions.