Hi can anybody tell me why it doesn’t write to the eeprom.
I know the firmware is executing since the led is turned off if change the following to a 1
PORTC = (0 << BOOTLED_BIT);
I’m using the avr gcc library functions to write to the eeprom
The reason why I think it isn’t working is the led should be switched off when I written a 0 to the eeprom.
In C programming 0 is false and 1 is true. Therefore if I write a 0 and switch isn’t pressed he bootloader shouldn’t execute
and led should be off. I’ve initialise the output to be a high and so the current going to led isn’t being directed to gnd.
I’m using an atmega 328p
/* initialize hardware */
bootLoaderInit();
odDebugInit();
DBG1(0x00, 0, 0);
/* jump to application if jumper is set */
unsigned char do_boot_load;
unsigned char do_boot_load_via_eeprom;
uint8_t addr;
do_boot_load = ~PIND & (1 << JUMPER_BIT); // see if jumper is set (= 0)
do_boot_load_via_eeprom = eeprom_read_byte(addr); // bootloader bit in eeprom address 0
if(do_boot_load || do_boot_load_via_eeprom){
addr=5;
eeprom_write_byte( (uint8_t *)addr, 6) ;
PORTC = (0 << BOOTLED_BIT); // turn bootloader led on
uchar i = 0, j = 0;
#ifndef TEST_MODE
GICR = (1 << IVCE); /* enable change of interrupt vectors */
GICR = (1 << IVSEL); /* move interrupts to boot flash section */
#endif
initForUsbConnectivity();
do{ /* main event loop */
wdt_reset();
usbPoll();
#if BOOTLOADER_CAN_EXIT
if(exitMainloop){
#if F_CPU == 12800000
break; /* memory is tight at 12.8 MHz, save exit delay below */
#endif
if(–i == 0){
if(–j == 0)
break;
}
}
#endif
}while(1);
}
leaveBootloader()