• AVR Freaks

PIC12F1501 - Help with writing & reading flash memory

Author
JeyakrishnaSridhar
New Member
  • Total Posts : 8
  • Reward points : 0
  • Joined: 2019/10/02 22:49:23
  • Location: 0
  • Status: offline
2019/11/29 02:46:10 (permalink)
0

PIC12F1501 - Help with writing & reading flash memory

Dear all, 
 
 
For my project, using PIC12F1501, I am using NCO peripheral to pulse my circuit and I will be operating it at 2 modes of operation, namely,  Calibration mode & Normal operation mode. The underlying circuit operates best at a particular frequency and to find out that particular frequency, I need to have a frequency sweep once in lifetime, store that frequency value in flash and every other time, it operates in normal operation where it fetches the operating frequency from the flash. The switch between calibration and normal operation mode is done by a Digital input. 
 
Calibration mode:
Sweep the NCO frequency from 800kHz to 999kHz at a duty cycle of about 50% using PFM mode
- Find the best operating point (using AN pins)
- Store values in Flash. 
 
Normal operation:
Read the values from flash
- Initialize NCO frequency values with the read variables
- Do other functions. 
 
As mentioned before, the calibraiton is done only once and the value has to be stored in a particular location in flash. Every other time, when the circuit is (re)started, the normal operation mode reads the flash and initializes the NCO accordingly. 
 
I tried using the routines given in memory.c but the FLASH_WriteWord() requires me to declare a variable unit16_t ramBuf[16] which already takes 32 bytes and with other declarations, i am running out of space. I tried to modify this write word as below, but still i wasnt able to get it working. 
 
Could someone help me to write 2 16bit data in the flash only during calibration and can be fetched while normal operation mode.
 
Thanks! 
#1

3 Replies Related Threads

    katela
    Super Member
    • Total Posts : 1461
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: online
    Re: PIC12F1501 - Help with writing & reading flash memory 2019/12/02 08:58:09 (permalink)

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #2
    Jim Nickerson
    User 452
    • Total Posts : 6373
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: online
    Re: PIC12F1501 - Help with writing & reading flash memory 2019/12/02 09:47:31 (permalink)
    0
    missing post
    #3
    JeyakrishnaSridhar
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2019/10/02 22:49:23
    • Location: 0
    • Status: offline
    Re: PIC12F1501 - Help with writing & reading flash memory 2019/12/03 02:01:32 (permalink)
    0
    Sorry, I had to try multiple times to post this as I was getting an error. 
     
    Admin: Please delete this
     
    Thank you! 
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5