changed frequencies, suspect running 8 times slower than thought

This commit is contained in:
Jonathan Wyss 2024-03-06 13:05:14 +01:00
parent 0894b6aac5
commit a4db90ecf4
2 changed files with 4 additions and 4 deletions

6
main.c
View File

@ -1,4 +1,4 @@
#define F_CPU 8000000UL
#define F_CPU 1000000UL
#include <util/delay.h>
#include <avr/io.h>
#include <avr/interrupt.h>
@ -22,7 +22,7 @@ void count(void)
{
//counts=0;//0..65535
counts++;
if(counts>=31)
if(counts>=128) //1m //1ms
{
counts=0;
if(ms<60000)//1 minute
@ -68,7 +68,7 @@ int main (void) { // (2)
cli();
//#######Timer0-setup##### |Phase correct pwm
TCCR0A = (1<<COM0A1)|(1<<COM0B1)|(1<<WGM00)|(1<<WGM01); //mode fast pwm (1/Fcpu)*prescaler*(max+1) =
TCCR0B = (1<<CS00)|(1<<CS00); //frequency /256 = 31250Hz , 1 t0 period = 8.192ms 1 increment = 0.032ms strangly prescaler of 1 results in expected results as prescaler was 256
TCCR0B = (1<<CS01)|(1<<CS01); //prescaler /64 gives 0...255 0.002048s = 2.0ms 1mhz-> /8
// PLLCSR |= (1 << PLLE) | (1 << PCKE);
//######Timer1-setup

View File

@ -5,7 +5,7 @@
# (GNU make, BSD make, SysV make)
MCU = attiny85
MCU = attiny45
FORMAT = ihex
TARGET = main
SRC = $(TARGET).c