On Fri, 29 Nov 2013, Neil wrote: > Okay, so I have used the disassembly window before, but never enough > to notice that library functions would be broken down there also. > Neat. I've been playing with it and whittling down the code to as > little as possible and I have a new revelation. > > The delay functions are not the issue. I have two versions of code, > only one of which works, and the difference is a local vs. global > variable. If I use the variable locally inside of the main function, > it stops working. I have disassemblies of both, and will break it > down later. Perhaps someone here can easily catch something I'm doing > wrong. This is the code... > Hi Neil, In a previous post you said that in one case the compiler would stop=20 working. This is what attracted my attention. This further info about the=20 global / local problem is also very interesting. Try changing the name of the global "i" variable to something else,=20 something unique and unused anywhere else. Uncomment out the definition of= =20 the local "i" variable. Does it still work? I wonder if the compiler is getting confused and using the address of the=20 global "i" as an offset into the runtime stack. Regards Sergio Masci > > > unsigned char i; > > void main(void) > { > unsigned char i; // <--- Comment this out and the code works > > OSCCON =3D 0b00010000; // 1 Mhz internal > OSCCON2 =3D 0b00000000; > OSCTUNE =3D 0b00000000; > TRISA =3D 0b11011111; > TRISB =3D 0; > TRISC =3D 0; > ANSELA =3D 0b00000011; > ANSELB =3D 0; > ANSELC =3D 0; > LATA =3D 0b00000000; > LATB =3D 0; > > while (1) > { > LATC =3D 0b01010101; // '0's will turn LED's on. > for (i=3D0; i<250; i++) > Nop(); > LATC =3D 0b10101010; // '0's will turn LED's on. > for (i=3D0; i<250; i++) > Nop(); > } > } // main() > > > > Cheers, > -Neil --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .