473,805 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AVR GCC compiler for Atmega168

2 New Member
Hello, here my problem:

I am using AVR GCC compiler for programming Atmega168 microcontroller . I am using an I2C communication, my problem is when I receive a command I run a function and the result of this function should be store in a global variable and remain with this value till next time I need to run this function. OK, this should be possible using an static variable declared in the global part.

static unsigned int value=8; // that's my case

However it doesnt work, it always recovers the same value, 8 in the example.

I would apreciatte if anyone can help me. Thank you
Jun 29 '07 #1
2 3695
JosAH
11,448 Recognized Expert MVP
Hello, here my problem:

I am using AVR GCC compiler for programming Atmega168 microcontroller . I am using an I2C communication, my problem is when I receive a command I run a function and the result of this function should be store in a global variable and remain with this value till next time I need to run this function. OK, this should be possible using an static variable declared in the global part.

static unsigned int value=8; // that's my case

However it doesnt work, it always recovers the same value, 8 in the example.

I would apreciatte if anyone can help me. Thank you
I use Atmega/128 micro processors myself for one project and I suspect that
your watchdog reset the entire thing. A watchdog acts as a leaking bucket: i.e.
when the bucket is empty it resets the cpu; you have to refill the bucket from
time to time to keep your cpu from resets. You can also disable the watchdog
mechanism so your cpu will never be reset by a watchdog.

When your cpu is reset the program's initialized data is loaded from flash rom
again which could explain the behaviour you just described. Disabling watchdogs
can be done by setting the cpu's bootstrap flag; check your manual.

kind regards,

Jos
Jun 29 '07 #2
hechergo
2 New Member
BINGO!, you were completely right.

Thank you very much Jos, I was going crazy with that

I use Atmega/128 micro processors myself for one project and I suspect that
your watchdog reset the entire thing. A watchdog acts as a leaking bucket: i.e.
when the bucket is empty it resets the cpu; you have to refill the bucket from
time to time to keep your cpu from resets. You can also disable the watchdog
mechanism so your cpu will never be reset by a watchdog.

When your cpu is reset the program's initialized data is loaded from flash rom
again which could explain the behaviour you just described. Disabling watchdogs
can be done by setting the cpu's bootstrap flag; check your manual.

kind regards,

Jos
Jul 2 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2333
by: Jeff Epler | last post by:
Hello. Recently, Generator Comprehensions were mentioned again on python-list. I have written an implementation for the compiler module. To try it out, however, you must be able to rebuild Python from source, because it also requires a change to Grammar. 1. Edit Python-2.3/Grammar/Grammar and add an alternative to the "listmaker" production: -listmaker: test ( list_for | (',' test)* )
13
2585
by: Bryan Parkoff | last post by:
You may notice that switch (...) is much faster than function that can gain a big improved performance because it only use JMP instruction however function is required to use CALL, PUSH, and POP instruction that can be slower. I created three functions in an array. Array is called pArray_Func(). pArray_Func() contains three functions. "xx" can be used to point each function. Let say, I have over 1,000 functions. I would put "inline"...
10
2574
by: Bjorn | last post by:
I'm using interfaces in C++ by declaring classes with only pure virtual methods. If then someone wants to implement the interface they needs to inherit from the class. If the implementing class forgets to implement some method I normally get a compile error(if the class is created in some way of course). When using the Visual Studio 6 compiler however, it does not generate a compile error in this case: - I have a implementing class A...
7
3122
by: Tao Wang | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I saw cuj's conformance roundup, but the result is quite old. I think many people like me want to know newer c++ standard conformance test result. Especially, I want to know the compiler conformance of vc7.1, vc8.0, gcc 4.x and intel c++, and also each implementation of STL. The world is moving on, right? :)
14
3151
by: joshc | last post by:
I'm writing some C to be used in an embedded environment and the code needs to be optimized. I have a question about optimizing compilers in general. I'm using GCC for the workstation and Diab compiler for the embedded target. My question is about how compilers optimize certain code sequences. As an example, take the code below. Will the compiler eliminate the actual function call to foo() in the object code generated and just store...
16
2857
by: pj | last post by:
(Was originally, probably wrongly, posted to the vc subgroup.) (This doesn't appear to be a c# problem, but a problem with a bug in the Visual Studio c# compiler, but, any help will be welcome...) Oh, I forgot to list the error messages; I would be delighted if someone could explain how to deduce which line number in which file is the one that the VC compiler cannot handle. Actually I'm using C#, but the only post I could find about...
0
2406
by: rollasoc | last post by:
Hi, I seem to be getting a compiler error Internal Compiler Error (0xc0000005 at address 535DB439): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around this problem, try simplifying or changing the program near the locations listed below. Locations at the top of the list are closer to the point at which the
3
5270
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error (0xc0000005 at address 535F072A): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around this problem, try simplifying or changing the program near the locations listed below. Locations at the top of the list are...
41
18235
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10369
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.