Flash operations result in "No source available for ..."

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flash operations result in "No source available for ..."

3,999 Views
niba
Contributor III

Hi,

I am currently developing a flash driver for the S12Z and I need your help. All flash operations result in "No source available for "0xBC6192 (0xBC6192)() " ".

I can step over all c instructions. Everything works fine while debugging. The flash is erased/written properly. If I run without breakpoints, it results in "No source available for "0xBC6192 (0xBC6192)() " "

Here are my function. Before calling I check the CCIF flag for being TRUE. Can anybody see a bug?

void flash_erase_sector(uint16 address)
{

    FSTAT = 0x30;    // clear ACCERR and PVIOL
    FCCOBIX = 0x01;
    FCCOB0HI = 0x0A; // erase pflash sector
    FCCOB0LO = (uint8)((address & 0x00FF0000) >> 16);
    FCCOB1 = (uint16)(address & 0x0000FFFF);
    FSTAT_CCIF = 1;         // launch command
}

void flash_write_phrase(uint16 address, uint8* data)
{
    FSTAT = 0x30;    // clear ACCERR and PVIOL
    FCCOBIX = 5;     // write 8 bytes (1 phrase)
    FCCOB0HI = 0x06; // write command
    FCCOB0LO = (uint8)((address & 0x00FF0000) >> 16);
    FCCOB1 = (uint16)(address & 0x0000FFFF);
    FCCOB2 = *((uint16*)data);
    FCCOB3 = *((uint16*)(data+2));
    FCCOB4 = *((uint16*)(data+4));
    FCCOB5 = *((uint16*)(data+6));
    FSTAT_CCIF = 1;           // launch command
}

After crashing the error flags ACCERR and FPVIOL are FALSE (0). The FDIV is set to 0x0F (16 MHz bus clock). All EEPROM operations are working fine and are programmed the same way.

Any idea? Thank you very much.

11 Replies

3,660 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

I have noticed that when you launch a command

FSTAT_CCIF = 1;

You do not wait until the command is complete

while(FSTAT_CCIF == 0);

This could be the problem.

 

Regards,

Daniel

0 Kudos
Reply

3,660 Views
niba
Contributor III

Hi Daniel,

yes, it is a problem! I had the "wait until the CCIF is TRUE", but outside the flash function. In the application part. That crashed my program. Don't know exactly why. But it works, when I call "while(FSTAT_CCIF == 0);" within the same flash function.

Do you have any explanation why I can't access FSTAT_CCIF bit outside the flash function?

I made your example program (ZVL32-FLASH-CW106) to get run. Thank you!

Regards

3,660 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

You should stay in RAM, while it is writing to the FLASH. Without the loop, it immediately leaves your function and starts executing code from the FLASH.

Regards,

Daniel

3,660 Views
mikijt
Contributor I

here is your attachment i have modified.

0 Kudos
Reply

3,660 Views
mikijt
Contributor I

Hi Daniel:

      i have got the same problem, using your attachment(ZVL32-FLASH-CW106); CW10.7 and chip is 9s12zvca64.

when "step over " into the   PFLASH_Send_Command()  program suspended:

pastedImage_1.png

the PFLASH_Send_Command() located at :pastedImage_2.png

i only modified the rom range and debug cofigration:

pastedImage_3.pngpastedImage_4.png

1、How can i solved it ,can you give me some advice!

2、As you said "You should stay in RAM, while it is writing to the FLASH. Without the loop, it immediately leaves your function and starts executing code from the FLASH." what does it mean saty in ram?

0 Kudos
Reply

3,660 Views
niba
Contributor III

And that's the result map file using "#pragma CODE_SEG DEFAULT_RAM"

MODULE:                 -- fls.o --
- PROCEDURES:
     fls_init                       1228      20      32       1   .data       
     fls_write_phrase               1248      60      96       1   .data       
     fls_erase_sector               12A8      52      82       1   .data       
- VARIABLES:
     fls_image                      1618      16      22       4   .common   

The addresses are between 0x001000 and 0x001FFF!

Despite that my program crashes with "No source available for ..." :-(

0 Kudos
Reply

3,660 Views
niba
Contributor III

When using "#pragma CODE_SEG RAM" my functions are placed into RAM according to map-file.

MODULE:                 -- fls.o --
- PROCEDURES:
     fls_init                        FF1FE1      20      32       1   RAM         
     fls_write_phrase                FF2001      60      96       1   RAM         
     fls_erase_sector                FF2061      52      82       1   RAM         
- VARIABLES:
     fls_image                         1546      16      22       4   .common  

The only think I don't understand, is why the address is 0xFF... and not between 0x001000 and 0x001FFFMemoryS12Z64.jpg

0 Kudos
Reply

3,660 Views
danielmartynek
NXP TechSupport
NXP TechSupport

It shouldn’t be a problem to call the command from an interrupt routine. Although the routine is stored in the flash, when you call your command function from that interrupt, it goes to RAM and execute it from there.

It could be problem if you use nested interrupts, which is however disabled by default. So if you call it from interrupt routine, you can actually omit the disable/enableInterrupts.

I have slightly modified the example code so that CCL register is pushed onto the stack and I bit is set before the Flash command is executed and after that the CCL register is restored.

 

Have you tried running the example code? Whether it does the same problems or not.

Could you attach your project?

Regards,

Daniel

3,660 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

 

You can find S12ZVL32 Flash example in the attachement. The PFLASH_Send_Command() function is executed from RAM.

 

Regards,

Daniel

3,659 Views
niba
Contributor III

Hi Daniel,

thank you for the reply.

I wrapped my flash functions (declaration and definition) with CODE_SEG pragmas as described in MCU_S12Z_Compiler.pdf, but it doesn't help. My program crashes with "No source available for ...".

Is there something else I have to be aware? Should the functions be declared extern?

In the code example, you attached, I found this "We cannot simultaneously execute code from the same flash block which we program. Therefore we disable interrupts in case when interrupt routines are stored in flash."

I call the flash functions within a timer interrupt. Is it a problem?

Best regards

0 Kudos
Reply

3,659 Views
niba
Contributor III

The reason for that strange behavior: It is not allowed to read and write to the same flash block simultaneously! The uC, which I use, has only one flash block (MC9S12ZVC64). The programm is located there, so I read from that flash block while the program execution. The EEPROM is located in another block. That’s why the EEPROM operations work without any problems. The solution for my problem is to execute the flash operations from RAM!

 

Somebody knows how to do it?

0 Kudos
Reply