simavr icon indicating copy to clipboard operation
simavr copied to clipboard

vcc, avcc are set improperly with AVR_MCU_VOLTAGES macro

Open djfd opened this issue 6 years ago • 0 comments

Hi,

I am setting the above mentioned voltages like this:

AVR_MCU_STRING(AVR_MMCU_TAG_NAME, "attiny24");
AVR_MCU_VOLTAGES(2700, 2700, 1100); // VCC, AVCC, VREF

however at the ADC ops I am getting strange output, like this

ADC: Start AREF 1100 AVCC 33884812

Then I added a couple of lines to my simulator to see these voltages right after firmware loading:

printf ("VCC: %d mV, AVCC: %d mV, AREF: %d mV\n", avr->vcc, avr->avcc, avr->aref);

which gives

VCC: 33819276 mV, AVCC: 33884812 mV, AREF: 1100 mV

There is the dump of .mmcu section:

$ avr-readelf -x .mmcu firmware.elf

Hex dump of section '.mmcu':
  0x00000304 01406174 74696e79 32340000 00000000 .@attiny24......
  0x00000314 00000000 00000000 00000000 00000000 ................
  0x00000324 00000000 00000000 00000000 00000000 ................
  0x00000334 00000000 00000000 00000000 00000000 ................
  0x00000344 00000302 8c0a0402 8c0a0502 4c04     ............L.

Thanks

djfd avatar Apr 14 '19 22:04 djfd