Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
PORT_ON(PORTD, 6);for (i=1000; i>0 ; i--);FLIP_PORT(PORTD, 6);for (i=100; i>0 ; i--);
PORT_ON(PORTD, 6);for (i=1000; i>0 ; i--);for (i=1000; i>0 ; i--);for (i=1000; i>0 ; i--);for (i=1000; i>0 ; i--);FLIP_PORT(PORTD, 6);for (i=100; i>0 ; i--);
PORT_ON(PORTD, 6);for (i=15000; i>0 ; i--);FLIP_PORT(PORTD, 6);for (i=130; i>0 ; i--);
void delay_us(unsigned long int time_us) { int i; long int j=time_us; for(i=1;i>0;i--) { while(j>=0) j--; j=time_us; } }//and in main i have:PORT_ON(PORTD, 6);delay_us(1000);FLIP_PORT(PORTD, 6);delay_us(100);
void delay_us(unsigned long int time_us) { int i; long int j=time_us; //for(i=1;i>0;i--) //{ while(j>=0) j--; j=time_us; //} }//and in main i have:PORT_ON(PORTD, 6);delay_us(1000);FLIP_PORT(PORTD, 6);delay_us(100);
void delay_us(unsigned short time_us) { unsigned short delay_loops; register unsigned short i; delay_loops = (time_us+3)/5*CYCLES_PER_US; // +3 for rounding up (dirty) // one loop takes 5 cpu cycles for (i=0; i < delay_loops; i++) {};}//in main i call:PORT_ON(PORTD, 6);delay_us(100);FLIP_PORT(PORTD, 6);delay_us(10);
void delay_us(unsigned long int time_us) { int i; unsigned long int j=time_us; for(i=1;i>0;i--) { while(j>=0) j--; j=time_us; } }
void delay_us(unsigned long int time_us) { int i; long int j=time_us; for(i=1;i>0;i--) { while(j>=0) j--; j=time_us; } }
Don't know why I did't think of that
would it make sense to have an optimization level that understands and therefore allows looping waits?
-floop-optimize Perform loop optimizations: move constant expressions out of loops, simplify exit test conditions and optionally do strength-reduction and loop unrolling as well. Enabled at levels -O, -O2, -O3, -Os.
-O turns on the following optimization flags:-fdefer-pop -fmerge-constants -fthread-jumps -floop-optimize -fif-conversion -fif-conversion2 -fdelayed-branch -fguess-branch-probability -fcprop-registers