It is not a "cheap" calculation, and having to do it for every cycle
would make the simulator slow down to a crawl. Same applies to the PWM
pin itself, it's /never/ toggled because we don't really care as it's
an output... that would involve massive overhead at each cycle for no
reason than having a pretty trace in VCD.
Thats why the value is calculated only when the AVR core reads it,
because that's the whole point. The simavr IRQ system for PWMs allows
you to make external "peripherals" that reacts to a certain PWM
frequency/duty cycles if you like, but not at the pin level...
Michael
I know that FPGA simulators allow you to do that, but it's because in
their case you /actualy/ make the silicon that does the PWM and so on,
and there is no interest nor possibility to run the simulation at
nowhere near real time speed. In /my/ case, I want to be able to write
an AVR firmware on my laptop that responds and drive "peripherals"
that I have re-coded as their "logical" level, not pin levels.
So in the case of the LedRamp example, the PWM would be passed as an
integer representing frequency and duty cycle, and the "peripheral"
would change the display brightness to simulate the real hardware,
without "blinking". Check the Timer example, it does just that...
Michael
Whats the previous discussion is about is where the simulator should
go down to simulating some of the AVR /external/ interfaces.
Michael
It's a pretty simple construct really. Each peripherals (and quite a
few other things) have use an "IRQ" to signal to whomever is
interested that something has changed... It is really just a
mono-directional signal, with one source and one or more destinations.
A destination can be either a C callback, or another IRQ in which case
the "signal" is passed on.
Each simavr IO module as a set of IRQs that are specific to that
peripheral, and "output" values of interests from that peripheral. It
can also have "input" IRQs that can be used to feed it information...
For example, if you look at the ADC module (sim/avr_adc.h), it has :
+ ADC0-7 as Input IRQs, these are used by a peripherals to pre-load
the "ADC" pre-multiplexer, so your "peripheral" can set the ADC0 to a
specific voltage for example...
+ TEMP for setting the temperature, if the AVR has that
+ OUT_TRIGGER is "signaled" when the AVR core starts a "conversion",
it allows your peripheral to calculate a value and send back a ADC0-7
to fill the pre-mux
+ IN_TRIGGER can be used by the peripheral to signal the AVR to start
a conversion automaticaly, the the regular AVR ADC can be triggered by
the timer etc.
these "IRQs" are used all over the place, every peripheral use them
and it is their standard way of communicating with "external" code...
Michael