Below are steps to run AVR program on AtmelStudio simulator and log register values.
main.cpp
#include <avr/io.h> // For DDRB, PORTB, PORTB5. #include <avr/sfr_defs.h> // For _BV(). int main(void) { // Set pin PB5 as output. DDRB |= _BV(DDB5); while (true) { // Drive pin PB5 high. PORTB |= _BV(PORTB5); // Drive pin PB5 low. PORTB &= ~(_BV(PORTB5)); } }
test.stimuli
// Log DDRB and PORTB registers $log DDRB $log PORTB // Save result in "output.sim" $startlog output.stim // Log for 20 clock cycles #20 $stoplog $break
Results are appended to the end of existing file. If register values do not change, nothing will be added to the file. Only changes are recorded.
output.stim
#1 DDRB = 0x20 #1 PORTB = 0x20 #2 PORTB = 0x00 #4 PORTB = 0x20 #2 PORTB = 0x00 #4 PORTB = 0x20 #2 PORTB = 0x00
After 1 cycle, DDRB
changed to 0x20
.
Then, after another 1 cycle, PORTB
changed to 0x20
.
2 cycles afterwards, PORTB
changed to 0x00
.
... and so on.