Перейти к содержанию
    

jackkum

Новичок
  • Постов

    2
  • Зарегистрирован

  • Посещение

Репутация

0 Обычный
  1. :krapula: Блин ведь чувствовал что где-то на поверхности :) Спасибо огромное! :) Работает :08:
  2. Помогите пожалуйста, устал уже 2 дня бродить по инету ничего не могу найти :( Пишу бутлоадер на AVR Studio 5.0 для меги88 хекс генериться нормально, начинается с адреса 0x0E00 запускается тоже нормально, но при записи во флеш ничего не происходит, скачиваю всю флешь, загрузчик есть а новой прошивки нет, должна запасаться из еепрома внешнего по i2c во флеш с адреса 0x0000 #define F_CPU 14745600 #define BOOTSIZE 512 #define APP_END (FLASHEND - (BOOTSIZE * 2)) #include <avr/io.h> #include <avr/boot.h> #include <avr/wdt.h> #include <avr/pgmspace.h> #include <util/delay.h> #include <stdio.h> #include <string.h> #include "i2c_eeprom.h" uint8_t gBuffer[32]; uint16_t get_hex(uint8_t b){ uint16_t hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}, x = 0; for(x = 0; x < sizeof(hex); x++){ if(b == hex[x]){ return x; } } return 0; } void eraseFlash(void) { // erase only main section (bootloader protection) uint32_t addr = 0; boot_spm_busy_wait(); while (APP_END > addr) { boot_page_erase(addr); // Perform page erase boot_spm_busy_wait(); // Wait until the memory is erased. addr += 32; } boot_rww_enable(); } void boot_program_page(uint32_t page){ uint16_t w; uint8_t i; eeprom_busy_wait(); boot_page_erase(page); boot_spm_busy_wait(); for (i=0; i<32; i+=2){ w = (gBuffer[i]) + ((gBuffer[i+1]) << 8); boot_page_fill(page+i, w); } boot_page_write(page); boot_spm_busy_wait(); } void boot(void){ uint16_t i = 0;//, x = 0, size = 0, type = 0, CS = 0, byte = 0; uint32_t /*e_addr = 32000, */addr = 0; //uint16_t line[43]; //eraseFlash(); /* do { line[0] = 0; for(i=0; i<40; i++){ asm("sei"); byte = eeGetc(e_addr++); RS_putc(byte); asm("cli"); line[i] = byte; } size = get_hex(line[1]); size = (size<<8)|get_hex(line[2]); addr = get_hex(line[3]); addr = (addr<<8)|get_hex(line[4]); addr = (addr<<8)|get_hex(line[5]); addr = (addr<<8)|get_hex(line[6]); type = get_hex(line[7]); type = (type<<8)|get_hex(line[8]); if(type!=0x00){ break; } for(i = 0, x = 9; i < 32; i++, x++){ gBuffer[i] = get_hex(line[x]); } CS = get_hex(line[41]); CS = (CS<<8)|get_hex(line[42]); e_addr++; e_addr++; PORTC ^= (1<<3); writeFlashPage(addr, SPM_PAGESIZE); addr += SPM_PAGESIZE; } while(addr < 0x0E00); */ uint8_t buff[32] = "19C020C01FC01EC01DC01CC01BC01AC0"; for(i=0; i<(sizeof(buff)); i++){ uint8_t s = buff[i]; gBuffer[i] = get_hex(s); } boot_program_page(addr); boot_spm_busy_wait(); boot_rww_enable(); } int main(void) { DDRB = 0xFF; DDRC = 0xFF; eeInit(); //if(get_boarch()){ asm("cli"); boot(); //} //_delay_ms(3000); //asm("rjmp 0x0000"); while(1) { do{ PORTC ^= (1<<3); _delay_ms(500); }while(1); } } уже пробую хотябы просто строку записать не выходит :(
×
×
  • Создать...