hy
i am using the ota update to flash my teensy during the running.
I use this source:
https://github.com/Photosynq/PhotosynQ-Firmware/blob/master/multispeq1/flasher.cpp
This means, i send the hex file over the CAN-Bus to the teensy 3.2 and after the transfer (4bytes all 50ms ~90min) i will send a command over CAN-Bus to flash the firmware.
If i start sending the firmware the source code is deleting the upper flash of the teensy. but this makes the teensy realy slowly. (my Idle Loop Counter per Sec goes down from 45kHz to nearly 13kHz) and will never increase back to 45kHz
what is happening in these lines of code, that the MCU is slowing down so extreme?
With best regards
i am using the ota update to flash my teensy during the running.
I use this source:
https://github.com/Photosynq/PhotosynQ-Firmware/blob/master/multispeq1/flasher.cpp
This means, i send the hex file over the CAN-Bus to the teensy 3.2 and after the transfer (4bytes all 50ms ~90min) i will send a command over CAN-Bus to flash the firmware.
If i start sending the firmware the source code is deleting the upper flash of the teensy. but this makes the teensy realy slowly. (my Idle Loop Counter per Sec goes down from 45kHz to nearly 13kHz) and will never increase back to 45kHz
what is happening in these lines of code, that the MCU is slowing down so extreme?
Code:
RAMFUNC static int flash_erase_sector(uint32_t address, int unsafe)
{
if (address > FLASH_SIZE || (address & (FLASH_SECTOR_SIZE - 1)) != 0) // basic checks
return 1;
if (address == (0x40C & ~(FLASH_SECTOR_SIZE - 1)) && unsafe != 54321) // 0x40C is dangerous, don't erase it without override
return 2;
__disable_irq();
// wait for flash to be ready!
while ((FTFL_FSTAT & FTFL_FSTAT_CCIF) != FTFL_FSTAT_CCIF)
{
};
// clear error flags
FTFL_FSTAT = FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL | FTFL_FSTAT_MGSTAT0;
// erase sector
FTFL_FCCOB0 = 0x09;
FTFL_FCCOB1 = address >> 16;
FTFL_FCCOB2 = address >> 8;
FTFL_FCCOB3 = address;
FTFL_FSTAT = FTFL_FSTAT_CCIF; // execute!
while ((FTFL_FSTAT & FTFL_FSTAT_CCIF) != FTFL_FSTAT_CCIF) // wait for ready
{
};
FMC_PFB0CR = 0xF << 20; // flush cache
if (!leave_interrupts_disabled)
__enable_irq();
return FTFL_FSTAT & (FTFL_FSTAT_RDCOLERR | FTFL_FSTAT_ACCERR | FTFL_FSTAT_FPVIOL | FTFL_FSTAT_MGSTAT0);
} // flash_erase_sector()
With best regards