Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

at mega16 timer problem.

Status
Not open for further replies.

abilashjoseph

Member level 1
Joined
Sep 8, 2009
Messages
34
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Kerala
Activity points
1,560
hi,
i am try to run the timer0 in the atmega16, but there is no increment on the TCNT0 register, i am using oshonsoft avr simulator. if any other needs in the code?
my code is given below

int main(void)
{
sei();
TCCR0= 0x01;
TIFR = 0x01;
TIMSK = 1<<TOIE0;
while(1)
{

}
}


thanks in advance..
 

I don't see a problem and it runs fine in the AVR studio 4 simulator

Alex
 

The bit posted here is fine. It runs and even produces the interrupt. Don't you need to include some header files? :
Code:
#include <avr/io.h>
#include <avr/interrupt.h>

There isn't any ISR in the code. However, the timer interrupt is enabled.

Hope this helps.
Tahmid.
 

does the avr simulator works with basic code:-? eh??
 

these includes are for AVRstudio/winavr, he is using oshonsoft avr ide which uses basic.



Alex
 

hi,
#include <avr/io.h>
#include <avr/interrupt.h>
these header files are included. and the timer is working with avr studio simulator but not working with oshonsoft simulator. and also the increment in the TCNT0 register
is twice ie, 0,2,4,6,......etc. what is the problem .
 

does the avr simulator works with basic code:-? eh??

The presented code assigns some values to the registers and the code is the same in C and basic, I have no idea about sei(), this is defined in winavr but I don't know if it is also defied in the oshonsoft compiler.
I'm also nor sure if the shift operator can be used in basic.

Alex
 

hi,
#include <avr/io.h>
#include <avr/interrupt.h>
these header files are included. and the timer is working with avr studio simulator but not working with oshonsoft simulator. and also the increment in the TCNT0 register
is twice ie, 0,2,4,6,......etc. what is the problem .

and you don't get an error or a warning for the includes that don't exist in oshonsoft or the sei() function?
You can't copy/paste the C code to a basic compiler.
 

Alex, I think he means that he's using AVR Studio for compiling and Oshonsoft for simulation. The first thing that tells me this is that there are semi-colons at the end of each line. BASIC doesn't require that. Also the use of parantheses {}. BASIC doesn't use these but instead uses words like "end if", "wend", etc
 

hi,
thanks to all.
yes i am using avr studio for compiling and oshonsoft for simulation. but in the Proteus simulation i get the result.
 

it can be directly accessed in avr compiler IDE
example:
TIMSK.TOIE0 = 1
 

hi Tahmid ,
i think that is the problem of oshonsoft simulator. it work correctly in Proteus.
thanks.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top