This week the second part of my task, that is to be able to erase the FPGA or PIC32 flash when needed and program them accordingly. Erasing the FPGA means putting it in configuration mode so that in can receive a configuration bitstream. This is achieved by pulling PROGRAM_B pin low and then set it high again while waiting for INIT_B pin to follow. Once the FPGA is in configuration mode, the bitstream can then be transferred until the done pin goes high which indicates that programming is finished. Erasing and programming the flash. However, is a little more complicated. I am trying to use a boot-loader to erase the flash and write the necessary code to it.
It works by reserving a range of addresses in the program flash memory (PFM) this memory can be erased or programmed while the PIC32 is still operating this is because the memory that is controlled by Boot-loader is different from the boot memory and does not intervene with it. The user code can be written to the PFM using the boot-loader. It can then erase those addresses by setting every bit to “1”. Keeping in mind that the flash memory has to be erased before anything can be written on it. The write operation can only change a bit from “1” to “0” and that is why the flash has to be erased first.