PIC32 internal Flash

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
arpatel
Posts: 3
Joined: 01 Jun 2018 04:19

PIC32 internal Flash

#1 Post by arpatel » 08 Jun 2018 03:52

Hi
I have tried to write and read to internal flash with UART on EasyPIC fusion v7(PIC32MX).
I have a problem with reading flash. It doesn't show anything.
My programme is

unsigned char pdest[55]= "Testing long string like uart buffer"; //57+ future expantion
unsigned char receive[80];
unsigned long int Address;
unsigned long* ptr;
unsigned long i;
unsigned long int value;
unsigned long int k;
unsigned char* test_char;
unsigned char tempChar[5];

unsigned long StringToLong(char test[5])
{ unsigned long l;
l = test[3];
l = (l<<8)|test[2];
l = (l<<8)|test[1];
l = (l<<8)|test[0];
return (l);
}
unsigned char* LongToString(long t)
{ char anil[5] ;
anil[0] = t & 0xFF;
anil[1] = (t >> 8) & 0xFF;
anil[2] = (t >> 16) & 0xFF;
anil[3] = (t >> 24) & 0xFF;
Delay_ms(50);
return(anil);
}
void main()
{
AD1PCFG = 0xFFFF;
UART2_Init(56000);
Delay_ms(200);
Address = 0x9D001000 ;
Flash_Erase_Page(Address);
UART2_Write_Text("Started\n");
for(i=0;i<strlen(pdest);i=i+4)
{
memcpy(tempChar,pdest+i,4);
k = StringToLong(tempChar) ;
Flash_Write_Word(Address,k);
Delay_ms(500);
Address++;
}
UART2_Write_Text("in the middle\n");
ptr = Address;
// for(i=0;i<6;i++)
//{
value = *ptr;
test_char = LongToString(value);
Delay_ms(500);
UART2_Write(*test_char);
UART2_Write(*(test_char+1));
UART2_Write(*(test_char+2));
UART2_Write(*(test_char+3));
UART2_Write('\n');
Delay_ms(500);
// ptr--;
// }
UART2_Write_Text("Done");




}

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: PIC32 internal Flash

#2 Post by filip.grujcic » 08 Jun 2018 11:48

Hello,

Have you checked out the included example in the compiler for this?
It's located in: ...\Examples\Internal MCU modules folder

Kind regards,
Filip Grujcic

Post Reply

Return to “mikroC PRO for PIC32 General”