First Run Only Trigger?

Questions about the BASICtools and MakeItC
Post Reply
TodWulff
Posts: 50
Joined: Fri Oct 19, 2012 4:03 am
Location: The Mitten State - Shores of Lake Huron

First Run Only Trigger?

Post by TodWulff » Mon Nov 19, 2018 12:31 am

Looking to see if there is a cross-target way, in an AB context, for user code to know if it is being run for the first time after it has been flashed, or after a power on/reset event.

I know that on the 824, there is some RAM that is wiped during power cycles, Deep Power Down, or a BOR, but is retained during successive resets. From the 824 UM (Page 11):

Code: Select all

Remark: SRAM location 0x1000 0000 to 0x1000 0050 is not used by the bootloader and
the memory content in this area is retained during reset. SRAM memory is not retained
when the part powers down or enters Deep power-down mode.
Sadly, it seems that NXP doesn't do this on all of their devices. I could see some real value in having this be consistent across devices. Oh well...

Anyways, I am wondering if there is a means to an end here, w/o having to resort to user code doing an IAP of some Flash location, to keep track of something like this in a predictable and cross-target manner.

Bruce/Mike, care to comment (please).?. Others who might have skinned this cat already are also requested to comment. TIA.

-t



olzeke51
Posts: 358
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: First Run Only Trigger?

Post by olzeke51 » Tue Nov 20, 2018 12:53 am

this might be a way to gen a first run flag.
? a long way around ????
Olzeke51

basicchip
Posts: 956
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: First Run Only Trigger?

Post by basicchip » Sat Jan 19, 2019 4:09 pm

Consistency from NXP, that was true in the early LPC21xx days. But now their devices are designed by at least 3 different groups around the world, and seemingly with little input from any "lead" designer.

In the LPC21xx days, you could pretty much take simple code from an LPC2106 and run it on a LPC2138 then LPC2103.

Those days are long gone. Some for the good as new peripherals come along, some though I don't think is all that good, with memory maps varying wildly for no good reason.

Back to the question. Yes some parts retain some RAM during all but power-on. NXP does lead when it comes to low power modes, but those require most or all RAM to be shut down. The WDT does have some registers that are maintained during all those power modes, but are initialized to 0 on power up (note they are maintained with battery backup).

Another option is to write into unused Flash to keep track of number of times run.

TodWulff
Posts: 50
Joined: Fri Oct 19, 2012 4:03 am
Location: The Mitten State - Shores of Lake Huron

Re: First Run Only Trigger?

Post by TodWulff » Sat Jan 19, 2019 11:39 pm

basicchip wrote:
Sat Jan 19, 2019 4:09 pm
...Another option is to write into unused Flash to keep track of number of times run.
Yeah, figured that this might be the case.

Does ARMbasic provide any framework for ISP/IAP to write to flash during runtime?

I've seen some fwrite constructs in the help docs, but figured they were for devices with removable storage, or external flash.

EDIT: Ah, Write: www.coridium.us/ARMhelp/scr/v7Write.html

Post Reply