??? 03/18/07 20:32 Read: times |
#135218 - try this Responding to: ???'s previous message |
M. Astiz said:
Hi Mike,
The program runs in an infinite loop, changing the value of the ports. As I said before, it runs fine when using P1, for example. Mikel What you need to understand with microcontrollers with flash is that there is a limited amount of memory on the chip. Once it exceeds that, some chips go ahead and read the external memory. The reason why I suggested an endless loop at the end of your code is so that the micro won't go to external memory. If it ran fine when you used P1, then there is something attached to P1 that is causing your program to jump to a valid location. First, you need to determine the amount of EEPROM your microcontroller has (for storing code). I'll call this the code space. Then make sure your code size is equal to or less than the code space. If your code is even one byte over, then this can cause problems. It is OK to have fewer bytes of code. Now, make sure you terminate your code like I described, or at least have the microcontroller jump to a lower address. For example, Make your code something like this: start: --code goes here-- section1: --more code goes here-- ljmp section1 or make it like this: start: --code goes here-- --more code goes here-- section1: ljmp section1 this can be good too: start: --code goes here-- --more code goes here-- ljmp start BUT disasters can happen if your jump statement is not completely within code space. For example, if at byte 7999 you started the ljump command, and your code rom space is exactly 8000 bytes (0 to 7999), then you will be in trouble, because in code, LJMP number is expressed as: 02, num1,num2 where num1 is the high byte of number, and the num2 is the low byte. (unless it is reversed) but the important thing to note is that if this instruction started at byte 7999, then it will process LJMP, not the number, because the ljmp code is at byte 7999, and num1 and num2 will be unrecognized because there isn't byte 8000 and byte 8001 in code space. think of it as storing a 3MB file on a floppy. It just can't be done on a floppy. If you still have trouble, then I will guess that your code space is corrupt. In other words, your flash rom (or eeprom) is broken. |