Part Number:MSP430F5438A
Tool/software: Code Composer Studio
I am trying to use the MSP430F5438A Experimenter's Board to complete a project for one of my classes. Currently I am using the User Experience Demo specifically the audio record/playback app.
My goal is to modify the audio data AFTER it has been recorded and stored in flash but BEFORE it is played back. Currently when I run the method, I can retrieve the data, but I cannot write it back to memory. Below is the function I use and it's location in the demo program.
void audioRecord(unsigned char mode) { unsigned char i; setupRecord(); //... //... //... synthesizeVoice(); //my function is called shutdownRecord(); }
void synthesizeVoice(){ unsigned long flash_loc; FCTL3 = FWKEY; // Unlock the flash for write FCTL1 = FWKEY + WRT; //Set flash to write byte unsigned long FlashPtr; //Long pointer to flash memory FlashPtr = PlaybackPtr; //load starting location of audio for(flash_loc = AUDIO_MEMSTART; flash_loc <= lastAudioByte; flash_loc++){ //loop unsigned char data = (*((unsigned char*)FlashPtr)); //retrieve data from flash (*((unsigned char*)FlashPtr)) = (data + 1); //modify data and store in flash at same location FlashPtr++; //increment flash pointer location } FCTL3 = FWKEY + LOCK; // Lock the flash from write //char data[AUDIO_MEMEND-AUDIO_MEMSTART]; }
So far, I can think of a few solutions to the problem but I would like to get some advice on which route to pursue.
Option 1) I do not erase the flash before writing to it. I have seen this mentioned several times on the E2E forms and I feel this could be why the (data+1) is not written to flash. Erasing the flash would not be efficient in the current design because the audio is written to flash in blocks using the DMA. There is usually a few thousand samples which means reading a sample, erasing that location, and rewriting it would need to happen a few thousand times and that would impossibly slow.
Option 2) Instead of using the DMA to write to flash, I could read the ADC12MEM0 every interrupt and save the audio sample in RAM and modify it there. However this would take a lot of rewriting of the demo and I am not very experienced with MSP430. Another potential problemcould be the speed of the reading of ADC12MEM0, modifying, and storing in flash before the next audio sample is read in.
I appreciate any help with this and that you for your time.