Timer1 Compare A Handler not working

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

Hello,

I have a problem with the timer interrupt. I made a very easy interrupt (I thought). It is almost simlair to a interrupt that I use in the atttiny24A, with some changes like sts instead of out.

Now I use the atmega328.

The meaning of this small program now is that the interrupt happens every 8msec and during that interrupt a pin (PD0) is set high and around 4msec later the pin (PD0) is set low.
So the conclusion is that there will be a square wave of around 4msec high and 4msec low on pin PD0.

But this is not happening I only see a line to zero.

I tied AVcc to Vcc and put Aref with 100nF to GND.
I included the Main file PT544.asm and the interrupt1.asm.

Maybe one of you can help me to find out what I'm doing wrong.
I looked over the datasheet for almost a week now and I start to lose it :cry:

Thanks for the help,
Patrick

Attachment(s): 

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

The Atmega328 has 2-word vectors. So either use jmp instead of rjmp, or put a nop behind each rjmp in the vector table.

Stefan Ernst

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

Thank you so so so very much stefan,

You made my entire weekend good :D :D

thanks, Patrick

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

Quote:

The Atmega328 has 2-word vectors. So either use jmp instead of rjmp, or put a nop behind each rjmp in the vector table.

Or .org at each vector address in which case it doesn't matter if you use JMP, RJMP and whether you need padding or not.