Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Atmel 89c51 Timer ?

Status
Not open for further replies.

phil22uk

New Member
Hi thanks for reading my post.

I'm working on a project to build a small autonomous robot, I'm using an Atmel 89C51AC2 uController to interface the sensors and actuators plus do some calculations etc.

I'm programing in C using the RIDE51 compiler from raisonance.com.

Part of my code requires the use of a timer to calculate the lapsed time between sending an output and recieving an input.

Hoping someone could post up an example of how to configure timer0 or timer1 to do this.

I'm not very experienced with C and don't know what to do to acheive this so any help would be greatly appreciated.

Regards

Phil
 
Check Atmels website: they probably have an example for using the timers.

Look at the datasheet for your controller. You have to write the timer registers to configure them to do what you want. The datasheet will tell you what each bit of the timer regiser does.

The C code to write the timer registers will look like this:
TMOD = 0xff; //set TMOD to all ones
You change the 0xff to make set the bits to the corect values. Use the windows calculator to convert between binary and Hex if you arn't good with hex.

You might be able to find a timer example on www.8052.com

Brent
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top