Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Compare Output Mode problem

2005-03-23 by rlrsmith

Having a problem with the Compare Output functions in Timer1 on an 
ATMega32.
Have simulated the code under AVRStudio with various combinations of 
the top 4 bits of the TCCR1A register - the code only appears to 
affect the PIND register rather than the PORTD register.  I can't 
spot the deliberate mistake - can anyone else help?

Thanks,

Richard Smith
rlrsmith@yahoo.co.uk

Code listing below:

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>

INTERRUPT(SIG_OUTPUT_COMPARE1A)
{
}

INTERRUPT(SIG_OUTPUT_COMPARE1B)
{
}

int main(void)
{
	DDRD=0xFF;
	PORTD = 0xFF;
	
	//Reset counter
	TCNT1 = 0;

	//Initiate timers
	TCCR1A = 0b10101100;	//See pg.105
	TCCR1B = 0b00000000;	//See pg.105

	//Clear output compare interrupt flags
	TIFR = (_BV(OCF1A)|_BV(OCF1B));	//See pg. 111
	
	//Enable output compare interrupts
	TIMSK = (_BV(OCIE1A)|_BV(OCIE1B));	//See pg. 110
	
	OCR1A = 0x00FF;
	OCR1B = 0x000F;
	
	// Start timer
	TCCR1B |= 0b00000010;
	
	sei();
	for(;;);
}

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.