Time problem, delay_us function

Beta Testing discussion on mikroC PRO for AVR.
Post Reply
Author
Message
miletheking
Posts: 2
Joined: 22 Nov 2009 00:25

Time problem, delay_us function

#1 Post by miletheking » 22 Nov 2009 13:29

Hi, I have problem with delay_us function. I was connect to port B led diode. In my program I light on diode for 10000 ms and light off diode for 10000ms. If my clock is 1 Mhz led will be on for 10 second and off for 10 second. If my clock is 2 Mhz led will be on for 5 second and off for 5 second. Why clock affect on delay_ms function?

My main problem is to create signal which is on high level for 1.8 ms and on low level for 20 ms. Can I be sure that if I use function delay_us(1800) and delay_us(20000) with clock of 1 Mhz that my signal will lock as I want?

I use bigavr2 board with ATmega 128 microcontroler.

User avatar
nikola.kostic
mikroElektronika team
Posts: 433
Joined: 11 Aug 2009 12:12

Re: Time problem, delay_us function

#2 Post by nikola.kostic » 25 Nov 2009 17:18

miletheking wrote:Hi, I have problem with delay_us function. I was connect to port B led diode. In my program I light on diode for 10000 ms and light off diode for 10000ms. If my clock is 1 Mhz led will be on for 10 second and off for 10 second. If my clock is 2 Mhz led will be on for 5 second and off for 5 second. Why clock affect on delay_ms function?
Delay is calculated from the clock, so you need to set oscillator/frequency settings correctly in your project. Don't forget that these settings can depend on quartz used on your board.

Post Reply

Return to “mikroC PRO for AVR Beta Testing”