Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ATmega64. #417

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

melizasw
Copy link

Based on sim_mega128.c as the ATmega64 is essentially a smaller ATmega128. The few differences are show here: https://www.avrfreaks.net/sites/default/files/doc2539.pdf

@buserror
Copy link
Owner

buserror commented Apr 1, 2021

Could this had been done the same way as the other "series" instead of duplicating the whole file?

@melizasw
Copy link
Author

melizasw commented Dec 23, 2021

Do you mean that I should use files like sim_megax4.h, sim_megax8.h and sim_megax.h? If so, only sim_megax.h is viable as it is the only one with AVR_EEPROM_DECLARE_NOEEPM in it.

However, I can't get it to compile as it sees redefinitions in sim_megax.h for the following that are defined in avr/iom64.h:

#define EICRA MCUCR
#define EIMSK GICR
#define EIFR GIFR 

And if I force my way past that issue I get many other compile errors such as these (this is a small sample):

cores/sim_megax.h:88:35: error: ‘EE_RDY_vect’ undeclared here (not in a function); did you mean ‘EE_READY_vect’?
   88 |         AVR_EEPROM_DECLARE_NOEEPM(EE_RDY_vect),
      |                                   ^~~~~~~~~~~
sim/avr_eeprom.h:101:35: note: in definition of macro ‘AVR_EEPROM_DECLARE_NOEEPM’
  101 |                         .vector = _vector,\
      |                                   ^~~~~~~
In file included from cores/sim_megax.h:27,
                 from cores/sim_mega64.c:32:
cores/sim_megax.h:89:44: error: ‘SPM_RDY_vect’ undeclared here (not in a function); did you mean ‘SPM_READY_vect’?
   89 |         AVR_SELFPROG_DECLARE(SPMCR, SPMEN, SPM_RDY_vect),
      |                                            ^~~~~~~~~~~~
sim/avr_flash.h:71:35: note: in definition of macro ‘AVR_SELFPROG_DECLARE_INTERNAL’
   71 |                         .vector = _vector,\
      |                                   ^~~~~~~

So either it can't be done this way with the existing files or I don't know how to do it this way.

#include "sim_avr.h"

#define SIM_VECTOR_SIZE	4
#define SIM_MMCU		"atmega64"
#define SIM_CORENAME	mcu_mega64

#define _AVR_IO_H_
#define __ASSEMBLER__
#include "avr/iom64.h"
// instantiate the new core
#include "sim_megax.h"

static avr_t * make()
{
	return avr_core_allocate(&SIM_CORENAME.core, sizeof(struct mcu_t));
}

avr_kind_t mega64 = {
	.names = { "atmega64" },
	.make = make
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants