This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Hex file not running correctly

Hi,

I'm trying to get some of the example programs running on my SK-167CS board, but I'm finding that the hex files that uVision2 generates does not work correctly. Running the examples via the uVision2 debugger works correctly, but not when I load up the generated hex file (using PHYTEC FlashTools 16W).

It seems that global variables in the code are not being accessed properly. For example:

#include <reg167.h>

int num = 0;

void serialout(int a); /* code to send 'a' to the RS232 port */

void main()
{
while(1)
{
serialout(num);
num++;
}
}

The above code *should* have "12345..." printed out to the port (seen using a terminal program) but instead I get some rubbish like "q535q535q535...". Now, if the variable 'num' was a local variable inside main(), then it produces the correct output.

Is there something I'm missing? (I'm very new to microcontroller programming so I'm pretty sure there's a big chunk of something missing :)

TIA

0