>It does sound like a shortage of data memory, what processor are you using ? PIC16F874 >Try taking a look at the *.occ file generated by the compiler (see page 13 of manual) this maps out the RAM usage of your program. I looked at this and saw that I'm only using about half of the available RAM. What I had been doing is completely filling one RAM bank and I think that this problem was made worse by the compilers reuse of certain locations in RAM for successive local variables. >Local variables are destroyed when a function ends and their memory locations are made available for reuse. If you are running low on RAM look at reducing the number of global variables which are permanently assigned to memory locations. I only have 5 globals! >Functions and variables are never in the same space. Functions are in program memory - >ROM/Flash/EPROM whatever, variables are in >RAM/data memory/register files etc. These are completely seperate in pics unlike some other designs of >processor. OK!, I appreciate this a bit more now. I seem to have solved the problem by placing all the variables in the method you described. Took a bit of thought :-( !! >Keeping all variables in one bank does slightly improve efficiency - but not a great deal - it just means the >bank selection bits >are not manipulated by the code the compiler produces. > Thanks for the hints, worked a treat once I got my brain into gear! Alan -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.