ATMega8535 Timer0 CTC - a confession and a quiz

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

With this relatively simple one-off ATMega8535 project I was overconfident and then spent the rest of the day hunting down Timer0 in CTC mode as a 1ms interrupt source not throwing the interrupts.

First of course I did not even realize that it's the Timer0, as much of the program (mostly bit-banging on a couple of port pins) did work, including UART communication (which, being interrupt-driven, indicated that interrupts do work in general). I fiddled around with blinking of the on-board two-colour LED, then looked at the pins with a logic analyzer, and then rewrote the code to use "magic constants" instead of the defines from the avr-libc header (in the unlikely chance that there's some error there) - no change. Then spent some quality time with AS4's simulator (v1, as v2 does not support '8535) just to find bugs in the simulator itself...

Finally turned to google to find a post directly here on avrfreaks, which pointed me to the real problem: the ATMega8535 had the AT90S8535 compatibility fuse on - and truly enough, the AT90S8535's Timer0 does not have CTC mode. To my defense, the ATMega8535's datasheet in the AT90S8535 Compatibility chapter does not care to mention this (thanks, Atmel! :-( ).

The reason for this is, that the target board had been originally designed for the AT90S8535 but manufactured long enough to see the ATMega8535 to be mounted instead. There is an on-board facility to reprogram the '8535 (and it's not a built-in bootloader, as the AT90S' did not permit that, but a second, smaller microcontroller); but the fuses can't be reprogrammed through that. So, instead of attempting to reprogram the fuses through some alternative method, I simply resorted to using Timer2 - which does have CTC mode also in the AT90S' - as the timing interrupt source.

Now the quiz: the board I mention is (was) quite ubiquitous among the AVR users a couple of years ago.. Anyone recognizing it from the above text?

JW

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

STK500 or AVRISP Mk1??

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

No, I don't recognise the board.

However, I will confess to forgetting that the 'earlier' AVRs were relatively stupid.

If you still have to support a 90S8535, you will just have to program for the lowest common denominator.

Quite honestly, if you don't need to support obsolete boards, I would just re-design for a ATmega164P which should be pin-compatible.

Otherwise, just use mega8535 in 90S8535 compatibility mode.

Incidentally, why can't your second MCU program fuses? As far as I know, the 90S8535 can use ISP or HVPP, both of which are capable of altering fuses.

David.

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

John is right - it's STK500. I don't know of AVRISPmkI which was populated by ATMega8535 (except of my own, but the ATMega there is consequence of me releasing the magic smoke out of the AT90... :-) ).

Of course, the firmware in ATTiny2313 (originally AT90S1200) used as the programmer there could be rewritten to support burning the fuses, but as I said above, the problem can be circumvented by using Timer2 instead of Timer0.

The project is a programmer for Microcontrollers Which Can Not Be Named here. The final "product" will be a standalone AVR-based device performing both the burning and a set of callibration steps; but for development the STK500 has all the facilities needed - a controllable VTARGET source, level converters on the ISP signals, and a logic-12V source, so I thought it might be a convenient platform for this project... Moreover, I felt I need to revenge this... ;-)

JW

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

Quote:
John is right
WOW I did dream I had won 1.1 million dollars in a guessing competition the other night, when do I get the money? :lol:

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Oh, yes, ehm, you know, my overdue membership fee to Slovakian Billionaire Microcontroller Designers Club is to be paid first, sorry... ;-)

JW