Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

What is your suggestion?

2006-12-07 by Reza

Hi all;

1st excuse me for poor english;

I'm working with AVR micros more than three years. Working in a 
company in Automation department. I use Code Vision AVR compiler for 
test perposes and WinAVR with AvrStudio 4 for final project. but 
there are some problems in all projects:

1- In some cases i need a software environment to test entire model 
as completely as possible. I tested proteus for simulation but is is 
a powerfull but bad designed program. AvrStudio has no capability to 
write plugins for.
in some cases I need to define harware for my model. I tested using a 
simulator working in DOS/Windows for my applications but having a 
great simulation software needs great time to spend.

2- In some cases, specially defining a serial port protocol, I need 
to use state machine, rather than using multi-task kernels. but 
defining and implementation of a state machine is a time consuming 
task. and when you want to change any logic you may need to review 
all work. is there any tools which could be customized to generate 
AVR assembly or C code in help of state machine design?

3- in C when you want to access a variable in both main code and 
interrupt handlers, you have to declare it as volatile to avoid 
memory access optimization using registers. but if variable be of 
type int, or something larger than one byte in size, bcz access made 
in more than one instruction you may get invalid results. consider 
this:

volatile short n;

SIGNAL(...)
{
   n++;
}

main()
{
   int t = n;
   ....
}

in main() function assembler code looks like this:

    lds r24,n
    lds r25,n+1

if an interrupt happens between two lds instructions and if <n>
have a value of 255 before first lds, you will get 511. in these cases
i may use cli/sei to block interrupts, but is there another way to 
notify the compiler to generate code for me? accessing to data types 
other than byte is not atomic.

4- some compilers have an ability to use near calls when possible 
rather than long calls to reduce code size. is there any way in GCC 
to declare a function as <near> or something? by now I use assembly 
code to reduce code size, using rcalls, instead of call instructions.

Thanks for any suggestion;

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.