Yahoo Groups archive

AVR-Chat

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

Message

RE: [AVR-Chat] Help setting OC1A,B HI on ATMega644p, please. FOUND a way, but is it the best?

2009-10-06 by Cat C

To answer my own question, I found a way, but is it the best/easiest?

TCCR1A = 0b11110000;    //Prepare so that next command sets OC1A/B HI (set on Output Compare)
TCCR1C = 0b11000000;    //Strobe - Forces an Output Compare for a/b so line above makes them HI


> To: avr-chat@yahoogroups.com
> From: catalin_cluj@hotmail.com
> Date: Tue, 6 Oct 2009 13:39:59 -0600
> Subject: [AVR-Chat] Help setting OC1A,B HI on ATMega644p, please.
> 
> 
> Hello,
> 
> I need to generate a pulse of some length and plan to use Timer 1 on a ATMega644p in normal mode (0).
> 
> So I set 
> 
>  TCCR1A = 0b10100000; //This sets PD5/4 do be OC1A/B, to be cleared on Compare-Match
> //                ||||||||
> //                ||||||--WGM11, WGM10 (00) Normal Mode. Also set WGM13:2 in TCCRnB to 00
> //                ||||--   Reserved, must be 0
> //                ||--    COM1B1, COM1B0: 10 = Clear OC1B on Compare Match. Set at Pulse Start
> //                --       COM1A1, COM1A0: 10 = Clear OC1A on Compare Match. Set at Pulse Start
> 
>     PORTD |= _BV(PD4) | _BV(PD5);    //OC1B, OC1A as  outputs 
> 
> The plan is to set OC1A/B (PD5/4) High before I start the timer and have the timer clear them on Compare Match.
> 
> My problem is: How do I set OC1A/B to High, as they no longer "respond" to commands sent to Port D?
> I tried:
> PORTD |= _BV(PD4) | _BV(PD5); to no avail.
> 
> Any help appreciated, thanks.
> 
> Cat

 		 	   		  

[Non-text portions of this message have been removed]

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.