Hello :D
I am doing a small dc-dc booster for bike white leds. I am using ATtiny85 for that. Actualy I can't make PWM working. I did read the AVR131-Using_the_AVRs_High_-_speed_PWM.pdf and the datasheet of the ATtiny85... I can't figure out what I am doing wrong... but I saw on osciloscope the MCU stoping from working, maybe stoping oscilating his main clock, I don't know. What I am doing wrong... thank you.
/* Configure PWM -- feq. 125KHz */ PLLCSR |= ((1<<PLLE) | (1<<LSM)); /* Enable PLL and Low Speed Mode peripheral clock -> 32MHz */ { unsigned char counter; /* Wait at least 100 us for PLL to stabilize */ for(counter = 0; counter < 250; counter++) { asm("nop"); /* Each NOP should take 500 ns -- MCU Clock at 2MHz */ } } while(bit_is_set(PLLCSR,PLOCK)) ; /* Wait for PLL to lock (approx. 100ms) */ PLLCSR |= (1<<PCKE); /* Set PLL as PWM clock source */ TCCR1 |= ((1<<COM1A0) | (1<<PWM1A)); /* Set PWM mode: toggle OC1A on compare */ TCCR1 |= ((1<<CS10) | (1<<CTC1)); /* Clear Timer/Counter on Compare Match and */ /* select Timer/Counter1 Prescale of PCK -> 32MHz */