Is this something like what you were trying to achieve
Increments otherval to 650 then jumps to Do_other_stuff
Decrements otherval to 649 then increments to 650 and so on forever?
Owen.
//ICC-AVR application builder : 30/01/2007 8:29:57 PM
// Target : M16
// Crystal: 4.0000Mhz
#include <iom16v.h>
#include <macros.h>
void port_init(void)
{
PORTA = 0x00;
DDRA = 0x00;
PORTB = 0x00;
DDRB = 0x00;
PORTC = 0x00; //m103 output only
DDRC = 0x00;
PORTD = 0x00;
DDRD = 0x00;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
//Code that doesn't work:
unsigned int otherval;
void Do_other_stuff(void)
{
/* do other stuff here ( caution void does not pass a value */
otherval --;
}
main ()
{
void Do_other_stuff(void);
unsigned int val;
val = 650;
otherval = 0;
while (1)
{
while (otherval < val)
{
otherval++;
}
while (otherval >= val)
{
Do_other_stuff();
}
}
}
[Non-text portions of this message have been removed]Message
RE: [AVR-Chat] Re: C Code weird behaviour help?
2007-01-30 by OWEN-A
Attachments
- No local attachments were found for this message.