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.

Writing to Flash on PIC18F (Cant get it to work at all, Help Please)

Status
Not open for further replies.

ste2006

Advanced Member level 4
Joined
May 1, 2012
Messages
118
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Activity points
2,226
Hi,
I know this has been discussed before and i have read all of the posts and the data sheets but still cant seem to write to the Flash on a PIC18F27J13, I am using the ICD3 to debug it and just cant see anything in flash memory after running it,

I am erasing the blocks first etc and all registers appear to be working correctly but still no luck, Anyone any ideas??

Here is my code,

Code:
//Read & Write Flash Settings

    TBLPTRU = 0x01;                             // Set Address of Flash
    TBLPTRH = 0xB8;
    TBLPTRL = 0x00;

    EECON1bits.WPROG = 1;                       // 2 Byte Mode
    EECON1bits.WREN = 1;                        // Enable Write to Memory
    EECON1bits.FREE = 1;                        // Enable Erase
    INTCONbits.GIE = 0;                         // Disable Interrupts
    EECON2 = 0x55;
    EECON2 = 0xAA;
    EECON1bits.WR = 1;                          // Start Erase
    Nop();

    INTCONbits.GIE = 1;                         // Enable Interrupts

    for (i = 0; i < 64; i++)
    {
        TABLAT = data[i];
        _asm 
            TBLWTPOSTINC
        _endasm
    }

    EECON1bits.WREN = 1;                        // Enable Write to Memory
    INTCONbits.GIE = 0;                         // Disable Interrupts
    EECON2 = 0x55;
    EECON2 = 0xAA;
    EECON1bits.WR = 1;                          // Start Programming
    Nop();
    INTCONbits.GIE = 1;                         // Enable Interrupts

    INTCONbits.GIE = 1;
    EECON1bits.WREN = 0;                        // Disable write to memory

Just to get it going i am happy to write anything into Flash, Once this works i will actually write what i want,

Thanks,
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top