Sign in

username:

password:



Not a member?

Search avrclub



Search tips

Subscribe to avrclub



avrclub by Keywords

AT90S2313 | AT90S8515 | ATMega | ATmega128 | ECL | FETS | IAR | Keyboard | LCD | STK50 | TMOS | UART

Ads

Discussion Groups

Discussion Groups | AVRclub | Re: [AVR club] need help

Atmel AVR Microcontroller discussion group.

[AVR club] need help - selam tesfaye - Sep 17 9:08:50 2008

can anyone help me with the c programming code=A0using Timer/Counter to swi=
tch led on and off it is urgent !!!
=A0
=A0what i did so far is i use AVR microcontroller and atmega644 and i did t=
he input output pin configuration by connecting input to TOSC1 pin and outp=
ut to PORTB
and the=A0unfinished code is (i start the code like this )
=A0
# include
=A0
void main()
{
=A0=A0 DDBB =3D 0xFF;=A0 // make port B=A0output
=A0=A0 PORTB=3D 0XFF;
=A0
=A0=A0 TCCR1B =3D 0X00; // stop timer
=A0=A0 TCCR1B =3D 0X02; // start timer with clk/8
=A0
i want to initialize the Timer/Counter value TCNTn =3D 0xFFFF; and i want t=
o make loop to turn led on when it reaches some value compair with OCRnx co=
mpair match register

so=A0 i came this far and my problem is how to initialize the Timer/Counter=
value and how to make a loop to switch led on and off .

thank you!!!
=20=20=20=20=20=20

[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )


Re: [AVR club] need help - raj - Sep 18 9:08:06 2008

Dear Friend,

Please us this file and make a project and compile it and =
check for the intended operation.

Regards,
Kundan=20
On Wed, 17 Sep 2008 selam tesfaye wrote :
>can anyone help me with the c programming code=A0using Timer/Counter to sw=
itch led on and off it is urgent !!!
>
> =A0what i did so far is i use AVR microcontroller and atmega644 and i did=
the input output pin configuration by connecting input to TOSC1 pin and ou=
tput to PORTB
>and the=A0unfinished code is (i start the code like this )
>
># includevoid main()
>{
> =A0=A0 DDBB =3D 0xFF;=A0 // make port B=A0output
> =A0=A0 PORTB=3D 0XFF;
>
> =A0=A0 TCCR1B =3D 0X00; // stop timer
> =A0=A0 TCCR1B =3D 0X02; // start timer with clk/8
>
>i want to initialize the Timer/Counter value TCNTn =3D 0xFFFF; and i want =
to make loop to turn led on when it reaches some value compair with OCRnx c=
ompair match register
>
>so=A0 i came this far and my problem is how to initialize the Timer/Counte=
r value and how to make a loop to switch led on and off .
>
>thank you!!!
>[Non-text portions of this message have been removed]
>
Sr. FAE=0D
Excel Eltech inc. =0D
A-76, EOK. New Delhi=0D
110065=0D
ph:9811675688=0D

----------

/*=0D
; Title: Getting Started with AVR=0D
; Subtitle: Timers and Counters, PWM=0D
; Author: Atmel AVR Applications Group=0D
; Date: 01/2003=0D
;=0D
; Compiler: AVR-GCC=0D
; Target: AT90S8515=0D
; Hardware: STK500=0D
;=0D
; Description:=0D
; The application will setup the 16-bit TCNT1 to be a PWM with frequency=0D
; of 300Hz and increase the duty cycle by 1 in the compare match interrupt=
=0D
; handler is called.=0D
; By applying this signal to an LED will it increase its light intensity=0D
; until OCR wraps and then start from 0 again=0D
;*/=0D
=0D
// Include definition file(s)=0D
#include =0D
#include =0D
//#include =0D
//#include =0D
=0D
// Interrupt handler routines=0D
SIGNAL(SIG_OUTPUT_COMPARE1A) // Timer1A Output Compare match Handler=0D
{=0D
=0D
OCR1AL++; //Increase the duty cycle=0D
=0D
}=0D
=0D
=0D
int main( void )=0D
{=0D
DDRD =3D (1< =0D
TIFR =3D TIFR; //Clear all TCNT interrupt flags by writing '1=
' to them=0D
TIMSK =3D (1< OCR1AL =3D 256/2; //Set the compare match value to 256/2 to get =
50% duty cycle=0D
TCCR1A =3D (1< 8bit mode=0D
TCCR1B =3D (1< ivided by 8=0D
//PWM frequency @ 1.23MHz =3D 1.23M/256/8/2=0D
TCCR1B |=3D (1< =0D
_SEI(); // Enable global interrupts=0D
=0D
for (;;) // Eternal loop=0D
{=0D
}=0D
}=0D
=0D
=0D
[Non-text portions of this message have been removed]
------------------------------------



(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )