In the program using a timer interrupt 1 or 2 for atmega8, atmega16, an error is generated when compiling into the HEX file. On timer 0 - no error! The cause of the error is that the “interrupt” block forms incorrect names of the interrupt control registers of timers 1 and 2.This can be seen and corrected in the setting (castomize) “C” of this block “interrupt”, having previously configured this block to work with timer 1 or 2. I’ll show atmega8, timer1,the prescaler 1/8:
FC8
TCCR1B &= 0xf8;
TCCR1B |= 0x02;
sei();
TIMSK1 |= (1 << TOIE1);
Given the names of the registers in the datasheet for atmega8
TCCR1B &= 0xf8;
TCCR1B |= 0x02;
sei();
TIMSK |= (1 << TOIE1);
After this fix compilation to the HEX file occurs without errors.
Timer1,2 atmega8,atmega16
Moderator: Benj
Timer1,2 atmega8,atmega16
Last edited by zav1971 on Fri Dec 21, 2018 10:25 pm, edited 1 time in total.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Timer1,2 atmega8,atmega16
Hi zav1971,
Welcome to the forums.
I also tried with a random target device: ATXMEGA192D3with timer 2 and that had the following error:
Thank you for letting us know.
I have moved the topic to Bug Reports.
Welcome to the forums.
I also tried with a random target device: ATXMEGA192D3with timer 2 and that had the following error:
Code: Select all
Launching the compiler...
C:\Program Files (x86)\Flowcode\Common\Compilers\avr\batchfiles\avra.bat atxmega192d3 "D:\Flowcode testing\Flowcode1.elf" "D:\Flowcode testing\Flowcode1.c" "D:\Flowcode testing\Flowcode1.lst"
D:\Flowcode testing>"C:\PROGRA~2\Flowcode\Common\COMPIL~1\avr\BATCHF~1\..\bin\avr-gcc.exe" -mmcu=atxmega192d3 -Os -ffunction-sections -fdata-sections -funsigned-char -o "D:\Flowcode testing\Flowcode1.elf" "D:\Flowcode testing\Flowcode1.c" -lm -Wl,-gc-sections
D:\Flowcode testing\Flowcode1.c: In function 'main':
D:\Flowcode testing\Flowcode1.c:87: warning: large integer implicitly truncated to unsigned type
D:\Flowcode testing\Flowcode1.c:88: error: 'TCC2' undeclared (first use in this function)
D:\Flowcode testing\Flowcode1.c:88: error: (Each undeclared identifier is reported only once
D:\Flowcode testing\Flowcode1.c:88: error: for each function it appears in.)
Error returned from [avr-gcc.exe]
C:\Program Files (x86)\Flowcode\Common\Compilers\avr\batchfiles\avra.bat reported error code 1
FINISHED
I have moved the topic to Bug Reports.
Martin