Reply by risha April 8, 20052005-04-08
"Michael N. Moran" <mnmoran@bellsouth.net> wrote in message news:<x895e.30954$vL3.24650@bignews4.bellsouth.net>...
> risha wrote: > > " > >>IANALL, but ulvald is never used, and it is not volatile, > >>and therefore the compiler likely performs an optimisation > >>never setting its value. > >> > > > > first i wanted to check that the value is in the debugger memory > > window should display correctly which is not happening first the > > varaible ucvald should be initialized to 0 which shows a junk value on > > execution of the stmt then the value at the particular location which > > is passed as a parameter should read the value at the location > > [(0x8020)which is actually 0x03 in my case]so the value in the memory > > window should have displayed 0x03 which shows junk value again. > > If you want to prevent the compiler from eliminating > useless expressions, then you will need to declare the > variables as "volatile". Try this: > > void FlashReadM(volatile unsigned long *fl_ad,unsigned long abb) > { > volatile unsigned long ulvald; // note volatile qualifier > abb=2; // This will be eliminated since abb is a local copy. > ulvald=0; // Now that uvald is volatile, this will show. > ulvald= *(fl_ad); > }
thank you for your time and help. It is really great, now the ulvald value does get initialized to 0 initially but the next line i.e. ulvald=*(fl_ad);does not show the correct value 03, it shows junk value. It should have copied the value at fl_ad into the variable ulvald right? The value 03 value is not displayed at this location. NOTE: 0x8020 address is passed as a parameter(fl_ad) to the function FlashReadM and contains the value as 03(at this location 0x8020) regards,
Reply by Michael N. Moran April 7, 20052005-04-07
risha wrote:
> " >>IANALL, but ulvald is never used, and it is not volatile, >>and therefore the compiler likely performs an optimisation >>never setting its value. >> > > first i wanted to check that the value is in the debugger memory > window should display correctly which is not happening first the > varaible ucvald should be initialized to 0 which shows a junk value on > execution of the stmt then the value at the particular location which > is passed as a parameter should read the value at the location > [(0x8020)which is actually 0x03 in my case]so the value in the memory > window should have displayed 0x03 which shows junk value again.
If you want to prevent the compiler from eliminating useless expressions, then you will need to declare the variables as "volatile". Try this: void FlashReadM(volatile unsigned long *fl_ad,unsigned long abb) { volatile unsigned long ulvald; // note volatile qualifier abb=2; // This will be eliminated since abb is a local copy. ulvald=0; // Now that uvald is volatile, this will show. ulvald= *(fl_ad); } -- Michael N. Moran (h) 770 516 7918 5009 Old Field Ct. (c) 678 521 5460 Kennesaw, GA, USA 30144 http://mnmoran.org "So often times it happens, that we live our lives in chains and we never even know we have the key." The Eagles, "Already Gone" The Beatles were wrong: 1 & 1 & 1 is 1
Reply by risha April 7, 20052005-04-07
" 
> IANALL, but ulvald is never used, and it is not volatile, > and therefore the compiler likely performs an optimisation > never setting its value. >
first i wanted to check that the value is in the debugger memory window should display correctly which is not happening first the varaible ucvald should be initialized to 0 which shows a junk value on execution of the stmt then the value at the particular location which is passed as a parameter should read the value at the location [(0x8020)which is actually 0x03 in my case]so the value in the memory window should have displayed 0x03 which shows junk value again. only when this works should i return the value ie ulvald from this function to the main program ofcourse changing the void return type of the function.So i need first the value displayed in the variable should be correct.Then can i proceed. any suggestions on this, regards risha
Reply by Michael N. Moran April 5, 20052005-04-05
risha wrote:
> ***************** > void FlashReadM(volatile unsigned long *fl_ad,unsigned long abb) > { > unsigned long ulvald; > abb=2; > ulvald=0; > //fl_ad=(volatile unsigned long *)0x8020; > ulvald= *(fl_ad); > //return ucVal; > } > > in the above prg the value of abb is shown as 2 but the value of > ulvald does not show 0 it shows a junk value in the debugger memeory > window > i initialized the value of the ulvald thinking that could initilize > the varaiable and then not have this junk value but the junk val just > stays put. > > any suggestions help extended will be very helpful > regards,
IANALL, but ulvald is never used, and it is not volatile, and therefore the compiler likely performs an optimisation never setting its value. -- Michael N. Moran (h) 770 516 7918 5009 Old Field Ct. (c) 678 521 5460 Kennesaw, GA, USA 30144 http://mnmoran.org "So often times it happens, that we live our lives in chains and we never even know we have the key." The Eagles, "Already Gone" The Beatles were wrong: 1 & 1 & 1 is 1
Reply by risha April 5, 20052005-04-05
thanks for the help i was just trying something and it rather appears
very strange as i dont see any thing wrong in the code no errors or
any indication as to where i am going wrong there is junk value stored
in the varaible which just does not seem to go away what could be the
problem?

*****************
void FlashReadM(volatile unsigned long *fl_ad,unsigned long abb)
{
   unsigned long ulvald;
   abb=2;
   ulvald=0;
   //fl_ad=(volatile unsigned long *)0x8020;
   ulvald= *(fl_ad);
   //return ucVal;
}

in the above prg the value of abb is shown as 2 but the value of
ulvald does not show 0 it shows a junk value in the debugger memeory
window
i initialized the value of the ulvald thinking that could initilize
the varaiable and then not have this junk value but the junk val just
stays put.

any suggestions help extended will be very helpful
regards,
Reply by Luca March 30, 20052005-03-30
In my group the first thing we do, it is to check the cfi capability of
the flash.

Try putting on the bus the "Auto select" command and verify the flash
response is what you expect. You can try this also by putting the
command directly in a debugger (if you have one).

At least there is a first check whether it is a bus/interface problem
or a broken flash.

Reply by risha March 28, 20052005-03-28
David Schmider <david.schmider@gmx.ch> wrote in message news:<4242a0f3$1_3@news.bluewin.ch>...
> risha schrieb: > > need to know how to write data into external flash > > memory(offchip).using MCU MC9S12A128B and the external flash memory > > chip is M29F040B.Is there any special code to be sent to the external > > flash memory.Using a cpld chip number being CY37128P84 125 JC which is > > used for the selecting the external flash chip.Also using metrowerks > > code warrior and BDM Multilink. > > > > > > Thanks for any help, > > Ranjita > > Hi Ranjita > > Here you will find the information you are looking for: > http://www.st.com/stonline/books/pdf/docs/6887.pdf > (There's even some C Code included)
thanks everybody for the help but i have gone through the documents before i posted this mail but it did not write in the flash memory.So i had doubt when i was doin the right thing but it seems like i was right.So the memory location shows just ff so it does not take in the data i wonder why? could there be such that the external flash chip has gone bad if so how to check it?the document specifies that Check for correct flash type Step 2: Check the offset range is valid Step 3: Check that the block(s) to be programmed are not protected Step 4: While there is more to be programmed Step 5: Check for changes from &#4294967295;0' to &#4294967295;1' Step 6: Program the next byte one more thing flash was erased so condition has been met.so now what is that i could be not doing the right way? thanks for any help, ranjita
Reply by Luca March 25, 20052005-03-25
ST produces device manual
(http://www.st.com/stonline/books/pdf/docs/6580.pdf) and Application
Notes with source code example (
http://www.st.com/stonline/books/pdf/docs/6887.pdf) on how to use that
memory device.

About ST SW Drivers, you can do whatever you want with that code as
long as you keep the ST disclaimer in your code.

Reply by David Schmider March 24, 20052005-03-24
Dave schrieb:
>>The two attached files were once published on the website of >>STMicroelectronics (www.st.com) and contain library routines for the >>M29F040B Flash Memory. >> > > They are also "Copyright (c) 1999 STMicroelectronics". Does the license > allow reproduction and publication? Or are you breaking the law? > >
I'm sorry. Posting just the link might be more appropriate.
Reply by David Schmider March 24, 20052005-03-24
risha schrieb:
> need to know how to write data into external flash > memory(offchip).using MCU MC9S12A128B and the external flash memory > chip is M29F040B.Is there any special code to be sent to the external > flash memory.Using a cpld chip number being CY37128P84 125 JC which is > used for the selecting the external flash chip.Also using metrowerks > code warrior and BDM Multilink. > > > Thanks for any help, > Ranjita
Hi Ranjita Here you will find the information you are looking for: http://www.st.com/stonline/books/pdf/docs/6887.pdf (There's even some C Code included)