Issac, Yep, I did that after looking it up. Long Int is much better. It=20 allows numbers from -2.x billion to 2.x billion. I think that is big enough= .. Thanks, rich! On 10/25/2015 6:10 AM, Isaac Marino Bavaresco wrote: > Richard, > > Use a 'long' instead of a 'double'. > The 'double' is a floating-point variable that requires a lot of library > code to be linked for it to work, and can give you even more strange bugs= .. > > Cheers, > > Isaac > > > Em 25/10/2015 07:16, Richard R. Pope escreveu: >> Nic, >> I have 10 second delays between each of the calls to send data to >> the LCD. I'm able to count this and right now it is only 2 to 3 seconds. >> The compiler didn't catch this overflow. I'll have to use a larger >> 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 routi= nes >>>> 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 = 250 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). >>> >>> --=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 .