AVR-timer1-simple

I am not able to understand why on the AVR3.55 simulator below mentioned code gives app. 50sec ticks instead of 1sec

#define CLK 4000000

outp(5,TCCR1B);//prescale CK to CK/1024 outw(63000,TCNT1);//I want 1 sec interval

signal(SIG_OVERFLOW1){ outw(61635,TCNT1); //0xFFFF - CLK/1024 to get 1sec ticks if(bit_is_set(1,PORTB)) cbi(1,PORTB); else sbi(1,PORTB); //toggle output pin }

Reply to
merazetro
Loading thread data ...

well, first off, i would have to question how you are making assembly instruction calls without the "asm" directive? you got the magic compiler or something?

Reply to
Clark G. Smith

Looks like it's the AVR GCC compiler. Some folks think it's magic. ;-)

Possibly an early release since I think they've deprecated the "asm-like" function calls. I use ICCAVR so I'm not 100% sure...

--
Rich Webb   Norfolk, VA
Reply to
Rich Webb

yeah, back in my AVR days, i used ICC also (you go Richard)...

don't know much about GCC........

compiler

Reply to
Clark G. Smith

There isn't a single assembly instruction in his code example. The cbi() and sbi() are GCC AVR "pseudo" functions or macros, which are translated bij the compiler into asm cbi and sbi instructions.

Meindert

Reply to
Meindert Sprang

Meantime I found an answer. The reason is with ATMEL Avr 3.55 simulator. When I verified the pin output toggle with scope it works as should be.

snipped-for-privacy@wp.pl wrote:

Reply to
merazetro

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.