Thanks Imajeff, but I have checked the erratas, and my chipset (0L15Y) does not include anything about programming Flash.
Here is the disassembled listing of the (not working version of the) program loop (almost identical to the AN2153). I did read somewhere on the forum a note about a delay before the CBEIF-bit is cleared, so I did put in the NOPs, but they did not help.
a00FAFA E6FA 02D7 ProgFBlock: ldab DataBytes,pcra00FAFE 54 lsrba00FAFF 37 pshba00FB00 EEFA 02D2 ldx PPAGEWAddr,pcra00FB04 19FA 02D3 leay SRecData,pcra00FB08 EC71 ProgLoop: ldd 2,y+a00FB0A 6C31 std 2,x+a00FB0C C620 ldab #PROGa00FB0E 7B01 06 stab FCMDa00FB11 C680 ldab #mFSTAT_CBEIFa00FB13 7B01 05 stab FSTATa00FB16 A7 nopa00FB17 A7 nopa00FB18 A7 nopa00FB19 A7 nopa00FB1A F601 05 ldab FSTATa00FB1D C530 bitb #mFSTAT_PVIOL+mFSTAT_ACCERRa00FB1F 2627 bne Returna00FB21 1F01 0580 brclr FSTAT,#mFSTAT_CBEIF,* 00FB25 FB a00FB26 6380 dec NumWords,spa00FB28 26DE bne ProgLoopa00FB2A 1F01 0540 brclr FSTAT,#mFSTAT_CCIF,* 00FB2E FB ;a00FB2F E6FA 02A2 ldab DataBytes,pcra00FB33 54 lsrba00FB34 6B80 stab NumWords,spa00FB36 EEFA 029C ldx PPAGEWAddr,pcra00FB3A 19FA 029D leay SRecData,pcra00FB3E EC71 VerfLoop: ldd 2,y+a00FB40 AC31 cpd 2,x+a00FB42 2604 bne Returna00FB44 6380 dec NumWords,spa00FB46 26F6 bne VerfLoop ;a00FB48 33 Return: pulba00FB49 3D rts
When I change the program so that the loop checks the CCIF-bit instead of the CBEIF, it works fine, but as this it leaves every second or every third word unprogrammed.
Note! The program is moved to RAM before executing, so the addresses in the listing will acutally be above 2000 instead of F800.
This is not so critical anymore, because I have a working version, but it would be interesting to know why the CBEIF-approach doesn't work.