Clock speed

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

User avatar
mikn
Posts: 209
Joined: Mon Mar 03, 2014 10:11 pm
Has thanked: 54 times
Been thanked: 41 times
Contact:

Clock speed

Postby mikn » Thu Apr 24, 2014 9:57 pm

I've got atmega168 running with int. oscillator at 8mhz
but to have normal 1s delay I need to set Clock speed in General optons to 1mhz.
When I set clock speed to 8mhz as it must be I meet problems with UART speed, on bitrate over 1200bps I have unreadable symbols. When I set back to 1mhz, everything is ok.
Does the clock speed in General options linked to the real clock speed or is it just for reference of something or what?
FC 6.1.3.2 (18.02.2016)

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8812
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2558 times
Been thanked: 3712 times
Contact:

Re: Clock speed

Postby medelec35 » Thu Apr 24, 2014 10:10 pm

Hi mikn,
The clock speed in options is used for delays and within components that require delays e.g LCD displays.
It's also used for components that require calculations e.g baud rates,PWM etc.
That is why the clock speed in options must match the osc speed of your hardware.
The clock speed will not change the hardware osc speed.

Sounds to me like the internal osc is not running at the correct speed of 8MHz?


Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
mikn
Posts: 209
Joined: Mon Mar 03, 2014 10:11 pm
Has thanked: 54 times
Been thanked: 41 times
Contact:

Re: Clock speed

Postby mikn » Thu Apr 24, 2014 10:39 pm

Code: Select all

Sounds to me like the internal osc is not running at the correct speed of 8MHz?

Hm. Do you think I need to do some additional operations to run atmega168 at 8mhz rather than just setting it in Config tab? It's not so smart chip if compared to pic24f where I've got same problems.
What config can you advice me to try?
FC 6.1.3.2 (18.02.2016)

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8812
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2558 times
Been thanked: 3712 times
Contact:

Re: Clock speed

Postby medelec35 » Thu Apr 24, 2014 11:02 pm

Sorry I can only generalise.
I could help if it was PIC.

The only thing I can suggest is see if someone who knows more about atmega posts something before tomorrow evening,
If thy don't then I will see if I can sort my atmega out and have a play tomorrow evening, and let you know the outcome.

Have you tried selecting a different internal speed from the configuration menu and see if it changes the delay speed at all?
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
mikn
Posts: 209
Joined: Mon Mar 03, 2014 10:11 pm
Has thanked: 54 times
Been thanked: 41 times
Contact:

Re: Clock speed

Postby mikn » Thu Apr 24, 2014 11:23 pm

Yeah, I tried most of settings from 128khz to 8mhz. Changed clock speed also to different values. Played with CKDIV8 bit. Also changed UART speed from 1200 to 57600.
The only stable config is Int. 8mhz / Clock speed 1mhz / UART speed 1200bps.
All other sets of settings either won't run or give unreadable data into the uart terminal (seems to be unsynchronized uart speed).

Along with this problem I have other two with pin remapping. UART is connected right on Channel1 and initialised ok, but I also have 24lc512 memory connected to non-standart pins of i2c channel and it initializes only in Software mode. in Ch1 mode with changed pins it freezes.

Fortune is not on my side. :cry:
FC 6.1.3.2 (18.02.2016)

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8812
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2558 times
Been thanked: 3712 times
Contact:

Re: Clock speed

Postby medelec35 » Fri Apr 25, 2014 3:28 am

Just as an experiment with clock at 1MHz so delays are correct. What happens if you only change the internal osc settings within configuration settings. Does the delay time change? If the delay time does not change then it looks like a c code block is required just like it is with PIC. I could bw wrong as I don't know these devices.
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
STibor
Posts: 262
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 115 times
Been thanked: 112 times
Contact:

Re: Clock speed

Postby STibor » Fri Apr 25, 2014 5:25 am

Hi Mikn,

Watch the AVR fuse bits settings. (AVR Studio 4 is shown in the picture)
Find the C(L)KDIV8 bit. If you have enabled eight sub-divide the system clock signal.
Attachments
fuse.jpg
fuse.jpg (69.25 KiB) Viewed 2832 times
These users thanked the author STibor for the post:
medelec35 (Fri Apr 25, 2014 12:45 pm)
Rating: 5%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8812
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2558 times
Been thanked: 3712 times
Contact:

Re: Clock speed

Postby medelec35 » Fri Apr 25, 2014 12:44 pm

I have just compile a Flowchart to hex, and there are no fuses set.
so this looks like a bug so requires reporting.
This is confirmed by looking at the generated C file
It looks like you will need something like AVR studio to load the flowcode hex file and then set the configuration settings & program target device.

As I stated before i'm more of a PIC person, but what I do know is STibor is 100& spot on.
You will need to watch the fuse settings!
This is the warning that pops up with my programmer:
atmega fuses.png
atmega fuses.png (17.7 KiB) Viewed 2813 times


The reason why you need to set clock at 1MHz, is because the default setting of ATMEGA128 runs the hardware with an internal clock frequency of 1MHz.
So that mystery is solved.

Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
mikn
Posts: 209
Joined: Mon Mar 03, 2014 10:11 pm
Has thanked: 54 times
Been thanked: 41 times
Contact:

Re: Clock speed

Postby mikn » Fri Apr 25, 2014 12:51 pm

both enabled and disabled ckdiv8 bit doesn't play any role, nothing changes.

medelec35, I program firmware with codevision's tool. Anyway I could not speed up the uart port at least to 9600. 4800 was the maximum.
Also I can't initialize memory chip on i2c Ch1. Only software mode.
It's ok for me even it will run with 1mhz, it's enough. But why uart and i2c don't run as needed...
Attachments
sc-config1.GIF
sc-config1.GIF (19.6 KiB) Viewed 2812 times
Last edited by mikn on Fri Apr 25, 2014 12:56 pm, edited 1 time in total.
FC 6.1.3.2 (18.02.2016)

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8812
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2558 times
Been thanked: 3712 times
Contact:

Re: Clock speed

Postby medelec35 » Fri Apr 25, 2014 12:54 pm

mikn wrote:both enabled and disabled ckdiv8 bit doesn't play any role, nothing changes.

medelec35 wrote:I have just compile a Flowchart to hex, and there are no fuses set.
so this looks like a bug so requires reporting.
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8812
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2558 times
Been thanked: 3712 times
Contact:

Re: Clock speed

Postby medelec35 » Fri Apr 25, 2014 1:23 pm

mikn wrote: But why uart and i2c don't run as needed...

I know there is also a bug with I2C not working.
That has been resolved.
So when the next update is released you will be able to get that working (unless I2C updated files are posted before the official release date).

As for uart, since hardware running at 1MHz (no matter what configuration settings are) you will need to set the clock speed in general options to 1MHz to match hardware.
as you have stated before:
mikn wrote:When I set back to 1mhz, everything is ok.


If you want to run your hardware at a speed greater than 1MHz then you should use AVR studio to set configuration settings and program device.

Perhaps other alternative is if FCDx file is edited with correct configuration settings, but matrix staff would be in a better position to advise whether it's possible or not?

Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
mikn
Posts: 209
Joined: Mon Mar 03, 2014 10:11 pm
Has thanked: 54 times
Been thanked: 41 times
Contact:

Re: Clock speed

Postby mikn » Sat Apr 26, 2014 7:47 am

Thanks. Changed fuses during programming in Codevision and it depends on them. However if I change config in FC and program it, it doesn't play any role. Will wait for FC update. Hope they will fix this.
FC 6.1.3.2 (18.02.2016)