bimalkamal
Member level 1
Please anyone tell me how many times in a minute the LEds of PORTB will blink? Or the delay time the mydelay() will create.
---------- Post added at 00:21 ---------- Previous post was at 00:16 ----------
Crystal=20Mhz
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 void mydelay(); void main() { OPTION_REG = 0x87; // Assign prescaler to TMR0 TRISB = 0; // PORTB is output PORTB = 0xFF; // Initialize PORTB TMR0 = 0; // Timer0 initial value while(1) { PORTB = ~PORTB; mydelay(); } } void mydelay() { unsigned int n=0; INTCON.TMR0IE=1; do{ while(!INTCON.TMR0IF); n++; if(n==76) { TMR0IE_bit=0; n=0; INTCON.TMR0IF=0; break; } }while(1); }
---------- Post added at 00:21 ---------- Previous post was at 00:16 ----------
Crystal=20Mhz