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

Fix/e2prom swm #275

Merged
merged 2 commits into from
Jun 7, 2023
Merged

Fix/e2prom swm #275

merged 2 commits into from
Jun 7, 2023

Conversation

eimiz
Copy link
Contributor

@eimiz eimiz commented May 8, 2023

This should write the last 3 bytes in SWM mode correctly. Tested with BOARD_328P only.

@LaZsolt
Copy link
Collaborator

LaZsolt commented May 9, 2023

Good that you notice.
The solution also seems obvious.

@LaZsolt
Copy link
Collaborator

LaZsolt commented May 10, 2023

@eimiz , @SuperUserNameMan
I looked it up in the databook, and found that it does not need to be aligned when programming E2PROM.
kép

But when programming as FLASH:
kép

@LaZsolt
Copy link
Collaborator

LaZsolt commented May 10, 2023

But address must be aligned at 32 bit mode read:

kép

@eimiz
Copy link
Contributor Author

eimiz commented May 10, 2023

After some more experiments I see that address is auto aligned when SWM or 32bit mode is used.
I mean, reading/writing to addresses 13, 14 or 15 will actually read/write to 12.
The databook also seems to indicate that the last two bits of address are not used:
image

In my tests SWM write works fine with any address.
However SWM read will store wrong value in E2PD0 on last read (after SWM is off) if address is not aligned. That is, PD0 contains PD1 PD2 or PD3 depending on misalignment.
If SWM_off is moved outside loop, then PD0 is correct, but then a dummy read or P2CTL reset is needed before return.

@SuperUserNameMan
Copy link
Contributor

Yep you're right guys. The older 1.0.4.en datasheet also mention the 4 bytes alignement and the fact that EEAR[0:1] are ignored in 32 bits mode.

I can't find the datasheet I was using when i rewrote the EEPROM lib, but I now remember it was the most recent chinese version i found on weibo and that i personally translated it using google translate. I must have messed in this process.

Sorry for the confusion and the bugs guys.

@dbuezas
Copy link
Owner

dbuezas commented May 15, 2023

So should we merge and release?

@LaZsolt
Copy link
Collaborator

LaZsolt commented Jun 7, 2023

So should we merge and release?

Yes. It looks good and tested by @eimiz .

@dbuezas dbuezas merged commit d4a26e6 into dbuezas:master Jun 7, 2023
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

4 participants