Page 1 of 1

Slow writing to LCD

Posted: Sun Jun 20, 2010 6:51 pm
by iain wilkie
I did a wee program with a simple 1 second delay loop and downloaded it into my
ATMEGA16 device. It ran but the delay was very much longer than 1 second. I then noticed that
the micro oscillator was configured for 1 Mhz and my project was set to 20Mhz .... so I changed this
to 1Mhz and download again and the delay was correct .... great !.

I then tried a program to write to the LCD I have connected to the micro. This works but the charactors are
written very slowly about one every few seconds ... took ages to initailise as well. I therefore tried switching
the project speed back to 20MHZ downloaded again .. and hey presto the LCD now writes fine.

So whats right and whats wrong .... it seems to me that the delays in the LCD routine are not changing accordingly
with different clock speeds ?

Iain

Re: Slow writing to LCD

Posted: Mon Jun 21, 2010 4:00 pm
by Benj
Hello Iain

What configuration settings are you using? Could it be possible that the config was changed between using the delay test file and the LCD test file. Seems strange that the LCD is working fine at 20MHz where as the delays are working ok at 1MHz. Would it be possible for you to attach your Flowcode file to have a look at it.

Re: Slow writing to LCD

Posted: Mon Jun 21, 2010 7:18 pm
by iain wilkie
Hi Ben,

I will recheck this and if there is still a problem I will send a sample file.

Cheers

Iain

Re: Slow writing to LCD

Posted: Wed Jun 23, 2010 11:04 am
by iain wilkie
Hi Ben,

Have attched piece of code to demonstrate this .....

Basically the target ATMEGA16 is set to run at 1Mhz .... This is not changed at anytime.

If I set the project to 1000000 and download into the device, the LCD loads up and writes HELLO no problem
but the LED flashes on and off at about 20 seconds (instead of 1 second).

If I now change the project speed to 20000000 and download into the device, the LCD loads up very slowly ... about
1 charactor every second BUT the led now flashes at the correct rate (1 second)....

???????????

Iain

Re: Slow writing to LCD

Posted: Fri Jun 25, 2010 9:32 am
by iain wilkie
Have had no response to this query so far .....

Is there any progress ?

Iain

Re: Slow writing to LCD

Posted: Mon Jun 28, 2010 6:39 pm
by iain wilkie
Just completed this project BUT for 1 second delays I need to program 50ms delays !!!!

Still no responce from you guys regarding this one ...... anybody listening ??????????????????????

Iain

Re: Slow writing to LCD

Posted: Tue Jun 29, 2010 9:54 am
by Sean
Hello Iain,

I have managed to replicate the problem - using a slightly different setup.

The problem is due to a calculation error in the microsecond timer (used by the LCD component) when the clock frequency is less than 4MHz.

I have attached a C file that corrects the problem by using a 10 microsecond timer to perform the same function (which willl operate down to 400KHz clock).
AVR_LCD.c
(10.79 KiB) Downloaded 289 times
This can be copied into the Components folder of your Flowcode AVR installation (backup or rename the original file if you want to retain it).

You should now be able to set the Flowcode clock frequency to match the hardware clock, and have the LED flashing at the correct rate. The LCD will also be updated correctly.

Re: Slow writing to LCD

Posted: Tue Jun 29, 2010 3:05 pm
by iain wilkie
Hi Sean,

That all seems fine now .... thanks

Iain
:P