Tiny2313 and TIMSK on a simulator

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

I've wrote following code:

      ldi r17, 1 << OCIE1A | 1 << OCIE0A ;got 0x41 in r17
      out TIMSK, r17  ;got 0x21 !!! in TIMSK
      in  r17, TIMSK  ; again 0x41 in r17

Value 0x21 I view in debugger, and timer1 behaves like there is actualy 0x21 in TIMSK register.

In Studio 4 with simulator 1 I've got 0x41 in TIMSK register, but with simulator 2 it behaves like in studio 5.

Is it a bug in simulator or there is mistake in my code?

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

Thank you for reporting this. There is nothing wrong with your code. This is a bug in the simulator model for ATtiny2313(A)/ATtiny4313 and will be fixed ASAP. For future reference this is bug #15217.

The program will simulate correctly but the I/O view presentation of OCIE1A and OCIE1B will be swapped in TIMSK, and TOIE1A <-> TOIE1B in TIFR.

- roland

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
      ldi r17, (1<<OCIE1A) | (1<<OCIE0A) ;got 0x41 in r17 

I would guess that your expression does actually work. After all, you have checked the Simulator behaviour.

I can never be bothered to look up the relevant operator precedences.

Simply using parentheses ensures that your expression is what you want.

David.

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

Quote:

I can never be bothered to look up the relevant operator precedences.

No need - it does load 0x41 into R17 as his comment says. As Roland confirms this is a bug in Sim2 (I checked 4.19 where it's also evident).

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

rkruse wrote:

The program will simulate correctly but the I/O view presentation of OCIE1A and OCIE1B will be swapped in TIMSK, and TOIE1A <-> TOIE1B in TIFR.

- roland

Thank you for your answer!
I'v wrote:

Quote:
timer1 behaves like there is actualy 0x21 in TIMSK register.

It was my mistake. You were right - timer behaves like there is 0x41 in TIMSK