Tiny24 timer0 in normal mode problem

Go To Last Post
3 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've used the timer in other modes but wanted to just get a basic timer interrupt going using the timer in normal mode and use the overflow interrupt to do it but can't see the interrupt happening.

I used the sbi trick for a pulse on PB1 to show that it is running but do not see a pulse on PB0 in the interrupt routine.

No wgm bits set since this is normal mode and all I do is start the timer or am I missing something?

.include  "tn24def.inc"

.def	Temp	=r16
.def	Dely1	=r17
.def	Dely2	=r18

.org	0x0000
	rjmp	RESET

.org	0x000B			;Timer0 overflow vector
	rjmp	TIM0_OVF

	;ldi		Temp,high(RAMEND)  ;This causes an error on tiny24
	;out		SPH,Temp
	ldi		Temp,low(RAMEND)
	out		SPL,Temp

	ldi		temp,(1<<PB0|1<<PB1)		;Set PB0 & PB1 for output
	out		ddrb,temp

	;Timer0 in Normal mode(0) no need to set any WGM bits 

	ldi		Temp,(1<<CS02) ;Start timer0 with clk/256
	out		TCCR0B,Temp


	rcall	DELAY
	sbi		PINB,PB1	;toggle PB1 to show a system pulse
	rjmp	LOOP

	dec		Dely1
	brne	DELAY
	dec		Dely2
	brne	DELAY

TIM0_OVF:		; Timer0 overflow

	sbi		PINB,PB0	;toggle PB0 to show overflow of timer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


.org 0x000B

For general use and avoid hair-pulling, use the name of the vector from the chip include file for the offset.

But the #1 thing I'd like to see in your program is a bit set in TIMSK (or whatever it is called in the datasheet for your chip) setting the TOIE0 bit.


You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah it was the setting the timer overflow bit.

I didn't know about using