On Apr 26, 2005, at 11:04 AM, arhodes19044 wrote:
> I can not find the source files for the eeprom routines in libc. I
> want to disable interrupts for the minimum necessary period while
> writing to EEPROM. I bet that the clear/set should occur in the
> write_byte function, since that is probably called by all the larger
> size write functions.
The sources are:
/* write a byte to EEPROM */
/* void eeprom_write_byte(uint8_t *addr, uint8_t val); */
/* addr = r25:r24, val = r22 */
#define val rP3
.global _U(eeprom_write_byte)
_U(eeprom_write_byte):
sbic _SFR_IO_ADDR(EECR), EEWE
rjmp _U(eeprom_write_byte) /* make sure EEPROM is ready */
#ifdef EEARH
out _SFR_IO_ADDR(EEARH), addr_hi
#endif
out _SFR_IO_ADDR(EEARL), addr_lo
out _SFR_IO_ADDR(EEDR), val
in __tmp_reg__, _SFR_IO_ADDR(SREG)
cli ; /* no ints between setting EEMWE and
EEWE */
sbi _SFR_IO_ADDR(EECR), EEMWE
sbi _SFR_IO_ADDR(EECR), EEWE
out _SFR_IO_ADDR(SREG), __tmp_reg__
ret
#undef val
/* write a block of bytes to EEPROM */
/* void eeprom_write_block (const void *buf, void *addr, size_t n); */
/* buf = r25:r24, addr = r23:r22, n = r21:r20 */
.global _U(eeprom_write_block)
_U(eeprom_write_block):
cp n_lo, __zero_reg__ ; check if really there
is something to write
cpc n_hi, __zero_reg__
breq eeprom_write_block_done
LOAD_X(buf_lo, buf_hi)
in buf_lo, _SFR_IO_ADDR(SREG) ; reuse buf_lo as the
SREG temporary storage
eeprom_write_block_busy:
sbic _SFR_IO_ADDR(EECR), EEWE
rjmp eeprom_write_block_busy ; make sure EEPROM is
ready
#ifdef EEARH
out _SFR_IO_ADDR(EEARH), addr_hi
#endif
out _SFR_IO_ADDR(EEARL), addr_lo
ld __tmp_reg__, X+
out _SFR_IO_ADDR(EEDR), __tmp_reg__
cli ; no ints between
setting EEMWE and EEWE
sbi _SFR_IO_ADDR(EECR), EEMWE
sbi _SFR_IO_ADDR(EECR), EEWE
out _SFR_IO_ADDR(SREG), buf_lo
subi addr_lo, lo8(-1)
sbci addr_hi, hi8(-1)
subi n_lo, lo8(1)
sbci n_hi, hi8(1)
brne eeprom_write_block_busy
eeprom_write_block_done:
ret
> How do I disasm only the required parts.
If you still have the Makefile I sent a while back, posted to the list,
it creates "object.elf" which is loaded into AVRStudio for debugging,
but also generates a text file named "object.list". I add object.list
to my PN2 project for quick access. Then text search (control-F) for
the string of interest.
> How do I even SEE the disasm'ed code while running avrsrudio?
Right mouse click on the source window, "view disassembly" or something
obvious to that effect. I have problems with AVRStudio getting out of
sync with the C source lines, stopping in mid-statement, and
automagically opening a disassembly window.
One advantage of using object.list described above is that the line of
C source code is inserted as comments immediately prior to the
generated code. AVRStudio does not insert the C source, but does
provide verbose descriptions of each assembly instruction.
Believe the command line to generate object.list is:
avr-objdump -DS object.elf > object.list
--
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.Message
Re: [AVR-Chat] was eeprom ? Now about disasm
2005-04-27 by David Kelly
Attachments
- No local attachments were found for this message.