Society of Robots - Robot Forum

Software => Software => Topic started by: PAT_McUser on April 09, 2010, 03:26:07 PM

Title: timercontrolled beeper
Post by: PAT_McUser on April 09, 2010, 03:26:07 PM
hi,
i hope you can help me this time.
My idea is to make a beeper several noises.
The noismaking is not the problem, how you can sea in the methods signature I want to define frequency and time.
My problem is how to stop the beeping after the in time defined ms.
I can't find a mistake in my code, but maybe you can help me.

Code: [Select]
void beep(unsigned int time,unsigned int freq)
{
unsigned int w,m;
float t;
t=((float)1)/((float)freq);
w=(unsigned int)(t*1000);
init_timer5(TIMER_CLK_64);
reset_timer5();

while(TCNT5<time)
{
rprintf(" %d",TCNT5);
PORT_ON(PORTC,0);
delay_ms(w);
PORT_OFF(PORTC,0);
delay_ms(w);
}
}
Title: Re: timercontrolled beeper
Post by: chelmi on April 09, 2010, 03:34:42 PM
what is the frequency of the your mcu ?
Title: Re: timercontrolled beeper
Post by: Soeren on April 09, 2010, 07:25:35 PM
Hi,

Check if "TCNT5" is updated at all.
Title: Re: timercontrolled beeper
Post by: PAT_McUser on April 17, 2010, 04:54:42 AM
what is the frequency of the your mcu ?
I use the axon, so I have 16MHz frequenzy

Hi,

Check if "TCNT5" is updated at all.


TCNT5 should be the counter, so I think it should be updatet (I'll test it, but I think so)