To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 8281
8280  |  8282
Subject: 
IC problem
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Sun, 4 Feb 2001 22:18:14 GMT
Viewed: 
970 times
  
I have written a small program for the Handyboard to test program flow in
IC. It is supposed to print "Step1", "Step2", Step3" in sucession to the LCD
in an endless loop until I reset the board. It works properly through 12
cycles but on the 13th cycle, the program hangs up and "RUNTIME ERR 04" is
printed out on the LCD. According to the HB Technical Reference Manual this
is indicating a stack overflow error in running process but I am not running
any processes that I know of. If anyone could help me out and tell me where
my mistakes are I would be most thankful.

John Edwards

The following is my troubled program:

/******************/
/*  Test_Loop.c   */
/******************/



int n;

void main()                       /* Push Start Button to Start */
{
  while(!start_button());
  increment();
  while(start_button());
}

void increment()                  /* Add 1 to n each time through */
{                                /* When n becomes larger than 3 */
  n =  n + 1;                     /* n is reassigned the value of 1 */
  if(n < 1)
   {
    n = 1;
   }
  if(n > 3)
   {
    n = 1;
   }
  control();
}

void control()                    /* Reads Global Variable and */
{                                /* Directs program to one of */
  if(n == 1)                      /* the Step# functions */
   {
    step1();
   }
  if(n == 2)
   {
    step2();
   }
  if(n == 3)
   {
    step3();
   }
}

void step1()                      /* Prints Step Number, Delays .1 second */
{                                /* then Returns program to increment
function */
  printf("\nStep1");
  sleep(.1);
  increment();
}

void step2()                      /* Prints Step Number, Delays .1 second */
{                                /* then Returns program to increment
function */
  printf("\nStep2");
  sleep(.1);
  increment();
}

void step3()                      /* Prints Step Number, Delays .1 second */
{                                /* then Returns program to increment
function */
  printf("\nStep3");
  sleep(.1);
  increment();
}



Message has 1 Reply:
  Re: IC problem
 
Hi. The default process is running of out stack. This is because you've written a program in which one function calls another, which calls another, which calls the first. Each time a function is called, an internal "call stack" must keep track of (...) (24 years ago, 4-Feb-01, to lugnet.robotics.handyboard)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR