Author Topic: timercontrolled beeper  (Read 1653 times)

0 Members and 1 Guest are viewing this topic.

Offline PAT_McUserTopic starter

  • Jr. Member
  • **
  • Posts: 32
  • Helpful? 1
  • I just started with robitic.
timercontrolled beeper
« 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);
}
}
I just started with robitic.

PS.: you have to sorry my bad english.

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
    • Current projects
Re: timercontrolled beeper
« Reply #1 on: April 09, 2010, 03:34:42 PM »
what is the frequency of the your mcu ?

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: timercontrolled beeper
« Reply #2 on: April 09, 2010, 07:25:35 PM »
Hi,

Check if "TCNT5" is updated at all.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline PAT_McUserTopic starter

  • Jr. Member
  • **
  • Posts: 32
  • Helpful? 1
  • I just started with robitic.
Re: timercontrolled beeper
« Reply #3 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)
I just started with robitic.

PS.: you have to sorry my bad english.