Opened 10 months ago

Closed 10 months ago

Last modified 6 weeks ago

#19 closed task (fixed)

ATMEGA328/328P: Configure by setting fuse bytes and lock bits

Reported by: dsl Owned by: Pawel
Priority: major Milestone: MCUSim-0.2
Component: avr Keywords: planned-in-0.2.0
Cc:

Description (last modified by dsl)

It's necessary to take into account any simulation-significant changes which can be made by setting fuse bytes and lock bits, i.e. size of the bootloader section, top border of the clock frequency, restrictions for the LPM and SPM instructions and so on.

The whole idea is to declare two functions in simm328p.h

int MSIM_M328PSetFuse(void *mcu, unsigned int fuse_n, unsigned char fuse_v);
int MSIM_M328PSetLock(void *mcu, unsigned char lock_v);

and let initialization mechanism know that these functions are available. You may achieve it by defining macros with function names:

#define SET_FUSE_F	MSIM_M328PSetFuse
#define SET_LOCK_F	MSIM_M328PSetLock

in the header file.

These function should also be implemented in simm328p.c. There are similar functions MSIM_M8ASetFuse and MSIM_M8ASetLock for ATmega8A.


I've attached a datasheet for ATmega328/328P to the ticket also. You may read its 28.1 Program And Data Memory Lock Bits and 28.2 Fuse Bits (please, pay attention to the ATmega328/328P only, like Fuse High Byte for ATmega328/328P) to understand what modifications should be done in struct MSIM_AVR instance according to the fuse and lock bytes values provided.

Attachments (2)

Atmel-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P.pdf (31.3 MB) - added by dsl 10 months ago.
Datasheet for ATmega328 and ATmega328P
0001-Atmega32p-Add-1-functions-to-set-fuse-and-lock-bytes.patch (4.9 KB) - added by Pawel 10 months ago.

Download all attachments as: .zip

Change History (18)

comment:1 Changed 10 months ago by dsl

Description: modified (diff)

Changed 10 months ago by dsl

Datasheet for ATmega328 and ATmega328P

comment:2 Changed 10 months ago by dsl

Pawel, feel free to switch milestone to "Work in Progress" when you start working on the ticket. We'll be able to move it back to 0.2.0 when it'll be ready. I usually try to keep initial milestone in keywords writing something like planned-in-X.X.X.

comment:3 Changed 10 months ago by Pawel

Milestone: 0.2.0Work in Progress

you can check progress on my fork of the repository
https://github.com/paweo90/mcusim

comment:4 Changed 10 months ago by dsl

Hm, nice! :) Progress is here!
I'll take a closer look tomorrow.

Last edited 10 months ago by dsl (previous) (diff)

comment:5 Changed 10 months ago by dsl

There is a pull request discussion on github also: https://github.com/dsalychev/mcusim/pull/10.

Last edited 10 months ago by dsl (previous) (diff)

comment:6 Changed 10 months ago by Pawel

I've attached the file :)

comment:7 Changed 10 months ago by Pawel

Milestone: Work in ProgressPatches Welcome

comment:8 in reply to:  6 Changed 10 months ago by dsl

Replying to Pawel:

I've attached the file :)

I'll definitely have to configure mail server to send/receive notifications from our Trac! Patch looks good. However, there are no adjustments according to my comment on github.

Sharing changes process isn't clear at the moment, as you can see, and it probably confused you. Anyway, code looks good enough and I'll apply this patch and make required changes myself. Moreover, I'm going to update Contributing Guide and ask you to read it and provide your opinion. Everyone would benefit from clearly written guide, I guess.

comment:9 Changed 10 months ago by dsl

Patch applied in 0.1.69. Good job, Pawel!

comment:10 Changed 10 months ago by dsl

Resolution: fixed
Status: assignedclosed

comment:11 Changed 10 months ago by dsl

Milestone: Patches Welcome0.2.0

comment:12 Changed 5 months ago by dsl

Milestone: 0.2.00.2

Milestone renamed

comment:13 Changed 5 months ago by dsl

Milestone: 0.2MCUSim-0.2

Milestone renamed

comment:14 Changed 3 months ago by dsl

Milestone: MCUSim-0.2MCUSim 0.2

Milestone renamed

comment:15 Changed 3 months ago by dsl

Milestone: MCUSim 0.2mcusim 0.2

Milestone renamed

comment:16 Changed 6 weeks ago by dsl

Milestone: mcusim 0.2MCUSim-0.2

Milestone renamed

Note: See TracTickets for help on using tickets.