AVR-timer1-simple

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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
}

Re: AVR-timer1-simple
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?

Quoted text here. Click to load it



Re: AVR-timer1-simple
On Sat, 5 Jul 2003 07:16:28 -0700, "Clark G. Smith"

Quoted text here. Click to load it

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

Re: AVR-timer1-simple
yeah, back in my AVR days, i used ICC also (you go Richard)...

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

Quoted text here. Click to load it
compiler



Re: AVR-timer1-simple
Quoted text here. Click to load it

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



Re: AVR-timer1-simple
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.
<posted & mailed>

snipped-for-privacy@wp.pl wrote:

Quoted text here. Click to load it


Site Timeline