Hi to all. Bit of a nubie hoping for some advice / help. I am having a problem with a mico application that I have developed / written. I am using an 89c4051from Atmel , and am writing the software in C. The compiler that I am using is Raisonance. The problem that I have is that the software keeps jumping out of the main DO...While(1) loop , and I can't figure out why. The software seems to run fine most of the time , but now and then jumps out of the infinite loop. I'll try to explain the code layout.
/* definitions etc #define etc etc
variable definitions
prototypes
//-----------------------------------------Main function / program void main(void)
{ P1_2 = !P1_2; // inserted later to try and find problem initialise(); // initialise function , sets up comms , timers etc
do {
do stuff and call various functions
} while(1);
} //----------------------------------------------------------
various functions
-------------------------------------------------------------------------
-------------------------------------------------------------------------
--------------------------------
Hope this gives some idea of the program structure. The P1_2 = !P1_2 I inserted later to try and find where things were going wrong. I monitor this pin with the scope and every time it changes I know that point in the software has been reached , or that instruction has been run. There are no other references to P1_2 or port 1 as a whole anywhere else in the software.(Yet :0))
On startup that instruction ( P1_2 = !P1_2; ) is run before going into the do_while loop , but that point in the code should never be run gain , barring a reset or power cycle. Correct? As I mentioned I am new to this , so I may be wrong. Anyway , that instruction does keep happening every now and then. How is this possible. Unless 1 does not equil 1 :0) The compiled code generates 2400 odd bytes of code and 91 bytes of RAM. The 4051 has 128 bytes of ram.
A few thaughts I had.
- Stack overflow----- could this cause this sort of problem , and how can I check if this is happening.
Any thaughts on this would be much appreciated.I am a bit stumped here. I have tried another chip , to no avail. Cheers Rob