[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] Use of LPM (memcpy_P) on Xmega
From: |
Ruud Vlaming |
Subject: |
[avr-libc-dev] Use of LPM (memcpy_P) on Xmega |
Date: |
Fri, 4 Mar 2011 10:19:39 +0000 |
User-agent: |
KMail/1.9.10 |
People,
In the libc 1.7.1 it states:
For Xmega devices, make sure the NVM controller
command register (NVM.CMD or NVM_CMD) is set to
0x00 (NOP) before using any of these functions.
which was a result of the post "memcpy_P on XMega" by
Johannes Bauer on 1-Jun-2010 14:02 in the avr-gcc-list.
Also see: http://savannah.nongnu.org/bugs/?30085
Although correct, the situation is a little more complicated
than that. If it were absolutely necessary to have NVM.CMD
equal to 0x00 (as suggested by the xmega manual and this
note) before being able to use LPM it would be an absolute
disaster i guess. Fortunately this is not the case.
I performed a few small tests on a xmega 16A4 and these were
my results:
- Changing NVM.CMD to 0x01 of 0x02 indeed changes the
result of LPM, so if you want to read a byte from flash memory
be sure NVM.CMD does not equal 0x01 or 0x02. Luckely these
situations are rare and can be well controled.
- When erase/writing to EEPROM for example, the NVM.CMD register
needs to be set to 0x35. During the time the EEPROM is busy,
you cannot set NVM.CMD to an other value. If you try it and
read it back afterwards you will notice it still has the value 0x35.
- However, while the EEPROM is busy, it is perfectly possible to
read a byte from flash using LPM on the xmega (as it was on
the older mega's). So the NVM.CMD does not need to be zero
for that. This is a big relieve since such situations are not so
rare.
I did not extend my experiments to other EEPROM activities, but
i suspect that EEPROM can be operated using other commands
as well, independent from reading bytes from flash using LPM.
It would have been better is this was clearly pointed out in the
manual, togheter with a explanation how it is really organised
'under the hood'.
I'll be happy to hear from other experiences.
Regards,
Ruud
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-dev] Use of LPM (memcpy_P) on Xmega,
Ruud Vlaming <=