AVR tiny simulator - Page 1
Forum section: electronics / general

author: free_electron
author_rank: Super Contributor
timestamp: September 10, 2025, 02:41:50 am
content: I am looking for a toolchain that can simulate an AVR Tiny core based processor ( 4809)I want to see LIVE I/O updates. Meaning every pin needs to have a virtual LED that updates as the program runs. The program does not need to run realtime of course. it i want to see the i/o change.It also needs ot be able to simulate interrupts. if an pin is programmed to react to a falling edge , the interrupt handler should fire when i click the pin button low.I also need a virtual uart terminal. If a uart is configured i need a console window to it where i can see what is being sent.Needs to be able to read standard OBJ files from GCC and trace sourcecode

author: firewalker
author_rank: Super Contributor
timestamp: September 10, 2025, 11:59:18 am
content: I believe the best thing out there is Proteus.https://www.labcenter.com/https://www.labcenter.com/buy-vsm/https://www.labcenter.com/documents/?315Alexander.

author: wraper
author_rank: Unknown
timestamp: September 10, 2025, 12:09:55 pm
content: I would not bother with Proteus AVR emulation, unless you want to debug its bugs. In the past I had experience when certain math operation in firmware did not math properly (worked fine in real HW) and several other peripheral issues as well. Overall, it was a counterproductive waste of time.

author: firewalker
author_rank: Super Contributor
timestamp: September 10, 2025, 12:26:48 pm
content: Tbh every time I had to user proteus VSM it was OK. I don;t know ifhttps://wokwi.comis suitable for AVR tiny.Alexander.

author: squadchannel
author_rank: Frequent Contributor
timestamp: September 10, 2025, 12:53:42 pm
content: By the way, the At *mega* 4809 Curiosity nano board(DM320115) is only $9.99($10.19 indigikey). I wonder what the reason is not to buy it.I think the REAL hardware is better than an emulator, but I've never used an emulator myself, so I can't really say.EDIT:https://www.eevblog.com/forum/microcontrollers/processors-with-factory-programmed-bootloaders-over-uart/msg6036143/#msg6036143from this?I think AVR C is very easy to understand. (and can learn far more than with Arduino. also serves as a stepping stone to 32-bit MCUs.)haven't used many other microcontrollers, but with AVR, can enable multiple IPs connected to a single pin simultaneously.(at least in recent AVR cores)can set up a glue logic in CCL and connect the output pins directly to SDA. just enable the CCL output while keep the pin mode set to input.There are all sorts of ways to use it.but USART half-duplex mode can't be used properly, it overwrites the pin mode.interrupt? just enable interrupts for each IP and then call sei();. receive the interrupt, it jumps to the ISR( vector ){};. That's all.I never had any trouble with pin mode. maybe because I'm working with real hardware? I have a few modern(416, 4809, 3217, DA) AVR development boards because they're cheap.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 10, 2025, 01:00:09 pm
content: Quote from: free_electron on September 10, 2025, 02:41:50 amWhat about the one in the oldMicrochip Studio?Use standard GNU toolchains, and only the simulator?Never used it myself, though.

author: free_electron
author_rank: Super Contributor
timestamp: September 10, 2025, 09:32:35 pm
content: the reason for a simulator is that i want to be able to take a look at what bits are being flipped in internal registers.I tried configuring the device using atmels START but that generates a metric ton of C code that runs every time at startup and takes up rom space ( and boot time)the simulator will let me peek in the configuration registers so i can replace all that stuff with a few line of direct register loading.Many of these toolchain rely on huge libraries with lots of calls at startup .Silicon labs hat a config tool for the 8051Fxx series where you clicked the features you want and it would show you directly what registers got what bits flipped. there was no runtime code other than a few MOV instructions directly into the processor registers.everything these days is hidden under layers upon layers of code.i miss the days of true hardware emulators with bond-out chips where you could actually see and modify everything at runtime.

author: langwadt
author_rank: Super Contributor
timestamp: September 10, 2025, 09:45:12 pm
content: Quote from: free_electron on September 10, 2025, 09:32:35 pmhttps://www.digikey.dk/en/products/detail/microchip-technology/PG164100/9562532

author: westfw
author_rank: Super Contributor
timestamp: September 11, 2025, 12:41:00 am
content: QuoteYou should probably note that a 4809 is NOT an "AVR Tiny" core. It's part of the "MegaAVR 0-series." (officially known as "AVRxt" apparently. Which IS the same designation as the "new" Tiny-0/1/2 chips.)QuoteThat seems a backwards way of doing things. Why not just read the datasheet?

author: squadchannel
author_rank: Frequent Contributor
timestamp: September 11, 2025, 01:19:23 am
content: Quote from: free_electron on September 10, 2025, 09:32:35 pmUsing the UPDI connection, it can executed on REAL hardware.Quote from: free_electron on September 10, 2025, 09:32:35 pmthis is AVR. not CubeIDE.only includes io.h. just 190 bytes.did you generate the project using Atmel Start? like CubeIDE, it consumes a lot of program memory.Quote from: free_electron on September 10, 2025, 09:32:35 pmjust buy a Curiosity Nano board from DigiKey for $10.19, connect it via USB, write program in Microchip Studio, and debug it.can use USART, IO View, real io pins, and there's no weird behavior.No need to buy expensive emulators or incomplete simulators.Quote from: squadchannel on September 10, 2025, 12:53:42 pmI don't know if it works in BASIC.

author: mtwieg
author_rank: Frequent Contributor
timestamp: September 16, 2025, 12:47:04 pm
content: I recall back in school, AVR studio 4.xx could simulate nearly every AVR part in the way you described. Looks like the 4908 was released ~2018, did they stop providing simulator support for new parts? Or does the current successor to AVR studio just not support simulation period?Anyways, I also think debugging actual hardware is preferable. You should be able to see every register the simulator would show you, maybe more.

author: gjl
author_rank: Newbie
timestamp: September 21, 2025, 08:09:32 pm
content: Quote from: free_electron on September 10, 2025, 09:32:35 pmSo you want to simulate some code, then reverse-engineer what hardware setup s needed, and use that to program the device.Sounds terribly complicated, error prone and driven by avoiding writing working code from the start.What about reading the manual, and from there engineer proper code?

author: free_electron
author_rank: Super Contributor
timestamp: September 21, 2025, 10:51:09 pm
content: Quote from: gjl on September 21, 2025, 08:09:32 pmNo , i want to set up the peripherals using the graphical configuration tool from Atmel. The configuration tool creates a bunch of startup code in C. I want to see the result after that code has run. What registers have they modified and what are the content. some things are easy to configure using the GUI but require multiple registers to be modified. It pre-empts mistakes in the register configuration.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: September 22, 2025, 05:58:34 am
content: Quote from: free_electron on September 10, 2025, 02:41:50 amMy understanding was that Atmel tools were able to simulate any AVR member, via a compiled simulator engine derived from the chip gate level source code.Is that no longer the case ?Did microchip discard or lose that nice capability along the way ?

author: Zoli
author_rank: Frequent Contributor
timestamp: September 22, 2025, 06:15:32 am
content: Attached is a screenshot of the IO view in Microchip Studio 7.0.2594(current) for ATTiny10.

author: westfw
author_rank: Super Contributor
timestamp: September 22, 2025, 07:06:25 am
content: QuoteThis is not what you said originally:QuoteQuoteAFAIK, they can simulate a 4809 just fine, and might be OK for checking those register contents, but I don't think they do much in the way of the "live GUI interface", and "stimulous files" were a pain."Of course", "Studio" is deprecated and you're supposed to move to "MPLABX." I haven't tried to use the MPLABX simulator; a quick test looks pretty grim :-( (No VPORT SFRs, no PORTB, sorting by address ... doesn't...)Also, I don't think either simulator is set up to handle the new structure-style IO definitions very well (or at all)

author: RoGeorge
author_rank: Super Contributor
timestamp: September 22, 2025, 07:30:47 am
content: Quote from: free_electron on September 10, 2025, 09:32:35 pmATtiny has one wire debugging (a hardware capability), so you can look inside the real hardware if you want to. That can be interfaced with GDB (AVR-GCC and AVR-GDB under the hood), but it can be used from the Eclipse GUI, for example:Printscreen fromhttps://www.eevblog.com/forum/microcontrollers/avr-(arduino)-linux-debug/msg3511900/#msg3511900The setup was not trivial, but all the pieces of software used there are free and open source. I did once that setup, and in the end you get a true (hardware) debugger, not a software stub debugger (ATtiny won't have enough memory for a stub debugger). A hardware debugger consumes no memory, it makes use of the debugging features already implemented in the chip's hardware.Once you get the setup working, you will have the whole set of features of a proper hardware debugger: step by step execution capability, breakpoints, I/Os, registry and memory inspection and/or modification during execution, stack trace, both a C and assembler view for sources, etc.Not all AVR chips have one wire debugger capability, but ATtiny has it (I've tested that on an ATtiny13). Recent ATmega series (for example the ATmega328 used in the typical Arduino boards) also have the one wire debugger feature, just that the Arduino boards doesn't take advantage of it.

author: free_electron
author_rank: Super Contributor
timestamp: September 22, 2025, 05:37:56 pm
content: Quote from: westfw on September 22, 2025, 07:06:25 ami gave up on that idea. The compiler i use has enough simulation capability ( like an LCD display and the i/o pins) but it can't handle interrupts. I got the interrupt code working. It's very minimal and was fairly easy to get goingThe big thing is (was) the configuration of some of the more complex blocks like the timer/compare blocks that have various settings for prescalers and clock sources.Silicon labs had a nice config tool for their F-series processors where you had a GUI and could click the options and set the numbers you wanted. It produced direct machine or C code that performed SFR writes without requiring library of functions like in Arduino or STM ecosystem. That code is invariably a ton of calls to a library.The silabs GUI did all the lifting and just told you : based on what you selected in the GUI : set these 9 registers with the following values. The startup code was essentially a number of mov operations. No bit twiddling happened at runtime. It was pre-calculated in the GUI.I can figure it out from the datasheet but if there is a nice tool to make life easier ( and crosscheck what i figured out) those things are welcome. Atmel had STARThttps://start.atmel.com/But it banks on some "middleware" and now there is MCC . START let's you configure the pinmux and set up some elements like the clock domain for the ADC.But the generated code is unreadable. It is scattered in like 20 files and they predefine a bunch of inline functions fore each possible bit and then call those. At compile time the compiler + optimizer processes those and squashes it to a single register write. They essentially let the compiler do the lifting as opposed to the GUI.That's why i wanted a simulator to see what the compiler had ultimately produced in terms of register writes. That is all i needed. I don't use C so i need to implement the register operations in my toolchain.Compile the produced code and run it ( just the system_init. Then halt and inspect the register contents.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: September 22, 2025, 06:19:09 pm
content: Maybe out of context and not very helpful, but commercial simulators like Lauterbach Trace32 just simulate the core ("instruction set simulator"). If you write to or read from peripherals, this is just like writing to and reading from a (virtual) RAM. There is no trap handling, there are no interrupts, even the FPU behavior is not the same.I guess, at least at a certain level, the complexity of simulating complex microcontrollers with all their peripherals is just too much effort for all the possible hardware variants.