Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Help me fix my program to get a .0025s delay

Status
Not open for further replies.

rebiyarasheed

Newbie level 2
Joined
Oct 12, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
india
Activity points
1,297
I am new to this site.I am doing a project on multilevel inverters based on a new topology.A particular switching pattern is expected here and i need 5 pulses.I want my delay in .0025s.But after writing my program i could get only .000025s delay.Can anyone help me in what is wrong with my program.

LIST P=16F877A
#INCLUDE<P16F877A.INC>
ORG H'00
GOTO START
ORG H'50
START:
BSF STATUS,RP0
MOVLW H'00
MOVWF TRISB
BCF STATUS,RP0
MOVLW H'18
MOVWF PORTB
CALL DELAY
MOVLW H'03
MOVWF PORTB
CALL DELAY
MOVLW H'12
MOVWF PORTB
CALL DELAY
MOVLW H'03
MOVWF PORTB
CALL DELAY
MOVLW H'06
MOVWF PORTB
CALL DELAY
MOVLW H'09
MOVWF PORTB
CALL DELAY
MOVLW H'0C
MOVWF PORTB
CALL DELAY
MOVLW H'09
MOVWF PORTB
CALL DELAY
GOTO START
ORG120H

DELAY BSF INTCON,GIE
BCF PIR1,TMR1IF
BSF PIE1,TMR1IE
MOVLW H'D8
MOVWF TMR1H
MOVLW H'EF
MOVWF TMR1L
MOVLW B'00001001
MOVWF T1CON
LOOP BTFSS PIR1,TMR1IF
GOTO LOOP
RETURN
END
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
Re: delay

Hi,

You do not say what frequency your chip is running at.

Just tested your delay loop at 4mhz and Sim returns 15us.

You can alter your TMR1 preload values to give a longer time.
You can also use the prescaler to increase the time.

If you use Tmr0 the prescale divider is much larger so longer delays are easier.

Alternativley you can use this popular way to create accurate delays - but it is not interrupt controlled.
http://www.piclist.com/cgi-bin/delay.exe
 

rebiyarasheed

Newbie level 2
Joined
Oct 12, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
india
Activity points
1,297
Re: delay

My oscillator frequency is 4Mhz.And 5 pulses that i want have differant frequencies.I know assembly language only.And the operating frequency for multilevel inverter is 50hz.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top