basically i want to measure the i/p frequency and wanted to produce same frequency at oc1a/oc1b,i do this several times but nothing positive o/p i got!!
the logic for it is that-first i capture the i/p freq. by configuring tccr1a,tccr1b register's, after doing this i stop capturing and again configure the tccr1a,tccr1b and produce squre wave at oc1a pin,but still i didn't get desired o/p,so wht i do plz give me some suggestion's,i post my sample(rescent) code here,plz reply me
Rich (BB code):
PROGRAMME:-
.INCLUDE "M16DEF.INC"
.DEF R_E=R18
.DEF L_E=R21
.MACRO INITSTACK
LDI R16,HIGH(RAMEND)
OUT SPH,R16
LDI R16,LOW(RAMEND)
OUT SPL,R16
.ENDMACRO
;=====================
GAME:
CBI DDRD,6 ;pd6 initialise as a i/p pin for i/p capture
SBI PORTD,6
SBI DDRD,5 ;pd5 initialise as a o/p pin for wave generation
RJMP MAIN
;=====================
MAIN:
INITSTACK
LDI R20,$00
OUT TCCR1A,R20
LDI R20,$41 ;i/p capture for rising edge signal
OUT TCCR1B,R20
F1:
IN R19,TIFR ;here first i captur i/p signal at rising edge
SBRS R19,ICF1
RJMP F1
IN L_E,ICR1L
IN R_E,ICR1H
OUT TIFR,R19
LDI R20,$01
OUT TCCR1B,R20
F2:IN R19,TIFR ;here first i captur i/p signal at falling edge
SBRS R19,ICF1
RJMP F2
IN R22,ICR1L ;then i got the pulse width
SUB R22,L_E
OUT OCR1AL,R22
IN R22,ICR1H
SBC R22,R_E
OUT OCR1AH,R22
RJMP WA_VE
;===================
WA_VE:
;this programme is use to generate wave at oc1a pin of atmega 16
LDI R16,$41
OUT TCCR1A,R16
LDI R16,$09
OUT TCCR1B,R16
HERE:RJMP HERE
;========================
;=======================
Last edited by a moderator: