Clock speed
Moderator: Benj
- mikn
- Posts: 209
- Joined: Mon Mar 03, 2014 10:11 pm
- Has thanked: 54 times
- Been thanked: 41 times
- Contact:
Clock speed
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?
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)
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Clock speed
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
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
- mikn
- Posts: 209
- Joined: Mon Mar 03, 2014 10:11 pm
- Has thanked: 54 times
- Been thanked: 41 times
- Contact:
Re: Clock speed
Code: Select all
Sounds to me like the internal osc is not running at the correct speed of 8MHz?
What config can you advice me to try?
FC 6.1.3.2 (18.02.2016)
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Clock speed
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?
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
- mikn
- Posts: 209
- Joined: Mon Mar 03, 2014 10:11 pm
- Has thanked: 54 times
- Been thanked: 41 times
- Contact:
Re: Clock speed
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.
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.
FC 6.1.3.2 (18.02.2016)
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Clock speed
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
- STibor
- Posts: 263
- Joined: Fri Dec 16, 2011 3:20 pm
- Has thanked: 116 times
- Been thanked: 113 times
- Contact:
Re: Clock speed
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.
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 (69.24 KiB) Viewed 5851 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Clock speed
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: 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
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: 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
- mikn
- Posts: 209
- Joined: Mon Mar 03, 2014 10:11 pm
- Has thanked: 54 times
- Been thanked: 41 times
- Contact:
Re: Clock speed
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...
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 (19.6 KiB) Viewed 5831 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)
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Clock speed
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Clock speed
I know there is also a bug with I2C not working.mikn wrote: But why uart and i2c don't run as needed...
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:
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.mikn wrote:When I set back to 1mhz, everything is ok.
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
- mikn
- Posts: 209
- Joined: Mon Mar 03, 2014 10:11 pm
- Has thanked: 54 times
- Been thanked: 41 times
- Contact:
Re: Clock speed
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)