Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] Timer 1 Troubles

2006-12-13 by Don AE5K

Evan,

I have not tried the tiny24, but on several other tiny new parts, there
is apparently a bug in the simulator with the timers and I've run into
similar strange problems.  If you dig deep enough in the online help for
the studio, there is a note in there about that as known problem.

Don

dr_bitbucket wrote:
> I'm writing some assembly code for an ATtiny24 for a new project.  I 
> need to use timer1 to PWM output PA5 (OC1B) (pin 8, I believe) at 
> close to 38 kHz and 50% PW, it's for an IR LED being sensed by an 
> IS1U60.  I am using timer0 for PWM motor control (which works just 
> fine), and I would prefer to use timer1 for this application as it 
> offers a phase and frequency correct PWM mode, and I think that's 
> snazzy.
> 
>  
> 
> The steps I have taken to initialize my timer1:
> 
>       My DDR for port A5 has been set to output in a previous 
> instruction.
> 
>       I begin by writing my TOP value to 16-bit registers OCR1AH and 
> OCR1AL, writing high-byte before low.
> 
>       I write to TCCR1A, disabling OC1A, enabling OC1B with code 
> 0b10, and setting Waveform Gen Mode bits 1 and 0 with code 0b01.
> 
>       I write to TCCR1B, setting Waveform Gen Mode bits 3 and 2 with 
> code 0b10 (which completes setting WGM to mode 9) and set my clock 
> prescaler bits CS1[2:0] to 0b001 for a prescale rate of CLK/1.  To 
> my understanding this is supposed to start the timer.
> 
>  
> 
> Here's the problem:
> 
> On the instruction cycle immediately following my write to TCCR1B, 
> Waveform Gen Mode bit 3 is cleared automatically.  This appears to 
> occur while flags OCF1A and OCF1B are simultaneously set, though I 
> am not sure if this is connected or relevant.  And the real kicker 
> is that the timer doesn't even appear to start:  TCNT1x registers 
> are not incrementing, just remaining clear.  Even if I test the 
> timer1 in a mode other than PFC-PWM, for example fastPWM, the timer 
> still refuses to start.  Has anyone seen this before (Craig???)?  It 
> feels like there is some kind of master control bit I have 
> neglected.  
> 
>  
> 
> I am using the AVRstudio simulator config'd for an ATtiny24.  Hoping 
> this is a simulator bug, though it'll be a bugger to debug if it is.
> 
> Thanks for any help you can provide,
> 
> Evan Haklar

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.