[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] Corrections of bootloader example in boot.h
From: |
pfaff - Markus Pfaff |
Subject: |
[avr-libc-dev] Corrections of bootloader example in boot.h |
Date: |
Fri, 12 Sep 2003 09:35:08 +0200 |
Hi,
found a little problem in boot.h:
At the end of the file there's a little example (very helpful!):
// Erase page.
boot_page_erase((unsigned long)ADDRESS);
while(boot_rww_busy())
{
boot_rww_enable();
}
// Write data to buffer a word at a time. Note incrementing address
by 2.
// SPM_PAGESIZE is defined in the microprocessor IO header file.
for(unsigned long i = ADDRESS; i < ADDRESS + SPM_PAGESIZE; i += 2)
{
boot_page_fill(i, (i-ADDRESS) + ((i-ADDRESS+1) << 8));
}
// Write page.
boot_page_write((unsigned long)ADDRESS);
while(boot_rww_busy())
{
boot_rww_enable();
}
I had to change this a little to make it work on the Mega32. If you call
boot_rww_enable();
while the flash is in the programming phase this will abort programming
(see Mega32 datasheet, p. 246, description of bit 4). To prevent this I
used code like this:
// Erase page
boot_page_erase(((unsigned
long)FlashPageNr)*SPM_PAGESIZE);
// Wait until the memory is erased.
boot_spm_busy_wait();
// Store buffer in flash page
boot_page_write(((unsigned
long)FlashPageNr)*SPM_PAGESIZE);
// Wait until the memory is written.
boot_spm_busy_wait();
// Reenable RWW-section again. We need this if we want
// to jump back to the application after bootloading.
boot_rww_enable();
Markus
---------------------------------------
Dipl.-Ing. Dr. Markus Pfaff
FHS-Hagenberg/HSSE
VLSI-Design
Hauptstr. 117
A-4232 Hagenberg/Austria/Europe
fon +43 7236 3888 2420
fax +43 7236 3888 2499
email address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-dev] Corrections of bootloader example in boot.h,
pfaff - Markus Pfaff <=