AnsweredAssumed Answered

Flash - erases but won't write in application

Question asked by dufrane.marcus on Nov 5, 2015
Latest reply on Nov 6, 2015 by Clive One
Im using the STM32F302vb with gnu tools and a jlink for programming and debugging.

I'm am currently having an issue with a bootloader application which is a port from an F103 device that works. The problem I'm running into is that my bootloader can erase flash pages but doesn't write them. 

This has been hard to debug since there are no program or write protect errors generated during the write.

I have examined the RCC registers as well as the FLASH registers and clock configurations appear to be correct.

RCC-AHBENR = 0x00020014
The device is running a sysclk of 72MHz
FLASH-ACR = 0x00000032

attached is the program code

for(i = 0; i < expectedLength - 1; i += 2)
        FLASH->CR |= FLASH_CR_PG;
        *(volatile uint16_t *)(currentAddress + i) = buffer.flash[i/2];

I have made sure to clear the PER bit in the CR register after the erase.

Any ideas of what I may be missing? What are the major differences in the Flash peripheral from the F1 to the F3 that might cause this.