2011-09-01 01:32 PM
Hello,
I am using the STM32F series. Right now I am writing to the flash one word at time. I have no problem doing this. I now implemented a function that writes one byte at a time. When I try to do this, I get the ''programming parallelism error'' (PGPERR bit in FLASH_SR register). However, I have correctly changed the PSIZE bits in the control register and this has been verified in the debug window. Does anybody know why I am getting this error?Clive1 I know you're out there. You helped me solve my last problem.Any input is much appreciated.Thanks.2011-09-01 03:06 PM
I thought the minimum write size for the STM32F1 series was 16-bits, but let me check.
Normally I'd pair things up, and write an additional NUL byte for strings to get them to multiples of two bytes, or write aligned structures into it.2011-09-01 03:31 PM
The F2 series allows what gman is trying to do.
gman - identify where in your code sequence the error occurs. Is it the first byte write attempt, or the next word write attempt. I presume you set PSIZE before the byte write, did you reset it to 16 bits after the byte write function ? Cheers, Hal2011-09-02 06:30 AM
Hello Clive1 and Baird,
Thank you very much for the input. I just found an error in my code however. The following is my FlashProgramByte function://******************************************************************************************************// @brief Programs a byte (8-bit) at a specified address.// @param address: specifies the address to be programmed.// data: specifies the data to be programmed.// @return kFLASH_ERROR: if there was an error while programming the flash.// kFLASH_COMPLETE: if everything went okay.//******************************************************************************************************uint32_t FlashProgramByte( uint32_t address, uint8_t data ){ uint32_t flash_status; // Wait for last operation to be completed flash_status = flashWaitForLastOperation(); // if the previous operation is completed, proceed to program the new data if(flash_status == kFLASH_COMPLETE){ FLASH_REGS.CR.PSIZE = kFLASH_BYTE_PSIZE; // set the PSIZE bits FLASH_REGS.CR.PG = 1; // set the programming bit *(uint8_t *)address = data; // write the data to the specified address // Wait for last operation to be completed flash_status = flashWaitForLastOperation(); // when program operation is completed, disable the PG Bit FLASH_REGS.CR.PG = 0; } // Return the Program Status return( flash_status );}My problem was the following line:*(uint8_t *)address = data; // write the data to the specified addresswas*(uint32_t *)address = data; // write the data to the specified addressSo in summary, it was just me messing up pointers. Thanks for your input however, I really appreciate it.Gman