Hi crasycat, its receiving the parameters correctly now! Thank you a lot. I'm having another trouble now... Don't now if it is correct to make a new post to asking it but ill ask here... Here's the thing: I have two functions to write to the non volatile memories (EEPROM and FLASH), i have:
short writeByteToFlash (char, short);
short writeByteToEeprom (char, short, short);
When im debugging and im running them step by step both functions work fine... but when i just run the program it doesn't write to the flash, instead of that it works strange and a message tells me on the command window "Preset breakpoint encountered".
And also: ILLEGAL_BP
Im wondering why is that? The writeByteToEeprom function works perfectly fine, im feeding the dog in every cycle i have on the function. Probable im making a novice mistake?
I have good C/C++ Experience programming but this is my very first applications for this kind of systems!
Here is the function:
short writeByteToFlash (char value, short address)
{
char *Pointer = NULL;
short couldWrite = 1;
if (address >= 0x7C00 && address = 0xFFFF) //Validating the address
{
FCDIV_PRDIV8 = 1; // divide the bus frequency / 8.
FCDIV_DIV = 12; //Set fFCLK to 192.3 khz (necessary for the flash and EEPROM programming).
while (FCDIV_DIVLD == 0)
__RESET_WATCHDOG(); //Ensure that the divisor has loaded correctly.
FSTAT_FACCERR = 0; //Ensure that this flag is cleared.
Pointer = ( char *)address;
*Pointer = value;
FCMD = 0x20; //Byte program command code.
FSTAT_FCBEF = 1; //Launch the command
while ((FSTAT & FSTAT_FCCF_MASK) == 0) //Wait until the write is done, and stop if an error occurs.
{
if (FSTAT_FACCERR == 1)
{
couldWrite = 0;
break;
}
__RESET_WATCHDOG();
}
}
else
couldWrite = -1;
return couldWrite;
}
Thanks for your help guys its very appreciated.
Message Edited by Saga on 2006-11-0810:53 AM
Message Edited by Saga on 2006-11-0810:55 AM