I am having a problem writing to memory on my ARM STM32F407VG. I am using Keil to program it and working with it for an Embedded Systems class. We just moved from ASSEMBLY to C and I am still getting acquainted with CMSIS.
The assignment itself is fairly simple: generate 5000 random numbers and place them into an array. Then test this array for prime numbers and place those in an array. The assignment itself is not too bad but I am having trouble with the peripherals. Specifically, while I have had no problems with the RNG during compiling, I do get a lot of problems writing to memory.
In ASSEMBLY we were able to write directly to memory and a slide in our intro to programming the ARM in C looked similar. It had you declare a pointer to an address which you initialized as the beginning of FLASH (0x20000000). Then you just assigned a number to that address and it was stored. In practice this didn't work out so my suspicion was that I need to configure the flash peripheral. The latter had a ton of commands that we didn't cover and when I tried the most basic, I kept getting a ton of errors.
My question is this: do I need to configure the flash peripheral or can I just write to memory by declaring a pointer and writing to it? If not, what is wrong with my FLASH peripheral commands in the code below and where can I find an example of how it is to be configured? The help file on FLASH is huge and I don't know what is necessary and what isn't.
#include "stm32f4_discovery.h"
#include <stm32f4xx.h>
//#define StoreAddress (uint32_t*) 0x20000000;
int main(){
uint32_t RandomNumber;
uint32_t StoreAddress;
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_RNG, ENABLE);
RNG_Cmd(ENABLE);
RNG_GetFlagStatus(RNG_FLAG_DRDY);
StoreAddress = 0x200000F0;
RandomNumber = RNG_GetRandomNumber();
FLASH_Unlock();
FLASH_Status FLASH_ProgramWord(uint32_t StoreAddress, uint32_t RandomNumber);
FLASH_Lock();
}
Any help is greatly, greatly appreciated.
Thanks, Yusif