Slow writing to LCD

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times

Slow writing to LCD

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Slow writing to LCD

Post 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.

iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times

Re: Slow writing to LCD

Post by iain wilkie »

Hi Ben,

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

Cheers

Iain

iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times

Re: Slow writing to LCD

Post 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
Attachments
LCD Test.fcf_avr
(6.5 KiB) Downloaded 292 times

iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times

Re: Slow writing to LCD

Post by iain wilkie »

Have had no response to this query so far .....

Is there any progress ?

Iain

iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times

Re: Slow writing to LCD

Post 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

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: Slow writing to LCD

Post 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.

iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times

Re: Slow writing to LCD

Post by iain wilkie »

Hi Sean,

That all seems fine now .... thanks

Iain
:P

Post Reply