A fast question about delays

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A fast question about delays.

I am programing a LCD and it has a Fosc=270khz but my micro is an ATmega8 with a of frec=8Mhz.

If I want to do a fuction delay what frecuancy I must use?

I ask this becouse I need a Delay of 50us and If I use as frecuency 8Mhz with a instruccion "NOP" I have enough.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To work out a delay from a frequency just do the reciprocal.

So 1/270000 = 3.7037037037037037037037037037037e-6 which is fairly close to 3.7us. While you could use _delay_us(3.7) you would probably be best programming a timer in CTC mode to toggle a pin for you.

By the way most LCD's are static, what kind of LCD needs 270kHz anyway? Either it's a segment LED and you'd need to use a segment driving controller (like a mega169 or mega329) or it's a raw graphic panel that needs Hsync, Vsync and a pixel clock in which case the AVR8 is not a good choice to drive it as (a) it almost certainly won't drive P_CLK fast enough and (b) there won't be enough RAM for a frame buffer.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

An 8MHz AVR will need 8 x 50 = 400 NOP instructions. So get typing.

You will find it easier to write a delay subroutine that takes an argument. So you write it once and use it many times.

So I suggest you make a delay_10us() subroutine. Then you just call with a value in a register.

Take care to get the correct number of cycles, then you know it will be accurate every time.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok.Thanks. I just have my delays

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Leraldo wrote:
A fast question about delays.

I am programing a LCD and it has a Fosc=270khz but my micro is an ATmega8 with a of frec=8Mhz.

If I want to do a fuction delay what frecuancy I must use?

8MHz of course.