Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic24fj128gb106 flash memory read/write problem

Status
Not open for further replies.

engineer khan

Member level 3
Joined
Aug 31, 2012
Messages
66
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,833
I am using PIC24fj micro controller having trouble in write/read operation of flash memory using mikroc compiler please provide me some example code in mikroc for pic24fj flash read/write...thanks
 

What have you tried to do? How are you going about it?
Can you show us your code?
What is it not doing and where (in your code) is it going wrong?
Have you looked at the Family Reference Manual examples? (The examples are in both C and assembler and it should be fairly straight forward to rework the assembler examples in C)
Susan
 

i just need mikroC code for read/write operation of internal flash program memory of pic24fj family
 

So what is stopping you from writing the code yourself. I have given you pointers to where to find example code and there are also many code examples that can be found with Google. Try CE027 for a start.
Susan
 

/*ITS CODE WHICH I HAVE TAKEN FROM MIKROC LIBRARY ITSELF AND IT RUNS WELL BUT WHEN TEST ON PROTEUS IT DOESNT DISPLAY THE DESIRED RESULT I CHANGE IT IN MANY WAYS AND RUNED OKAY BUT NOT GIVING THE WANTED RESULT*/


char cArr[] = "mikroElektronika Flash example";
char cArr2[40];

void * pv1;
unsigned bb;

void main() {
unsigned i;

pv1 = cArr;



//--- erase the block first
FLASH_Erase(0x006000);

//--- write compact format to flash
FLASH_Write_Compact(0x006000, pv1);

//--- read compact format
pv1 = cArr2;
FLASH_Read_Compact(0x006000, pv1,12);
pv1 += 12;
FLASH_Read_Compact(0x006008, pv1,12);
pv1 += 12;
FLASH_Read_Compact(0x006010, pv1,12);
pv1 += 12;
*pv1 = 0; //termination

//--- show what has been written
i = 0;
UART1_Init(9600);
// UART1_Write_Text("Start");
UART1_Write(10);
UART1_Write(13);
while(cArr2) {
bb = cArr2[i++];
UART1_Write(bb);
}
}
 

Apart from the fact that the 'main' program exists (and therefore will likely reset the device and restart), what does that code do that it is not supposed to?
You say it "...runs well..." so I'm not sure what the problem is.
You say there are problems with the Proteus simulator, but that could well be bugs in the simulator: does it work on real hardware?
Also, in what way is it wrong? What are you seeing displayed and what are you expecting to see?
Have you used a debugger to single step through the code to see which parts are working and where the errors are occurring? If so, what are the results of that?
Susan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top