Nic, I have 10 second delays between each of the calls to send data to=20 the LCD. I'm able to count this and right now it is only 2 to 3 seconds.=20 The compiler didn't catch this overflow. I'll have to use a larger=20 variable such as a double. Thanks, rich! On 10/25/2015 5:09 AM, Nicola Perotto wrote: > Hi Rich, > > > On 25/10/2015 06:39, Richard R. Pope wrote: >> Hello everyone, >> Well I have it working reliably. Now I can't get my delay routines >> to work correctly. No matter what I try my delays do not change. > How you know this? How you measured the real delay? > >> Would >> someone look at my delay routines and see if they can spot what I am >> doing wrong? Here are the routines: >> >> extern void wait_us(unsigned int delay) >> { >> for(; delay; delay--) >> { >> NOP(); //This is about 500 nS at 1 MHz > Here one error: at 1 MHz of clock the instruction clock is ever 1/4 so 25= 0 kHz =3D > 4 microseconds. > You can find this explained in paragraph 5.2 of datasheet. > > >> //NOP(); //Now we have one uS at 1 MHz >> //NOP(); //This is about 500 nS at 1 MHz >> //NOP(); //Now we have one uS at 1 MHz >> //NOP(); //This is about 500 nS at 1 MHz >> //NOP(); //Now we have one uS at 1 MHz >> } >> } >> extern void wait_ms(unsigned int delay) > Here "unsigned int" is 16 bit =3D 0..65535 > >> { >> wait_us(delay * 1000); //This gives us 1 millisecond >> } >> >> extern void wait_seconds(unsigned int delay) >> { >> wait_ms(delay * 1000); //This is one second > No! This is an overflow error! 1000*1000 > 65535! > Check your compiler settings, this error can be catched at compile time > (maybe... no experience with XC8). > > >> } >> >> Thanks, >> rich! > :-) > Nic > * > * --=20 Richard R. Pope President Reedsburg Area Model Railroad Club, RAMRC 1230 19th Street #5 Reedsburg, WI 53959 608-768-7448 mechanic_2@charter.net --=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 .