This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Flash Programming C166 XC164CS

Hi Everyone,

Is anyone familiar with the flash programming procedure on the XC164 derivatives? I'm trying to implement a small piece of code that will live in sector 0 of my XC164. At the moment, all I'm trying to do is erase sector 5. I have the following piece of test code:

// Try a little flash programming (erasing sector 5)
{
    // Set some pointers to register locations
    unsigned int* reg_a = (unsigned int*)(0xfff0AA);
    unsigned int* reg_b = (unsigned int*)(0xfff054);
    unsigned int* reg_c = (unsigned int*)(0xff8000);
    unsigned int* reg_d = (unsigned int*)(0xfff000);

    // Clear status bits
    *reg_d = 0x0000;    // Clear status bits
    printf( "Flash status is %x \n", *reg_d );

    // Command sequence to erase sector 5
    *reg_a = 0x0080;
    *reg_b = 0x00AA;
    *reg_c = 0x0033;

    // Check status bits again
    printf( "Flash status is %x \n", *reg_d );

    // Wait for flash to be no longer busy
    while( *reg_d & 0x0001 )
    {
        _nop_();
    }
}

Each time I run this I see the sequence error bit in the flash status register is set.

One thing that strikes me as being odd is the byte reg_c is pointing to. According to Infineon's documentation, the address of phase 3 is the sector you want to erase (SA). But it also says for sector 3, SA should be 0x8000. But that puts the address before the base address of 0xfff000 for flash registers.

Does anyone have any ideas what I'm doing wrong? Am I even barking up the wrong tree completely?

Thanks for any help.
Paul.

0