New Products Flash Sale
Thread Tools
Old Jul 16, 2015, 07:18 PM
vollrathd is online now
Find More Posts by vollrathd
Registered User
vollrathd's Avatar
Joined Jan 2007
1,740 Posts
Help!
PicChip PIC24FV32KA301

I've got these PIC24FV32's that are programmed with the "Voltsagger" project.

Now, I'd like to add a simple flight counter, using the PIC24FV32's internal EEProm.

Only problem is, the mikroC program used for programming it doesn't support writing to or reading from the the PIC24FV32's EEProm. Yeah, I've contacted them, and they admitted to it. They suggested I write my own EEProm read and write program myself.

Looking at the MicroChip specs, they call for using PicChip registers that don't exist in the mikroC program, making it difficult or impossible to use the PicChips EEProm.

So, has anyone used the EEProm in the PIC24FV32's and if so, how'd you do it?

Thanks in advance for any help.
vollrathd is online now Find More Posts by vollrathd
Reply With Quote
Sign up now
to remove ads between posts
Old Jul 18, 2015, 06:17 AM
tomsdk is online now
Find More Posts by tomsdk
RC expert
Denmark, North Denmark Region, Vestbjerg
Joined Jun 2013
207 Posts
Quote:
Originally Posted by vollrathd View Post
So, has anyone used the EEProm in the PIC24FV32's and if so, how'd you do it?
Hello Vollrathd,

I use the PIC24FV32KA301 in my combined IAS and barometric altitude sensor. All code is simply made in MPLAB-X and using the free Microchip XC16 compiler. It really works great. IMHO the ability to use eeprom is a must have. The voltsagger application should be quite easy to make work in XC16 as well.

Notify me if you would like some code snippets for the XC16 eeprom access

-Thomas
tomsdk is online now Find More Posts by tomsdk
Last edited by tomsdk; Jul 18, 2015 at 06:24 AM.
Reply With Quote
Old Jul 22, 2015, 12:02 AM
vollrathd is online now
Find More Posts by vollrathd
Registered User
vollrathd's Avatar
Joined Jan 2007
1,740 Posts
Quote:
Originally Posted by tomsdk View Post
Hello Vollrathd,

I use the PIC24FV32KA301 in my combined IAS and barometric altitude sensor. All code is simply made in MPLAB-X and using the free Microchip XC16 compiler. It really works great. IMHO the ability to use eeprom is a must have. The voltsagger application should be quite easy to make work in XC16 as well.

Notify me if you would like some code snippets for the XC16 eeprom access

-Thomas
Yup
I'd like some eprom code snippets for the XC16 compiler. Got the XC16 compiler on my computer, and have to spend some time getting familiar with it.
vollrathd is online now Find More Posts by vollrathd
Reply With Quote
Old Jul 22, 2015, 02:34 PM
tomsdk is online now
Find More Posts by tomsdk
RC expert
Denmark, North Denmark Region, Vestbjerg
Joined Jun 2013
207 Posts
Quote:
Originally Posted by vollrathd View Post
Yup
I'd like some eprom code snippets for the XC16 compiler. Got the XC16 compiler on my computer, and have to spend some time getting familiar with it.
Ok, here is a function for writing an int. I'm not saying it's pretty, but it works And it's quite simple.

void eepromwriteint(int value, int eepromaddress) {
_prog_addressT p;

p = 0x7FFE00; //hardcoded start of eeprom area.

p += eepromaddress;
SET_CPU_IPL(7);
_erase_eedata(p, _EE_WORD); //The length may be _EE_WORD, _EE_4WORDS, or _EE_8WORDS
_wait_eedata(); /* wait to complete */
_write_eedata_word(p, value); /* write a word to dat[0] */
_wait_eedata();
SET_CPU_IPL(0);
}


To read it back, I use standard table read:

int eepromreadint(int eepromaddress) {

int readvalue;
int register p;

p = 0xFE00 + eepromaddress;
TBLPAG = 0x7F;

readvalue = __builtin_tblrdl(p);
return readvalue;
}


-Thomas
tomsdk is online now Find More Posts by tomsdk
Reply With Quote
Old Jul 22, 2015, 08:53 PM
vollrathd is online now
Find More Posts by vollrathd
Registered User
vollrathd's Avatar
Joined Jan 2007
1,740 Posts
Thanks Thomas!

Quote:
Originally Posted by tomsdk View Post
Ok, here is a function for writing an int. I'm not saying it's pretty, but it works And it's quite simple.

void eepromwriteint(int value, int eepromaddress) {
_prog_addressT p;

p = 0x7FFE00; //hardcoded start of eeprom area.

p += eepromaddress;
SET_CPU_IPL(7);
_erase_eedata(p, _EE_WORD); //The length may be _EE_WORD, _EE_4WORDS, or _EE_8WORDS
_wait_eedata(); /* wait to complete */
_write_eedata_word(p, value); /* write a word to dat[0] */
_wait_eedata();
SET_CPU_IPL(0);
}


To read it back, I use standard table read:

int eepromreadint(int eepromaddress) {

int readvalue;
int register p;

p = 0xFE00 + eepromaddress;
TBLPAG = 0x7F;

readvalue = __builtin_tblrdl(p);
return readvalue;
}


-Thomas
Thanks, I'll load it up and give it a try in the next day or three. Right now, I'm just about done building up a replacement 12S2P A123 pack for my Giant Big Stick. Those original China A123's are down to around 60% of their rated Mah.
vollrathd is online now Find More Posts by vollrathd
Reply With Quote


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Help! PicChip Micro-Ohmmeter in "C" vollrathd DIY Electronics 7 Jun 04, 2015 07:45 PM
Mini-HowTo PicChip Fun Stuff vollrathd DIY Electronics 209 Mar 27, 2015 08:03 PM