Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | 68HC12 | OC interrupts


Advertise Here

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

OC interrupts - Joseph D. Kay - Sep 6 20:54:00 2005

I'm having trouble getting output compare interrupt service routines to work on my s12compact board. My goal is to use the ISR to sample an analog input channel every 20us. I've done something similar on a 68HC11 board but am having trouble on the s12compact board.
Does anyone have an example of using the OC interrupts?

[Non-text portions of this message have been removed]




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )


Write to Page 3C and 3D of MC9SNE64 - luhchyuan - Sep 7 0:27:00 2005

i hav trouble writting to to the page 3C with the function i obtained
from the application note AN2720/D on metrework compiler.

(void)Flash_Write_Word( (unsigned int *far)(0x3CB000),0xCCDD);

The data 0xCCDD is written on the page 0x3DB000 instead of 0x3CB000. i use the below prm file
NAMES
END
SECTIONS
RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
/* unbanked FLASH ROM */
ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
ROM_C000 = READ_ONLY 0xC000 TO 0xF7FF;
/* banked FLASH ROM */
SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
END

PLACEMENT
_PRESTART, /* Used in HIWARE format: jump to
_Startup at the code start */
STARTUP, /* startup data structures */
ROM_VAR, /* constant variables */
STRINGS, /* string literals */
NON_BANKED,
COPY INTO ROM_C000;
DEFAULT_ROM INTO PAGE_3C,PAGE_3D;
DEFAULT_RAM INTO RAM;
END
STACKTOP 0x3FFF

What might go wrong?

Thanks for the help.

regards
Lau Luh Chyuan




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Write to Page 3C and 3D of MC9SNE64 - Gilles Blanquin - Sep 7 3:15:00 2005


Hi Lau.

The AN2720/D title is:

"A Utility for Programming Single FLASH Array HCS12 MCUs, with Minimum RAM
Overhead".
You will surely have to adapt the source code to your silicon, to properly
select flash blocks (if necessary) and program the correct flash page.

Regards,
Gilles ========================================
CodeWarrior Online Community and Support
========================================

<http://www.codewarrior.com/community> features the ability to submit and
track service requests online and to search the CodeWarrior Knowledge Base,
as well as participate in online developer forums (open to everyone).
Community: <http://www.codewarrior.com/community At 06:27 AM 9/7/2005, you wrote:
>i hav trouble writting to to the page 3C with the function i obtained
>from the application note AN2720/D on metrework compiler.
>
> (void)Flash_Write_Word( (unsigned int *far)(0x3CB000),0xCCDD);
>
>The data 0xCCDD is written on the page 0x3DB000 instead of 0x3CB000. >i use the below prm file
>NAMES
>END
>SECTIONS
>RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
> /* unbanked FLASH ROM */
> ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
> ROM_C000 = READ_ONLY 0xC000 TO 0xF7FF;
> /* banked FLASH ROM */
> SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
> ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
> PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
>END
>
>PLACEMENT
> _PRESTART, /* Used in HIWARE format: jump to
>_Startup at the code start */
> STARTUP, /* startup data structures */
> ROM_VAR, /* constant variables */
> STRINGS, /* string literals */
> NON_BANKED,
> COPY INTO ROM_C000;
> DEFAULT_ROM INTO PAGE_3C,PAGE_3D;
> DEFAULT_RAM INTO RAM;
> END
>STACKTOP 0x3FFF
>
>What might go wrong?
>
>Thanks for the help.
>
>regards
>Lau Luh Chyuan >Yahoo! Groups Links




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Write to Page 3C and 3D of MC9SNE64 - lau luh chyuan - Sep 7 3:39:00 2005

Dear Gilles,
Now i am using the evaluation version of Metrework CodeWarrior 3.1
I am using the AN2720/D document.. I can sucessfully write to the unbanked area $4000 - $8000 and $C000 to $FFFF. i just find out i cannot concurently use the page 3C and page 3D...

PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
if i set the prm file :
DEFAULT_ROM INTO PAGE_3C
when i try to write to page 0x3D
(void)Flash_Write_Word( (unsigned int *far)(0x3D8000),0xAAAA);
the data will be written to the page 0x3C.
Uder this setting, i have no problem to write to the page 0x3C

on the other hand if i set the prm file as below:
DEFAULT_ROM INTO PAGE_3D
when i try to write to page 0x3D
(void)Flash_Write_Word( (unsigned int *far)(0x3C8000),0xAAAA);
the data will be written to the page 0x3D .
i even try to hard code the ppage to 0x3C but it still go to page 0x3D
SpSub:
ldab $3C ; ldab SpSubEnd - SpSub+2, sp
stab PAGE
nop
nop
nop
tfr ccr, b ;get copy of ccr
orcc #$10 ;disable interrupts
staa FSTAT ;[PwO] register command
nop ;[0]
nop ;[0]
nop ;[0]

brclr FSTAT, CCIF, *
tfr b, ccr ;restore ccr and int condition
rtc ;back into DoOnStack in flash..
SpSubEnd:

Thanks..
Lau Luh Chyuan Gilles Blanquin <gilles.blanquin@gill...> wrote: Hi Lau.

The AN2720/D title is:

"A Utility for Programming Single FLASH Array HCS12 MCUs, with Minimum RAM
Overhead".
You will surely have to adapt the source code to your silicon, to properly
select flash blocks (if necessary) and program the correct flash page.

Regards,
Gilles ========================================
CodeWarrior Online Community and Support
========================================

<http://www.codewarrior.com/community> features the ability to submit and
track service requests online and to search the CodeWarrior Knowledge Base,
as well as participate in online developer forums (open to everyone).
Community: <http://www.codewarrior.com/community At 06:27 AM 9/7/2005, you wrote:
>i hav trouble writting to to the page 3C with the function i obtained
>from the application note AN2720/D on metrework compiler.
>
> (void)Flash_Write_Word( (unsigned int *far)(0x3CB000),0xCCDD);
>
>The data 0xCCDD is written on the page 0x3DB000 instead of 0x3CB000. >i use the below prm file
>NAMES
>END
>SECTIONS
>RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
> /* unbanked FLASH ROM */
> ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
> ROM_C000 = READ_ONLY 0xC000 TO 0xF7FF;
> /* banked FLASH ROM */
> SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
> ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
> PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
>END
>
>PLACEMENT
> _PRESTART, /* Used in HIWARE format: jump to
>_Startup at the code start */
> STARTUP, /* startup data structures */
> ROM_VAR, /* constant variables */
> STRINGS, /* string literals */
> NON_BANKED,
> COPY INTO ROM_C000;
> DEFAULT_ROM INTO PAGE_3C,PAGE_3D;
> DEFAULT_RAM INTO RAM;
> END
>STACKTOP 0x3FFF
>
>What might go wrong?
>
>Thanks for the help.
>
>regards
>Lau Luh Chyuan >Yahoo! Groups Links

---------------------------------
YAHOO! GROUPS LINKS ---------------------------------

---------------------------------
Meet your soulmate!
Yahoo! Asia presents Meetic - where millions of singles gather

[Non-text portions of this message have been removed]


______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Write to Page 3C and 3D of MC9SNE64 - Gilles Blanquin - Sep 7 3:56:00 2005

Hi Lau.

I can't see exactly what does your code.
But for sure, you cannot program the flash with an application/function
running from the same flash array/block.
As the NE64 has one single flash array, make sure your flash handling
functions are copied and executed from RAM.

Regards,
Gilles
At 09:39 AM 9/7/2005, you wrote:
>Dear Gilles,
>Now i am using the evaluation version of Metrework CodeWarrior 3.1
>I am using the AN2720/D document.. I can sucessfully write to the unbanked
>area $4000 - $8000 and $C000 to $FFFF. i just find out i cannot
>concurently use the page 3C and page 3D...
>
>PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
>if i set the prm file :
>DEFAULT_ROM INTO PAGE_3C
>when i try to write to page 0x3D
>(void)Flash_Write_Word( (unsigned int *far)(0x3D8000),0xAAAA);
>the data will be written to the page 0x3C.
>Uder this setting, i have no problem to write to the page 0x3C
>
>on the other hand if i set the prm file as below:
>DEFAULT_ROM INTO PAGE_3D
>when i try to write to page 0x3D
>(void)Flash_Write_Word( (unsigned int *far)(0x3C8000),0xAAAA);
>the data will be written to the page 0x3D .
>i even try to hard code the ppage to 0x3C but it still go to page 0x3D
>SpSub:
> ldab $3C ; ldab SpSubEnd - SpSub+2, sp
> stab PAGE
> nop
> nop
> nop
> tfr ccr, b ;get copy of ccr
> orcc #$10 ;disable
> interrupts
> staa FSTAT ;[PwO] register
> command
> nop ;[0]
> nop ;[0]
> nop ;[0]
>
> brclr FSTAT, CCIF, *
> tfr b, ccr ;restore ccr and int condition
> rtc ;back into DoOnStack in flash..
>SpSubEnd:
>
>Thanks..
>Lau Luh Chyuan >Gilles Blanquin <gilles.blanquin@gill...> wrote: >Hi Lau.
>
>The AN2720/D title is:
>
>"A Utility for Programming Single FLASH Array HCS12 MCUs, with Minimum RAM
>Overhead".
>You will surely have to adapt the source code to your silicon, to properly
>select flash blocks (if necessary) and program the correct flash page.
>
>Regards,
>Gilles >========================================
>CodeWarrior Online Community and Support
>========================================
>
><http://www.codewarrior.com/community> features the ability to submit and
>track service requests online and to search the CodeWarrior Knowledge Base,
>as well as participate in online developer forums (open to everyone).
>Community: <http://www.codewarrior.com/community >At 06:27 AM 9/7/2005, you wrote:
> >i hav trouble writting to to the page 3C with the function i obtained
> >from the application note AN2720/D on metrework compiler.
> >
> > (void)Flash_Write_Word( (unsigned int *far)(0x3CB000),0xCCDD);
> >
> >The data 0xCCDD is written on the page 0x3DB000 instead of 0x3CB000.
> >
> >
> >i use the below prm file
> >NAMES
> >END
> >SECTIONS
> >RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
> > /* unbanked FLASH ROM */
> > ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
> > ROM_C000 = READ_ONLY 0xC000 TO 0xF7FF;
> > /* banked FLASH ROM */
> > SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
> > ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
> > PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> > PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
> >END
> >
> >PLACEMENT
> > _PRESTART, /* Used in HIWARE format: jump to
> >_Startup at the code start */
> > STARTUP, /* startup data structures */
> > ROM_VAR, /* constant variables */
> > STRINGS, /* string literals */
> > NON_BANKED,
> > COPY INTO ROM_C000;
> > DEFAULT_ROM INTO PAGE_3C,PAGE_3D;
> > DEFAULT_RAM INTO RAM;
> > END
> >STACKTOP 0x3FFF
> >
> >What might go wrong?
> >
> >Thanks for the help.
> >
> >regards
> >Lau Luh Chyuan
> >
> >
> >
> >
> >
> >
> >
> >
> >Yahoo! Groups Links
> >
> >
> >
> >
>---------------------------------
>YAHOO! GROUPS LINKS >--------------------------------- >
>
>---------------------------------
>Meet your soulmate!
> Yahoo! Asia presents Meetic - where millions of singles gather
>
>[Non-text portions of this message have been removed] >Yahoo! Groups Links


______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Write to Page 3C and 3D of MC9SNE64 - lau luh chyuan - Sep 7 4:09:00 2005

Dear Gilles,
I copy the code to the ram stack and executed from the ram..after the write / erase sucessfully it return back to the flash.
For the code as below if i set the prm file as
DEFAULT_ROM INTO PAGE_3C;
Then the data 0xAABB and 0xCCDD will be written to page 0x3C,
but i expect the data 0xAABB should go to page 0x3D instead of 0x3C.

main()
{
Flash_Init(25000); // 25MHz
(void)Flash_Write_Word( (unsigned int *far)(0x3CB002),0xCCDD);
(void)Flash_Write_Word( (unsigned int *far)(0x3DB000),0xAABB);
for(;;)
{
}
}

signed char Flash_Write_Word(unsigned int *far far_address, unsigned int data)
{
unsigned int* address;
address = (unsigned int*)far_address; // strip page off
FSTAT = ( FSTAT_PVIOL_MASK | FSTAT_ACCERR_MASK); //clear error
if( (unsigned int)address & 0x0001 )
{
return Flash_Odd_Access; //aligned word?
}
if(*far_address != 0xFFFF)
{
return Flash_Not_Erased; //is erased?
}
(*address) = data; //store desired data to address being programed.
FCMD = FLASH_WORD_PROGRAM; //0x20
HWD;
(void)DoOnStack(far_address); // jsut passed frp PPAGE
if (FSTAT_ACCERR )
{
return Access_Error;
}
if( FSTAT_PVIOL )
{
return Protection_Error;
}
return 1;
}
The below is my DoOnStack function.
XDEF DoOnStack
INCLUDE 'MC9S12NE64.inc'
MY_EXTENDED_RAM: SECTION
MyCode: SECTION
CBEIF EQU $80
FSTAT_TEMP EQU $105
FCMD_TEMP EQU $106
CCIF EQU $40
PAGE_ADDR EQU $30
DoOnStack:
pshb ; save B - PPAGE
ldx #SpSubEnd-2 ; point at last word to move to stack
SpmoveLoop: ldd 2, x- ; read from flash
pshd ; move onto stack
cpx #SpSub-2 ; past end?
bne SpmoveLoop ; loop till whole sub on stack
tfr sp, x ; point to sub on stack
ldaa #CBEIF ; preload mask to register command
call 0,x,00 ; execute the sub on the stack
leas SpSubEnd - SpSub, sp ; de- allocate space ussed by sub
pulb ; restore B
rtc ; to flash where DoOnStack was called
assume banked calling function
EVEN ; Make code start word aligned
SpSub:
ldab SpSubEnd - SpSub+2, sp ;get PPAGE back //testing
stab PAGE_ADDR ;Store the PPAGE address
tfr ccr, b ;get copy of ccr
orcc #$10 ;disable interrupts
staa FSTAT_TEMP ;[PwO] register
nop ;[0]
nop ;[0]
nop ;[0]

brclr FSTAT_TEMP, CCIF, * ;[rfPPP] wait for queued commands to finish
tfr b, ccr ;restore ccr and int condition
rtc ;back into DoOnStack in flash..
SpSubEnd:

Thanks.
regards
Lau Luh Chyuan.

Gilles Blanquin <gilles.blanquin@gill...> wrote:
Hi Lau.

I can't see exactly what does your code.
But for sure, you cannot program the flash with an application/function
running from the same flash array/block.
As the NE64 has one single flash array, make sure your flash handling
functions are copied and executed from RAM.

Regards,
Gilles
At 09:39 AM 9/7/2005, you wrote:
>Dear Gilles,
>Now i am using the evaluation version of Metrework CodeWarrior 3.1
>I am using the AN2720/D document.. I can sucessfully write to the unbanked
>area $4000 - $8000 and $C000 to $FFFF. i just find out i cannot
>concurently use the page 3C and page 3D...
>
>PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
>if i set the prm file :
>DEFAULT_ROM INTO PAGE_3C
>when i try to write to page 0x3D
>(void)Flash_Write_Word( (unsigned int *far)(0x3D8000),0xAAAA);
>the data will be written to the page 0x3C.
>Uder this setting, i have no problem to write to the page 0x3C
>
>on the other hand if i set the prm file as below:
>DEFAULT_ROM INTO PAGE_3D
>when i try to write to page 0x3D
>(void)Flash_Write_Word( (unsigned int *far)(0x3C8000),0xAAAA);
>the data will be written to the page 0x3D .
>i even try to hard code the ppage to 0x3C but it still go to page 0x3D
>SpSub:
> ldab $3C ; ldab SpSubEnd - SpSub+2, sp
> stab PAGE
> nop
> nop
> nop
> tfr ccr, b ;get copy of ccr
> orcc #$10 ;disable
> interrupts
> staa FSTAT ;[PwO] register
> command
> nop ;[0]
> nop ;[0]
> nop ;[0]
>
> brclr FSTAT, CCIF, *
> tfr b, ccr ;restore ccr and int condition
> rtc ;back into DoOnStack in flash..
>SpSubEnd:
>
>Thanks..
>Lau Luh Chyuan >Gilles Blanquin <gilles.blanquin@gill...> wrote: >Hi Lau.
>
>The AN2720/D title is:
>
>"A Utility for Programming Single FLASH Array HCS12 MCUs, with Minimum RAM
>Overhead".
>You will surely have to adapt the source code to your silicon, to properly
>select flash blocks (if necessary) and program the correct flash page.
>
>Regards,
>Gilles >========================================
>CodeWarrior Online Community and Support
>========================================
>
><http://www.codewarrior.com/community> features the ability to submit and
>track service requests online and to search the CodeWarrior Knowledge Base,
>as well as participate in online developer forums (open to everyone).
>Community: <http://www.codewarrior.com/community >At 06:27 AM 9/7/2005, you wrote:
> >i hav trouble writting to to the page 3C with the function i obtained
> >from the application note AN2720/D on metrework compiler.
> >
> > (void)Flash_Write_Word( (unsigned int *far)(0x3CB000),0xCCDD);
> >
> >The data 0xCCDD is written on the page 0x3DB000 instead of 0x3CB000.
> >
> >
> >i use the below prm file
> >NAMES
> >END
> >SECTIONS
> >RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
> > /* unbanked FLASH ROM */
> > ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
> > ROM_C000 = READ_ONLY 0xC000 TO 0xF7FF;
> > /* banked FLASH ROM */
> > SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
> > ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
> > PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> > PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
> >END
> >
> >PLACEMENT
> > _PRESTART, /* Used in HIWARE format: jump to
> >_Startup at the code start */
> > STARTUP, /* startup data structures */
> > ROM_VAR, /* constant variables */
> > STRINGS, /* string literals */
> > NON_BANKED,
> > COPY INTO ROM_C000;
> > DEFAULT_ROM INTO PAGE_3C,PAGE_3D;
> > DEFAULT_RAM INTO RAM;
> > END
> >STACKTOP 0x3FFF
> >
> >What might go wrong?
> >
> >Thanks for the help.
> >
> >regards
> >Lau Luh Chyuan
> >
> >
> >
> >
> >
> >
> >
> >
> >Yahoo! Groups Links
> >
> >
> >
> >
>---------------------------------
>YAHOO! GROUPS LINKS >--------------------------------- >
>
>---------------------------------
>Meet your soulmate!
> Yahoo! Asia presents Meetic - where millions of singles gather
>
>[Non-text portions of this message have been removed] >Yahoo! Groups Links

SPONSORED LINKS
Freescale semiconductor inc Microcontrollers Pic microcontrollers 8051 microprocessor

---------------------------------
YAHOO! GROUPS LINKS ---------------------------------

---------------------------------
Meet your soulmate!
Yahoo! Asia presents Meetic - where millions of singles gather

[Non-text portions of this message have been removed]




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Write to Page 3C and 3D of MC9SNE64 - Gilles Blanquin - Sep 7 4:36:00 2005

Lau,

The .prm file setup has no relation with your programming location.
What is setup in the .prm file is your project application location at
download time to onchip flash.

The debugger actually programs to flash (by default, when the project is
created with the Wizard) your application according to the Wizard generated
.prm file. You don't even need to change the .prm file.

If now, you want that your application is able to flash some new data, you
can use the AN runtimes to do so, but make sure to program to a blank location.

"(void)Flash_Write_Word( (unsigned int *far)(0x3CB002),0xCCDD);" programs
0xCCDD at location 0x3CB002, i.e. page 0x3C, address 0xB002 (flash bank
window).

This place should therefore be empty.

IF you set "DEFAULT_ROM INTO PAGE_3C;", then make sure to program in page
0x3D, for example.
page 0x3E is mirrored in0x4000-0x7FFF and page 0x3F is mirrored in
0xC000-0xFFFF, ranges that might be defined and used in the project/.prm
for non banked code, like startup and ISR's.

Regards,
Gilles
At 10:09 AM 9/7/2005, you wrote:
>Dear Gilles,
>I copy the code to the ram stack and executed from the ram..after the
>write / erase sucessfully it return back to the flash.
>For the code as below if i set the prm file as
>DEFAULT_ROM INTO PAGE_3C;
>Then the data 0xAABB and 0xCCDD will be written to page 0x3C,
>but i expect the data 0xAABB should go to page 0x3D instead of 0x3C.
>
>main()
>{
> Flash_Init(25000); // 25MHz
> (void)Flash_Write_Word( (unsigned int *far)(0x3CB002),0xCCDD);
> (void)Flash_Write_Word( (unsigned int *far)(0x3DB000),0xAABB);
> for(;;)
> {
> }
>}
>
>signed char Flash_Write_Word(unsigned int *far far_address, unsigned int data)
>{
> unsigned int* address;
> address = (unsigned int*)far_address; // strip page off
> FSTAT = ( FSTAT_PVIOL_MASK | FSTAT_ACCERR_MASK); //clear error
> if( (unsigned int)address & 0x0001 )
> {
> return Flash_Odd_Access; //aligned word?
> }
> if(*far_address != 0xFFFF)
> {
> return Flash_Not_Erased; //is erased?
> }
> (*address) = data; //store desired data to address being programed.
> FCMD = FLASH_WORD_PROGRAM; //0x20
> HWD;
> (void)DoOnStack(far_address); // jsut passed frp PPAGE
> if (FSTAT_ACCERR )
> {
> return Access_Error;
> }
> if( FSTAT_PVIOL )
> {
> return Protection_Error;
> }
> return 1;
>}
>The below is my DoOnStack function.
>XDEF DoOnStack
>INCLUDE 'MC9S12NE64.inc'
>MY_EXTENDED_RAM: SECTION
>MyCode: SECTION
>CBEIF EQU $80
>FSTAT_TEMP EQU $105
>FCMD_TEMP EQU $106
>CCIF EQU $40
>PAGE_ADDR EQU $30
>DoOnStack:
> pshb ; save B - PPAGE
> ldx #SpSubEnd-2 ; point at last word to move to stack
>SpmoveLoop: ldd 2, x- ; read from flash
> pshd ; move onto stack
> cpx #SpSub-2 ; past end?
> bne SpmoveLoop ; loop till whole sub on stack
> tfr sp, x ; point to sub on stack
> ldaa #CBEIF ; preload mask to register command
> call 0,x,00 ; execute the sub on the stack
> leas SpSubEnd - SpSub, sp ; de- allocate space ussed by sub
> pulb ; restore B
> rtc ; to flash where DoOnStack was
> called
> assume banked calling
> function
> EVEN ; Make code start word
> aligned
>SpSub:
> ldab SpSubEnd - SpSub+2, sp ;get PPAGE back //testing
> stab PAGE_ADDR ;Store the PPAGE address
> tfr ccr, b ;get copy of ccr
> orcc #$10 ;disable
> interrupts
> staa FSTAT_TEMP ;[PwO]
> register
> nop ;[0]
> nop ;[0]
>
nop ;[0]
>
> brclr FSTAT_TEMP, CCIF, * ;[rfPPP] wait for queued commands to finish
> tfr b, ccr ;restore ccr and int condition
> rtc ;back into DoOnStack in flash..
>SpSubEnd:
>
>Thanks.
>regards
>Lau Luh Chyuan.
>
>Gilles Blanquin <gilles.blanquin@gill...> wrote:
>Hi Lau.
>
>I can't see exactly what does your code.
>But for sure, you cannot program the flash with an application/function
>running from the same flash array/block.
>As the NE64 has one single flash array, make sure your flash handling
>functions are copied and executed from RAM.
>
>Regards,
>Gilles >
>At 09:39 AM 9/7/2005, you wrote:
> >Dear Gilles,
> >Now i am using the evaluation version of Metrework CodeWarrior 3.1
> >I am using the AN2720/D document.. I can sucessfully write to the unbanked
> >area $4000 - $8000 and $C000 to $FFFF. i just find out i cannot
> >concurently use the page 3C and page 3D...
> >
> >PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> > PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
> >if i set the prm file :
> >DEFAULT_ROM INTO PAGE_3C
> >when i try to write to page 0x3D
> >(void)Flash_Write_Word( (unsigned int *far)(0x3D8000),0xAAAA);
> >the data will be written to the page 0x3C.
> >Uder this setting, i have no problem to write to the page 0x3C
> >
> >on the other hand if i set the prm file as below:
> >DEFAULT_ROM INTO PAGE_3D
> >when i try to write to page 0x3D
> >(void)Flash_Write_Word( (unsigned int *far)(0x3C8000),0xAAAA);
> >the data will be written to the page 0x3D .
> >i even try to hard code the ppage to 0x3C but it still go to page 0x3D
> >SpSub:
> > ldab $3C ; ldab SpSubEnd - SpSub+2, sp
> > stab PAGE
> > nop
> > nop
> > nop
> > tfr ccr, b ;get copy of ccr
> > orcc #$10 ;disable
> > interrupts
> > staa FSTAT ;[PwO] register
> > command
> > nop ;[0]
> > nop ;[0]
> > nop ;[0]
> >
> > brclr FSTAT, CCIF, *
> > tfr b, ccr ;restore ccr and int condition
> > rtc ;back into DoOnStack in flash..
> >SpSubEnd:
> >
> >Thanks..
> >Lau Luh Chyuan
> >
> >
> >Gilles Blanquin <gilles.blanquin@gill...> wrote:
> >
> >
> >Hi Lau.
> >
> >The AN2720/D title is:
> >
> >"A Utility for Programming Single FLASH Array HCS12 MCUs, with Minimum RAM
> >Overhead".
> >You will surely have to adapt the source code to your silicon, to properly
> >select flash blocks (if necessary) and program the correct flash page.
> >
> >Regards,
> >Gilles
> >
> >
> >========================================
> >CodeWarrior Online Community and Support
> >========================================
> >
> ><http://www.codewarrior.com/community> features the ability to submit and
> >track service requests online and to search the CodeWarrior Knowledge Base,
> >as well as participate in online developer forums (open to everyone).
> >Community: <http://www.codewarrior.com/community>
> >
> >
> >At 06:27 AM 9/7/2005, you wrote:
> > >i hav trouble writting to to the page 3C with the function i obtained
> > >from the application note AN2720/D on metrework compiler.
> > >
> > > (void)Flash_Write_Word( (unsigned int *far)(0x3CB000),0xCCDD);
> > >
> > >The data 0xCCDD is written on the page 0x3DB000 instead of 0x3CB000.
> > >
> > >
> > >i use the below prm file
> > >NAMES
> > >END
> > >SECTIONS
> > >RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
> > > /* unbanked FLASH ROM */
> > > ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
> > > ROM_C000 = READ_ONLY 0xC000 TO 0xF7FF;
> > > /* banked FLASH ROM */
> > > SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
> > > ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
> > > PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> > > PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
> > >END
> > >
> > >PLACEMENT
> > > _PRESTART, /* Used in HIWARE format: jump to
> > >_Startup at the code start */
> > > STARTUP, /* startup data structures */
> > > ROM_VAR, /* constant variables */
> > > STRINGS, /* string literals */
> > > NON_BANKED,
> > > COPY INTO ROM_C000;
> > > DEFAULT_ROM INTO PAGE_3C,PAGE_3D;
> > > DEFAULT_RAM INTO RAM;
> > > END
> > >STACKTOP 0x3FFF
> > >
> > >What might go wrong?
> > >
> > >Thanks for the help.
> > >
> > >regards
> > >Lau Luh Chyuan
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >Yahoo! Groups Links
> > >
> > >
> > >
> > >
> >
> >
> >
> >---------------------------------
> >YAHOO! GROUPS LINKS
> >
> >
> >
> >
> >
> >---------------------------------
> >
> >
> >
> >
> >---------------------------------
> >Meet your soulmate!
> > Yahoo! Asia presents Meetic - where millions of singles gather
> >
> >[Non-text portions of this message have been removed]
> >
> >
> >
> >
> >
> >Yahoo! Groups Links
> >
> >
> >
> >
>SPONSORED LINKS
>Freescale semiconductor inc Microcontrollers Pic microcontrollers 8051
>microprocessor
>
>---------------------------------
>YAHOO! GROUPS LINKS >--------------------------------- >
>
>---------------------------------
>Meet your soulmate!
> Yahoo! Asia presents Meetic - where millions of singles gather
>
>[Non-text portions of this message have been removed] >Yahoo! Groups Links




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Write to Page 3C and 3D of MC9SNE64 - lau luh chyuan - Sep 7 4:57:00 2005

Dear Gilles,
I everytime make sure both the page 0x3d and page 0x3c is empty before i am writting new data. I found out i hav banked memory problem of page 3D and page 3C. The NE64 should have 64k of flash (0x3C, 0x3D, 0x3E, 0x3F) to be used right.. I do a testing with the following setting .I put the DEFAULT_ROM to page 0x3C and STRINGS to page 0x3D. I go to view the memory map .I found out actually the page 0x3D is all 0xFF the STRINGS data is not successfully written to the page 0x3D.But The DEFAULT_ROM data is successfully go to page 0x3C.
It seem like i actually can't use the page 0x3C and page 0x3D concurrently.

The following is my prm file..
NAMES
END
SECTIONS

RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
/* unbanked FLASH ROM */
ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
ROM_C000 = READ_ONLY 0xC000 TO 0xF7FF;
/* banked FLASH ROM */
SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
END
PLACEMENT
_PRESTART, /* Used in HIWARE format: jump to _Startup at the code start */
STARTUP, /* startup data structures */
ROM_VAR, /* constant variables */
NON_BANKED, /* runtime routines which must not be banked */
COPY /* copy down information: how to initialize variables */
INTO ROM_C000;
STRINGS INTO PAGE_3C;
DEFAULT_ROM INTO PAGE_3D;
DEFAULT_RAM INTO RAM;
END
STACKTOP 0x3FFF
Thanks
Lau Luh Chyuan Gilles Blanquin <gilles.blanquin@gill...> wrote:
Lau,

The .prm file setup has no relation with your programming location.
What is setup in the .prm file is your project application location at
download time to onchip flash.

The debugger actually programs to flash (by default, when the project is
created with the Wizard) your application according to the Wizard generated
.prm file. You don't even need to change the .prm file.

If now, you want that your application is able to flash some new data, you
can use the AN runtimes to do so, but make sure to program to a blank location.

"(void)Flash_Write_Word( (unsigned int *far)(0x3CB002),0xCCDD);" programs
0xCCDD at location 0x3CB002, i.e. page 0x3C, address 0xB002 (flash bank
window).

This place should therefore be empty.

IF you set "DEFAULT_ROM INTO PAGE_3C;", then make sure to program in page
0x3D, for example.
page 0x3E is mirrored in0x4000-0x7FFF and page 0x3F is mirrored in
0xC000-0xFFFF, ranges that might be defined and used in the project/.prm
for non banked code, like startup and ISR's.

Regards,
Gilles
At 10:09 AM 9/7/2005, you wrote:
>Dear Gilles,
>I copy the code to the ram stack and executed from the ram..after the
>write / erase sucessfully it return back to the flash.
>For the code as below if i set the prm file as
>DEFAULT_ROM INTO PAGE_3C;
>Then the data 0xAABB and 0xCCDD will be written to page 0x3C,
>but i expect the data 0xAABB should go to page 0x3D instead of 0x3C.
>
>main()
>{
> Flash_Init(25000); // 25MHz
> (void)Flash_Write_Word( (unsigned int *far)(0x3CB002),0xCCDD);
> (void)Flash_Write_Word( (unsigned int *far)(0x3DB000),0xAABB);
> for(;;)
> {
> }
>}
>
>signed char Flash_Write_Word(unsigned int *far far_address, unsigned int data)
>{
> unsigned int* address;
> address = (unsigned int*)far_address; // strip page off
> FSTAT = ( FSTAT_PVIOL_MASK | FSTAT_ACCERR_MASK); //clear error
> if( (unsigned int)address & 0x0001 )
> {
> return Flash_Odd_Access; //aligned word?
> }
> if(*far_address != 0xFFFF)
> {
> return Flash_Not_Erased; //is erased?
> }
> (*address) = data; //store desired data to address being programed.
> FCMD = FLASH_WORD_PROGRAM; //0x20
> HWD;
> (void)DoOnStack(far_address); // jsut passed frp PPAGE
> if (FSTAT_ACCERR )
> {
> return Access_Error;
> }
> if( FSTAT_PVIOL )
> {
> return Protection_Error;
> }
> return 1;
>}
>The below is my DoOnStack function.
>XDEF DoOnStack
>INCLUDE 'MC9S12NE64.inc'
>MY_EXTENDED_RAM: SECTION
>MyCode: SECTION
>CBEIF EQU $80
>FSTAT_TEMP EQU $105
>FCMD_TEMP EQU $106
>CCIF EQU $40
>PAGE_ADDR EQU $30
>DoOnStack:
> pshb ; save B - PPAGE
> ldx #SpSubEnd-2 ; point at last word to move to stack
>SpmoveLoop: ldd 2, x- ; read from flash
> pshd ; move onto stack
> cpx #SpSub-2 ; past end?
> bne SpmoveLoop ; loop till whole sub on stack
> tfr sp, x ; point to sub on stack
> ldaa #CBEIF ; preload mask to register command
> call 0,x,00 ; execute the sub on the stack
> leas SpSubEnd - SpSub, sp ; de- allocate space ussed by sub
> pulb ; restore B
> rtc ; to flash where DoOnStack was
> called
> assume banked calling
> function
> EVEN ; Make code start word
> aligned
>SpSub:
> ldab SpSubEnd - SpSub+2, sp ;get PPAGE back //testing
> stab PAGE_ADDR ;Store the PPAGE address
> tfr ccr, b ;get copy of ccr
> orcc #$10 ;disable
> interrupts
> staa FSTAT_TEMP ;[PwO]
> register
> nop ;[0]
> nop ;[0]
>
nop ;[0]
>
> brclr FSTAT_TEMP, CCIF, * ;[rfPPP] wait for queued commands to finish
> tfr b, ccr ;restore ccr and int condition
> rtc ;back into DoOnStack in flash..
>SpSubEnd:
>
>Thanks.
>regards
>Lau Luh Chyuan.
>
>Gilles Blanquin <gilles.blanquin@gill...> wrote:
>Hi Lau.
>
>I can't see exactly what does your code.
>But for sure, you cannot program the flash with an application/function
>running from the same flash array/block.
>As the NE64 has one single flash array, make sure your flash handling
>functions are copied and executed from RAM.
>
>Regards,
>Gilles >
>At 09:39 AM 9/7/2005, you wrote:
> >Dear Gilles,
> >Now i am using the evaluation version of Metrework CodeWarrior 3.1
> >I am using the AN2720/D document.. I can sucessfully write to the unbanked
> >area $4000 - $8000 and $C000 to $FFFF. i just find out i cannot
> >concurently use the page 3C and page 3D...
> >
> >PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> > PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
> >if i set the prm file :
> >DEFAULT_ROM INTO PAGE_3C
> >when i try to write to page 0x3D
> >(void)Flash_Write_Word( (unsigned int *far)(0x3D8000),0xAAAA);
> >the data will be written to the page 0x3C.
> >Uder this setting, i have no problem to write to the page 0x3C
> >
> >on the other hand if i set the prm file as below:
> >DEFAULT_ROM INTO PAGE_3D
> >when i try to write to page 0x3D
> >(void)Flash_Write_Word( (unsigned int *far)(0x3C8000),0xAAAA);
> >the data will be written to the page 0x3D .
> >i even try to hard code the ppage to 0x3C but it still go to page 0x3D
> >SpSub:
> > ldab $3C ; ldab SpSubEnd - SpSub+2, sp
> > stab PAGE
> > nop
> > nop
> > nop
> > tfr ccr, b ;get copy of ccr
> > orcc #$10 ;disable
> > interrupts
> > staa FSTAT ;[PwO] register
> > command
> > nop ;[0]
> > nop ;[0]
> > nop ;[0]
> >
> > brclr FSTAT, CCIF, *
> > tfr b, ccr ;restore ccr and int condition
> > rtc ;back into DoOnStack in flash..
> >SpSubEnd:
> >
> >Thanks..
> >Lau Luh Chyuan
> >
> >
> >Gilles Blanquin <gilles.blanquin@gill...> wrote:
> >
> >
> >Hi Lau.
> >
> >The AN2720/D title is:
> >
> >"A Utility for Programming Single FLASH Array HCS12 MCUs, with Minimum RAM
> >Overhead".
> >You will surely have to adapt the source code to your silicon, to properly
> >select flash blocks (if necessary) and program the correct flash page.
> >
> >Regards,
> >Gilles
> >
> >
> >========================================
> >CodeWarrior Online Community and Support
> >========================================
> >
> ><http://www.codewarrior.com/community> features the ability to submit and
> >track service requests online and to search the CodeWarrior Knowledge Base,
> >as well as participate in online developer forums (open to everyone).
> >Community: <http://www.codewarrior.com/community>
> >
> >
> >At 06:27 AM 9/7/2005, you wrote:
> > >i hav trouble writting to to the page 3C with the function i obtained
> > >from the application note AN2720/D on metrework compiler.
> > >
> > > (void)Flash_Write_Word( (unsigned int *far)(0x3CB000),0xCCDD);
> > >
> > >The data 0xCCDD is written on the page 0x3DB000 instead of 0x3CB000.
> > >
> > >
> > >i use the below prm file
> > >NAMES
> > >END
> > >SECTIONS
> > >RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
> > > /* unbanked FLASH ROM */
> > > ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
> > > ROM_C000 = READ_ONLY 0xC000 TO 0xF7FF;
> > > /* banked FLASH ROM */
> > > SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
> > > ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
> > > PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> > > PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
> > >END
> > >
> > >PLACEMENT
> > > _PRESTART, /* Used in HIWARE format: jump to
> > >_Startup at the code start */
> > > STARTUP, /* startup data structures */
> > > ROM_VAR, /* constant variables */
> > > STRINGS, /* string literals */
> > > NON_BANKED,
> > > COPY INTO ROM_C000;
> > > DEFAULT_ROM INTO PAGE_3C,PAGE_3D;
> > > DEFAULT_RAM INTO RAM;
> > > END
> > >STACKTOP 0x3FFF
> > >
> > >What might go wrong?
> > >
> > >Thanks for the help.
> > >
> > >regards
> > >Lau Luh Chyuan
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >Yahoo! Groups Links
> > >
> > >
> > >
> > >
> >
> >
> >
> >---------------------------------
> >YAHOO! GROUPS LINKS
> >
> >
> >
> >
> >
> >---------------------------------
> >
> >
> >
> >
> >---------------------------------
> >Meet your soulmate!
> > Yahoo! Asia presents Meetic - where millions of singles gather
> >
> >[Non-text portions of this message have been removed]
> >
> >
> >
> >
> >
> >Yahoo! Groups Links
> >
> >
> >
> >
>SPONSORED LINKS
>Freescale semiconductor inc Microcontrollers Pic microcontrollers 8051
>microprocessor
>
>---------------------------------
>YAHOO! GROUPS LINKS >--------------------------------- >
>
>---------------------------------
>Meet your soulmate!
> Yahoo! Asia presents Meetic - where millions of singles gather
>
>[Non-text portions of this message have been removed] >Yahoo! Groups Links

SPONSORED LINKS
Freescale semiconductor inc Microcontrollers Pic microcontrollers 8051 microprocessor

---------------------------------
YAHOO! GROUPS LINKS ---------------------------------

---------------------------------
Meet your soulmate!
Yahoo! Asia presents Meetic - where millions of singles gather

[Non-text portions of this message have been removed]




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: Write to Page 3C and 3D of MC9SNE64 - Gilles Blanquin - Sep 7 5:55:00 2005


Lau,

The default placement is as below and places STRINGS in non banked above $C000.

If you want to locate exactly your STRINGS, I propose you to define:

ROM_STRINGS = READ_ONLY 0xC000 TO 0xCFFF;
ROM_D000 = READ_ONLY 0xD000 TO 0xFEFF;

Then replace in default .prm here below ROM_C000 by ROM_D000.

Then you can have, as placement: "STRINGS INTO ROM_STRINGS;"

Please check also the ".map" file generated in the "bin" folder of your
project.

Regards,
Gilles PLACEMENT
_PRESTART, /* Used in HIWARE format: jump to
_Startup at the code start */
STARTUP, /* startup data structures */
ROM_VAR, /* constant variables */
STRINGS, /* string literals */
VIRTUAL_TABLE_SEGMENT, /* C++ virtual table segment */
DEFAULT_ROM, NON_BANKED , /* runtime routines which
must not be banked */
COPY /* copy down information: how to
initialize variables */
INTO ROM_C000;
OTHER_ROM INTO PAGE_3C,PAGE_3D,PAGE_3E;
DEFAULT_RAM INTO RAM;
END At 10:57 AM 9/7/2005, you wrote:
>Dear Gilles,
>I everytime make sure both the page 0x3d and page 0x3c is empty before i
>am writting new data. I found out i hav banked memory problem of page 3D
>and page 3C. The NE64 should have 64k of flash (0x3C, 0x3D, 0x3E, 0x3F) to
>be used right.. I do a testing with the following setting .I put the
>DEFAULT_ROM to page 0x3C and STRINGS to page 0x3D. I go to view the memory
>map .I found out actually the page 0x3D is all 0xFF the STRINGS data is
>not successfully written to the page 0x3D.But The DEFAULT_ROM data is
>successfully go to page 0x3C.
>It seem like i actually can't use the page 0x3C and page 0x3D concurrently.
>
>The following is my prm file..
>NAMES
>END
>SECTIONS
>
> RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
> /* unbanked FLASH ROM */
> ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
> ROM_C000 = READ_ONLY 0xC000 TO 0xF7FF;
> /* banked FLASH ROM */
> SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
> ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
> PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
>END
>PLACEMENT
> _PRESTART, /* Used in HIWARE format: jump to
> _Startup at the code start */
> STARTUP, /* startup data structures */
> ROM_VAR, /* constant variables */
> NON_BANKED, /* runtime routines which must not be
> banked */
> COPY /* copy down information: how to initialize
> variables */
> INTO ROM_C000;
> STRINGS INTO PAGE_3C;
> DEFAULT_ROM INTO PAGE_3D;
> DEFAULT_RAM INTO RAM;
> END
>STACKTOP 0x3FFF
>Thanks
>Lau Luh Chyuan >Gilles Blanquin <gilles.blanquin@gill...> wrote:
>Lau,
>
>The .prm file setup has no relation with your programming location.
>What is setup in the .prm file is your project application location at
>download time to onchip flash.
>
>The debugger actually programs to flash (by default, when the project is
>created with the Wizard) your application according to the Wizard generated
>.prm file. You don't even need to change the .prm file.
>
>If now, you want that your application is able to flash some new data, you
>can use the AN runtimes to do so, but make sure to program to a blank
>location.
>
>"(void)Flash_Write_Word( (unsigned int *far)(0x3CB002),0xCCDD);" programs
>0xCCDD at location 0x3CB002, i.e. page 0x3C, address 0xB002 (flash bank
>window).
>
>This place should therefore be empty.
>
>IF you set "DEFAULT_ROM INTO PAGE_3C;", then make sure to program in page
>0x3D, for example.
>page 0x3E is mirrored in0x4000-0x7FFF and page 0x3F is mirrored in
>0xC000-0xFFFF, ranges that might be defined and used in the project/.prm
>for non banked code, like startup and ISR's.
>
>Regards,
>Gilles >
>At 10:09 AM 9/7/2005, you wrote:
> >Dear Gilles,
> >I copy the code to the ram stack and executed from the ram..after the
> >write / erase sucessfully it return back to the flash.
> >For the code as below if i set the prm file as
> >DEFAULT_ROM INTO PAGE_3C;
> >Then the data 0xAABB and 0xCCDD will be written to page 0x3C,
> >but i expect the data 0xAABB should go to page 0x3D instead of 0x3C.
> >
> >main()
> >{
> > Flash_Init(25000); // 25MHz
> > (void)Flash_Write_Word( (unsigned int *far)(0x3CB002),0xCCDD);
> > (void)Flash_Write_Word( (unsigned int *far)(0x3DB000),0xAABB);
> > for(;;)
> > {
> > }
> >}
> >
> >signed char Flash_Write_Word(unsigned int *far far_address, unsigned int
> data)
> >{
> > unsigned int* address;
> > address = (unsigned int*)far_address; // strip page off
> > FSTAT = ( FSTAT_PVIOL_MASK | FSTAT_ACCERR_MASK); //clear error
> > if( (unsigned int)address & 0x0001 )
> > {
> > return Flash_Odd_Access; //aligned word?
> > }
> > if(*far_address != 0xFFFF)
> > {
> > return Flash_Not_Erased; //is erased?
> > }
> > (*address) = data; //store desired data to address being programed.
> > FCMD = FLASH_WORD_PROGRAM; //0x20
> > HWD;
> > (void)DoOnStack(far_address); // jsut passed frp PPAGE
> > if (FSTAT_ACCERR )
> > {
> > return Access_Error;
> > }
> > if( FSTAT_PVIOL )
> > {
> > return Protection_Error;
> > }
> > return 1;
> >}
> >The below is my DoOnStack function.
> >XDEF DoOnStack
> >INCLUDE 'MC9S12NE64.inc'
> >MY_EXTENDED_RAM: SECTION
> >MyCode: SECTION
> >CBEIF EQU $80
> >FSTAT_TEMP EQU $105
> >FCMD_TEMP EQU $106
> >CCIF EQU $40
> >PAGE_ADDR EQU $30
> >DoOnStack:
> > pshb ; save B - PPAGE
> > ldx #SpSubEnd-2 ; point at last word to move to stack
> >SpmoveLoop: ldd 2, x- ; read from flash
> > pshd ; move onto stack
> > cpx #SpSub-2 ; past end?
> > bne SpmoveLoop ; loop till whole sub on stack
> > tfr sp, x ; point to sub on stack
> > ldaa #CBEIF ; preload mask to register command
> > call 0,x,00 ; execute the sub on the stack
> > leas SpSubEnd - SpSub, sp ; de- allocate space ussed by sub
> > pulb ; restore B
> > rtc ; to flash where DoOnStack was
> > called
> > assume banked calling
> > function
> > EVEN ; Make code start word
> > aligned
> >SpSub:
> > ldab SpSubEnd - SpSub+2, sp ;get PPAGE back //testing
> > stab PAGE_ADDR ;Store the PPAGE address
> > tfr ccr, b ;get copy of ccr
> > orcc #$10 ;disable
> > interrupts
> > staa FSTAT_TEMP ;[PwO]
> > register
> > nop ;[0]
> > nop ;[0]
> >
> nop ;[0]
> >
> > brclr FSTAT_TEMP, CCIF, * ;[rfPPP] wait for queued commands to
> finish
> > tfr b, ccr ;restore ccr and int condition
> > rtc ;back into DoOnStack in flash..
> >SpSubEnd:
> >
> >Thanks.
> >regards
> >Lau Luh Chyuan.
> >
> >Gilles Blanquin <gilles.blanquin@gill...> wrote:
> >Hi Lau.
> >
> >I can't see exactly what does your code.
> >But for sure, you cannot program the flash with an application/function
> >running from the same flash array/block.
> >As the NE64 has one single flash array, make sure your flash handling
> >functions are copied and executed from RAM.
> >
> >Regards,
> >Gilles
> >
> >
> >
> >At 09:39 AM 9/7/2005, you wrote:
> > >Dear Gilles,
> > >Now i am using the evaluation version of Metrework CodeWarrior 3.1
> > >I am using the AN2720/D document.. I can sucessfully write to the unbanked
> > >area $4000 - $8000 and $C000 to $FFFF. i just find out i cannot
> > >concurently use the page 3C and page 3D...
> > >
> > >PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> > > PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
> > >if i set the prm file :
> > >DEFAULT_ROM INTO PAGE_3C
> > >when i try to write to page 0x3D
> > >(void)Flash_Write_Word( (unsigned int *far)(0x3D8000),0xAAAA);
> > >the data will be written to the page 0x3C.
> > >Uder this setting, i have no problem to write to the page 0x3C
> > >
> > >on the other hand if i set the prm file as below:
> > >DEFAULT_ROM INTO PAGE_3D
> > >when i try to write to page 0x3D
> > >(void)Flash_Write_Word( (unsigned int *far)(0x3C8000),0xAAAA);
> > >the data will be written to the page 0x3D .
> > >i even try to hard code the ppage to 0x3C but it still go to page 0x3D
> > >SpSub:
> > > ldab $3C ; ldab SpSubEnd - SpSub+2, sp
> > > stab PAGE
> > > nop
> > > nop
> > > nop
> > > tfr ccr, b ;get copy of ccr
> > > orcc #$10 ;disable
> > > interrupts
> > > staa FSTAT ;[PwO] register
> > > command
> > > nop ;[0]
> > > nop ;[0]
> > > nop ;[0]
> > >
> > > brclr FSTAT, CCIF, *
> > > tfr b, ccr ;restore ccr and int condition
> > > rtc ;back into DoOnStack in flash..
> > >SpSubEnd:
> > >
> > >Thanks..
> > >Lau Luh Chyuan
> > >
> > >
> > >Gilles Blanquin <gilles.blanquin@gill...> wrote:
> > >
> > >
> > >Hi Lau.
> > >
> > >The AN2720/D title is:
> > >
> > >"A Utility for Programming Single FLASH Array HCS12 MCUs, with Minimum RAM
> > >Overhead".
> > >You will surely have to adapt the source code to your silicon, to properly
> > >select flash blocks (if necessary) and program the correct flash page.
> > >
> > >Regards,
> > >Gilles
> > >
> > >
> > >========================================
> > >CodeWarrior Online Community and Support
> > >========================================
> > >
> > ><http://www.codewarrior.com/community> features the ability to submit and
> > >track service requests online and to search the CodeWarrior Knowledge
> Base,
> > >as well as participate in online developer forums (open to everyone).
> > >Community: <http://www.codewarrior.com/community>
> > >
> > >
> > >At 06:27 AM 9/7/2005, you wrote:
> > > >i hav trouble writting to to the page 3C with the function i obtained
> > > >from the application note AN2720/D on metrework compiler.
> > > >
> > > > (void)Flash_Write_Word( (unsigned int *far)(0x3CB000),0xCCDD);
> > > >
> > > >The data 0xCCDD is written on the page 0x3DB000 instead of 0x3CB000.
> > > >
> > > >
> > > >i use the below prm file
> > > >NAMES
> > > >END
> > > >SECTIONS
> > > >RAM = READ_WRITE 0x3200 TO 0x3FFE; /* BUFMAP = 4 (1.5K) */
> > > > /* unbanked FLASH ROM */
> > > > ROM_4000 = READ_ONLY 0x4000 TO 0x7FFF; /* 16K */
> > > > ROM_C000 = READ_ONLY 0xC000 TO 0xF7FF;
> > > > /* banked FLASH ROM */
> > > > SECURITY = READ_ONLY 0xFF00 TO 0xFF0F;
> > > > ROM_FF10 = READ_ONLY 0xFF10 TO 0xFF7F;
> > > > PAGE_3D = READ_ONLY 0x3D8000 TO 0x3DBFFF;
> > > > PAGE_3C = READ_ONLY 0x3C8000 TO 0x3CBFFF;
> > > >END
> > > >
> > > >PLACEMENT
> > > > _PRESTART, /* Used in HIWARE format: jump to
> > > >_Startup at the code start */
> > > > STARTUP, /* startup data structures */
> > > > ROM_VAR, /* constant variables */
> > > > STRINGS, /* string literals */
> > > > NON_BANKED,
> > > > COPY INTO ROM_C000;
> > > > DEFAULT_ROM INTO PAGE_3C,PAGE_3D;
> > > > DEFAULT_RAM INTO RAM;
> > > > END
> > > >STACKTOP 0x3FFF
> > > >
> > > >What might go wrong?
> > > >
> > > >Thanks for the help.
> > > >
> > > >regards
> > > >Lau Luh Chyuan
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >---------------------------------
> > >YAHOO! GROUPS LINKS
> > >
> > >
> > >
> > >
> > >
> > >---------------------------------
> > >
> > >
> > >
> > >
> > >---------------------------------
> > >Meet your soulmate!
> > > Yahoo! Asia presents Meetic - where millions of singles gather
> > >
> > >[Non-text portions of this message have been removed]
> > >
> > >
> > >
> > >
> > >
> > >Yahoo! Groups Links
> > >
> > >
> > >
> > >
> >
> >
> >
> >SPONSORED LINKS
> >Freescale semiconductor inc Microcontrollers Pic microcontrollers 8051
> >microprocessor
> >
> >---------------------------------
> >YAHOO! GROUPS LINKS
> >
> >
> >
> >
> >
> >---------------------------------
> >
> >
> >
> >
> >---------------------------------
> >Meet your soulmate!
> > Yahoo! Asia presents Meetic - where millions of singles gather
> >
> >[Non-text portions of this message have been removed]
> >
> >
> >
> >
> >
> >Yahoo! Groups Links
> >
> >
> >
> >
>SPONSORED LINKS
>Freescale semiconductor inc Microcontrollers Pic microcontrollers 8051
>microprocessor
>
>---------------------------------
>YAHOO! GROUPS LINKS >--------------------------------- >
>
>---------------------------------
>Meet your soulmate!
> Yahoo! Asia presents Meetic - where millions of singles gather
>
>[Non-text portions of this message have been removed] >Yahoo! Groups Links




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )