Error en registro TIFR del attiny2313. rev 2278
Quote from Lazlo_lozla on April 16, 2024, 4:43 pm¿El registro TIFR debería de estar inicialmente en ceros?
Cuando subo el programa al attiny2313, el osiloscopio no produce una señal PWM. Tampoco el led alterna de encendido a apagado.
Pero al subir este mismo programa "físicamente" al attiny2313APU el led sí alterna de encendido a apagado.
Yo utilizo linux y avrdude 6.3
¿El registro TIFR debería de estar inicialmente en ceros?
Cuando subo el programa al attiny2313, el osiloscopio no produce una señal PWM. Tampoco el led alterna de encendido a apagado.
Pero al subir este mismo programa "físicamente" al attiny2313APU el led sí alterna de encendido a apagado.
Yo utilizo linux y avrdude 6.3
Quote from arcachofo on April 16, 2024, 4:56 pmHi, thanks for reporting.
Can you share your code and circuit?And please use english in this forum.
Hi, thanks for reporting.
Can you share your code and circuit?
And please use english in this forum.
Quote from Lazlo_lozla on April 16, 2024, 8:59 pmI copied the sketch from this page: https://startingelectronics.com/tutorials/AVR-8-microcontrollers/ATtiny2313-tutorial/P8-TC0-polled-timer/#include <avr/io.h> int main(void) { char toggle = 0; DDRD |= (1 << PD6); // LED on PD6 TCCR0A = 0x02; // Clear Timer on Compare Match (CTC) mode OCR0A = 0xFF; // number to count up to TCCR0B = 0x05; // clock source CLK/1024, start timer while(1) { if (TIFR & 0x01) { // timer timed out? TIFR |= 0x01; // reset timer flag // toggle LED each time the timer times out if (toggle) { toggle = 0; PORTD &= ~(1 << PD6); } else { toggle = 1; PORTD |= (1 << PD6); } } } }
#include <avr/io.h>
int main(void)
{
char toggle = 0;
DDRD |= (1 << PD6); // LED on PD6
TCCR0A = 0x02; // Clear Timer on Compare Match (CTC) mode
OCR0A = 0xFF; // number to count up to
TCCR0B = 0x05; // clock source CLK/1024, start timer
while(1)
{
if (TIFR & 0x01) { // timer timed out?
TIFR |= 0x01; // reset timer flag
// toggle LED each time the timer times out
if (toggle) {
toggle = 0;
PORTD &= ~(1 << PD6);
}
else {
toggle = 1;
PORTD |= (1 << PD6);
}
}
}
}
Quote from Lazlo_lozla on April 16, 2024, 9:01 pm#makefile attiny2313 AVR = attiny2313 COMPILE = avr-gcc -Wall -O3 -mmcu=$(AVR) SOURCES = main.c OUTPUT_HEX = main.hex OBJETCS = $(patsubst %.c, %.o, $(SOURCES)) OUTPUT_ELF = $(patsubst %.hex, %.elf, $(OUTPUT_HEX)) all: $(OUTPUT_HEX) %.o: %.c $(COMPILE) -c $< $(OUTPUT_HEX): $(OBJETCS) $(COMPILE) $^ -o $(OUTPUT_ELF) avr-objcopy -O ihex $(OUTPUT_ELF) $@ clean: rm -f *.o *.elf *.hex
#makefile attiny2313
AVR = attiny2313
COMPILE = avr-gcc -Wall -O3 -mmcu=$(AVR)
SOURCES = main.c
OUTPUT_HEX = main.hex
OBJETCS = $(patsubst %.c, %.o, $(SOURCES))
OUTPUT_ELF = $(patsubst %.hex, %.elf, $(OUTPUT_HEX))
all: $(OUTPUT_HEX)
%.o: %.c
$(COMPILE) -c $<
$(OUTPUT_HEX): $(OBJETCS)
$(COMPILE) $^ -o $(OUTPUT_ELF)
avr-objcopy -O ihex $(OUTPUT_ELF) $@
clean:
rm -f *.o *.elf *.hex
Quote from Lazlo_lozla on April 16, 2024, 9:29 pmWhen I load the program C into the attiny2313APU. LED toggle.I don't have an osiloscope. But doing the math with an OC0RA of 255 the result is 1.92 Hz
Quote from arcachofo on April 16, 2024, 10:53 pmThanks for all the information.
Seems that this issue is alredy solved in development version.
This fix will be included in next "tester builds" for 1.1.0.
Have a look here for an update in next days:
https://simulide.com/p/testers/
Thanks for all the information.
Seems that this issue is alredy solved in development version.
This fix will be included in next "tester builds" for 1.1.0.
Have a look here for an update in next days:
https://simulide.com/p/testers/