MC9S12Q128 - Flash unable to programm page 3C

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

MC9S12Q128 - Flash unable to programm page 3C

2,437 Views
JadhavAj
Contributor I
Hi,
 
I am writing a Flash driver for MC9S12Q128 ( and testing on MC9S12C128 board), I am unable to programm page 0x3C ( 0x10000–0x13FFF ).
 
Code is downloaded on page 3D. Other pages are programmed without any issues.
 
Please let me know if  there are any issues with accessing page 3C .
 
Thanks.
 
Regards,
 Ajay
Labels (1)
0 Kudos
6 Replies

655 Views
kef
Specialist I
What's 0x10000-0x13FFF ? Page 0x3C corresponds to linear addresses 0xF0000-0xF3FFF.
0 Kudos

655 Views
JadhavAj
Contributor I
0x10000-0x13FFF is a relative address for page 3C in S12Q.
 
Same as page : 0x3C8000 to 0x3CBFFF
0 Kudos

655 Views
kef
Specialist I
I think you are wrong. Relative address is something new.
 
3c8000 to 3cbfff  are banked addresses. Corresponding linear addresses are F0000-F3FFF. Banked to linear conversion for S12 family is
 
PPAGE*pageSize+pageOffset
 
For example bottom of page 3C is $3C*$4000 = $F0000. The top of page 3C is $3C*$4000+$3FFF=$F3FFF
 
Banked address like 3C8000 can't have lower 16bits lower than 8000 or higher than BFFF (PPAGE window bounds). 0x10000-0x13FFF is definitely not banked address. Linear 0x10000-0x13FFF could specify some external memory, but S12Q I think doesn't have external memory bus.
 
 
0 Kudos

655 Views
Lundin
Senior Contributor IV
Kef is correct.

Though there is one circumstance where page 3C can't be programmed: when you are writing your own flash programming algorithm and running it from flash. If that's not what you are doing, you can disregard the rest of this post.

On most S12 devices with 128k, the flash is devided in two banks of 64k each. Code that writes to the flash cannot be located in the same bank as the flash it tries to access, or strange things will happen.

Pages 38, 39, 3A and 3B are located in bank 1.
Pages 3C, 3D, 3E and 3F are located in bank 0.

Now lets say you are writing a typical app and store your program in non-banked flash. The non-banked flash on 0x4000 and 0xC000 equals pages 3E and 3F. So such apps will work excellent on all pages 38-3B until it reaches 3C, where it switches bank.

This is all pretty well hidden in the manual, almost close to undocumented... everyone writing flash algorithms for S12xx128 run into this problem.
0 Kudos

655 Views
deka
Contributor II

The mentioned technique was tried on the board. But still we faced the same problem.

In our tests code was downloaded into pages 3A. Then that code was loaded to RAM from 3A page, before write/read/erase operation. After this write/eraseperformed on 3D and 3C pages. But with that even we faced the same problem in page 3C.

But the observable point during those tests was, all the write/read/erase operations were successful in 3D page whereas in 3C page all those operations failed.

In the datasheet MC9S12C128_V1.pdf (Rev 1.15  7/2005) it is mentioned that for the page 3C the "Arrary relative address" will be 0x10000 to 0x13FFF ( page no. 295). So are "Arrary relative address" and Global address different?

0 Kudos

655 Views
kef
Specialist I
Now I understand what you meant by "relative address". I understand what array relative address is, but then I wonder how you are using it? I think no compiler in the marked is aware of these "array relative addresses". You have to convert these array relative addresses to banked, to linear, or to PPAGE plus "near" 16bit CPU address.

BTW, according to the docs, C128/Q128 have single 128k flash array, not two 64k flash arrays. So probably all flash routines should run from RAM, no option to program flash array from another flash array.


Message Edited by kef on 2008-07-03 09:20 AM



Message Edited by kef on 2008-07-03 09:25 AM
0 Kudos