Jump to content

    
Sign in to follow this  
Radi0

Поясните пожалуйста несколько моментов по примеру из boot.h

Recommended Posts

Добрый день уважаемые форумчане. Поясните пожалуйста несколько моментов по примеру из boot.h

 

 

void boot_program_page (uint32_t page, uint8_t *buf)                                    
{
    uint16_t i;
    uint8_t sreg;
    sreg = SREG;
    asm("cli");                                                                                                // Disable interrupts.    
    
    eeprom_busy_wait();
    boot_page_erase(page);
    boot_spm_busy_wait();                                                                                    // Wait until the memory is erased.
    for (i=0; i<SPM_PAGESIZE; i+=2)
    {
        // Set up little-endian word.
        uint16_t w = *buf++;
        w += (*buf++) << 8;
        boot_page_fill_safe(page + i, w);
        //boot_page_fill (page + i, w);
    }
    boot_page_write(page);                                                                                    // Store buffer in flash page.
    boot_spm_busy_wait();                                                                                    // Wait until the memory is written.
    // Reenable RWW-section again. We need this if we want to jump back
    // to the application after bootloading.
    //boot_rww_enable ();
    // Re-enable interrupts (if they were ever enabled).
    boot_rww_enable();
    SREG = sreg;
    boot_spm_interrupt_enable();
    
    //asm("sei");                                                                                            // Enable interrupts
}

 

1. Что будет если не использовать макрос boot_page_erase(page); ?

2. Возможно ли исправить только несколько слов в странице? Используя boot_page_fill() с конкретными адресами а потом запуская boot_page_write(page);?

 

Контроллер Atmega 128

 

Заранее благодарю.

Edited by Radi0

Share this post


Link to post
Share on other sites

Попробуйте прочитать даташит, там изложено довольно хорошо.

От себя рекомендую читать блок, исправлять, стирать, записывать.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this