Neil, the purpose of TRIS is to make pins input or output. use PORT to drive=A0le= ds on/off. call TRIS in main once and in your while loop use PORT. =A0for single pin l= ets say to toggle PORTbits.RC0 ^=3D 1; =A0 AA On Thursday, November 28, 2013 12:17 PM, Neil wrote: =20 Also just tried this on another computer with MPLAB v8.76 and C18=A0=20 v3.42.=A0 Same non-working behaviour. Cheers, -Neil. Quoting Neil : > Happy Thanksgiving US folks, > > Trying to figure out why code isn't working, I've whittled it down to > this oddity: > > This works, toggling LED's repeatedly as expected... > > while (1) > { > =A0=A0=A0 TRISC =3D 0b10101010;=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // '0's will= turn LED's on. > =A0=A0=A0 for (x=3D0; x<200; x++) > =A0=A0=A0 { > =A0=A0=A0 =A0=A0=A0 Delay10TCYx(255); > =A0=A0=A0 =A0=A0=A0 res++;=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // Dumm= y task > =A0=A0=A0 } > =A0=A0=A0 TRISC =3D 0b01010101;=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // '0's will= turn LED's on. > =A0=A0=A0 res++;=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // Dumm= y task > =A0=A0=A0 for (x=3D0; x<200; x++) > =A0=A0=A0 { > =A0=A0=A0 =A0=A0=A0 Delay10TCYx(255); > =A0=A0=A0 =A0=A0=A0 res++;=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // Dumm= y task > =A0=A0=A0 } > } > > > However, when I switch delay functions and adjust the time units > accordingly, the code stalls at the delay... > > while (1) > { > =A0=A0=A0 TRISC =3D 0b10101010;=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // '0's will= turn LED's on. > =A0=A0=A0 for (x=3D0; x<200; x++) > =A0=A0=A0 { > =A0=A0=A0 =A0=A0=A0 Delay100TCYx(26); > =A0=A0=A0 =A0=A0=A0 res++;=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // Dumm= y task > =A0=A0=A0 } > =A0=A0=A0 TRISC =3D 0b01010101;=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // '0's will= turn LED's on. > =A0=A0=A0 res++;=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // Dumm= y task > =A0=A0=A0 for (x=3D0; x<200; x++) > =A0=A0=A0 { > =A0=A0=A0 =A0=A0=A0 Delay100TCYx(25); > =A0=A0=A0 =A0=A0=A0 res++;=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // Dumm= y task > =A0=A0=A0 } > } > > > This is a fresh install of MPLAB 8.66 with C18 v3.46.=A0 I've disabled > all optimizations in the project's build options.=A0 What else should I > be checking, or is this a legitimate bug with the compiler/libraries? > FWIW, I also noticed that I could previously use "while (1)" for > infinite loops, but now the compiler hangs for several minutes, memory > usage climbs significantly, then just fails to compile. > > Cheers, > -Neil. > > > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=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 --=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 .