Teja.p
Member level 2
- Joined
- May 29, 2016
- Messages
- 44
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 1,728
here is my code please help meee
i am using pic12f675 with20Mhz clock and
i want to generate 5us delay ..
i calculate by using formula
Pic input frequency= Fosc / 4= 20 Mhz / 4 = 5 Mhz
Prescaler = 1:4
Tick Counter frequency = Prescaler/5 Mhz = 4 / 5 Mhz = 0.8 u s
Delay required =5us
Delay required = Timer Count * Tick Counter frequency
by using this formula timer count is 249
please help mee ..
i am using pic12f675 with20Mhz clock and
i want to generate 5us delay ..
i calculate by using formula
Pic input frequency= Fosc / 4= 20 Mhz / 4 = 5 Mhz
Prescaler = 1:4
Tick Counter frequency = Prescaler/5 Mhz = 4 / 5 Mhz = 0.8 u s
Delay required =5us
Delay required = Timer Count * Tick Counter frequency
by using this formula timer count is 249
please help mee ..
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 35 36 37 38 39 40 41 42 #define IP GP0_bit #define OP1 GP1_bit #define OP2 GP2_bit void delay(); void main() { unsigned int count=0; /*GPIO=0X00; TRISIO=0X00; /// WPU=0x00; ANSEL = 0; CMCON = 7; */ ANSEL = 0x00; // Set ports as digital I/O, not analog input ADCON0 = 0x00; // Shut off the A/D Converter CMCON = 0x07; // Shut off the Comparator VRCON = 0x00; // Shut off the Voltage Reference TRISIO=0X01;///GP0 and GP1 are the inputs and GP2 and GP4is the output GPIO = 0x00; // Make all pins 0 OPTION_REG=0X41; TMR0=0X00; while(1) { OP1=1; delay(); OP1=0; delay(); } } void delay() { TMR0=249; T0IF_bit = 0; // Clear interrupt bit T0IE_bit= 1; // Enable Timer1 interrupt PEIE_bit= 1; // Enable peripheral interrupts GIE_bit= 1; // Enable global interrupt if(T0IF_bit==1) //If Timer1 Interrupt { T0IF_bit= 0; // clear the interrupt } }
Last edited by a moderator: