Question: . include m 1 2 8 def.inc . equ F _ CPU = 1 6 0 0 0 0 0 0 . equ PRESCALER

.include "m128def.inc"
.equ F_CPU =16000000
.equ PRESCALER =1024
.equ COMPARE_MATCH =(F_CPU /(2* PRESCALER *1))-1 ; 0.5 seconds period
init:
sbi DDRB, DDB6 ; Set Port B Pin 6 as output
cbi DDRC, DDC6 ; Set Port C Pin 6 as input
ldi r16,0xFF
out DDRD, r16 ; Set Port D as output
ldi r16,(1<< WGM32) ; Configure Timer 3 in CTC mode
out TCCR3A, r16 ; Set WGM32 in TCCR3A
ldi r16,(1<< CS32)|(1<< CS30) ; Start Timer 3 with prescaler 1024
out TCCR3B, r16
ldi r16, low(COMPARE_MATCH)
out OCR3AH, r16 ; Set compare match low byte
ldi r16, high(COMPARE_MATCH)
out OCR3AL, r16 ; Set compare match high byte
ldi r16,(1<< OCIE3A) ; Enable Timer 3 compare match interrupt
out TIMSK, r16
sei ; Enable global interrupts
main_loop:
sbic PINC, PINC6 ; Check if Port C Pin 6 is HIGH
rjmp clear_port_d
rjmp main_loop
clear_port_d:
ldi r16,0x00
out PORTD, r16 ; Clear Port D
rjmp main_loop
; Timer 3 compare match interrupt service routine
ISR(TIMER3_COMPA_vect):
sbi PINB, PINB6 ; Toggle Port B Pin 6
reti
In line 39, syntax error, unexpected and ISR: Unknown instruction or macro errors occurs. Can you fix them?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!