Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

program is erased from flash
Goto page Previous  1, 2
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Fri Oct 30, 2020 10:11 am    Post subject: Reply with quote

Quote:
cannot be used to jump to the program; it jumps to the bootloader

it will reset the micro. it depends on your fuse if it will execute the boot loader or the normal application memory.

ok, the procedure is clear. i understand it saves time, but i would test the boot loading before shipping the device.
i used pins and special test boards and programs but at the end that will not test the connector and testing everything is the only way to make sure the product is 100%.
ok, i f you make thousands you can accept some error.
in any case we can assume the problem is only with the xmega flash.

the only way is that spm is executed with &H20. since there are no interrupts active i can not see it happen.
thus i keep it on an electric kind of problem. again the brown out (or an external one) would solve that problem.

_________________
Mark
Back to top
View user's profile Visit poster's website
hzz

Bascom Member



Joined: 20 Feb 2007
Posts: 314

spain.gif
PostPosted: Sat Oct 31, 2020 1:25 am    Post subject: Reply with quote

Comparing the Bootloader sample from BASCOM I have seen a couple of differences with my Bootloader version:

The sample uses
Code:
$lib "xmega.lib"
while I do not use this lib. Is it necessary fro XMEGA chips? The problem using it is that
Code:
Reset_cause = Getreg(r0)
doesn't work (it always returns 0)

The second difference is that in the BASCOM Bootloader sample we have:
Code:
   Const Maxwordbit = 8                                    
   Const Maxword =(2 ^ Maxwordbit) * 2            
   Const Maxwordshift = Maxwordbit + 1            
 

In my version of the Bootloader I have:
Code:
   Const Maxwordbit = 7                                    
   Const Maxword =(2 ^ Maxwordbit) * 2            
   Const Maxwordshift = Maxwordbit + 1            
 

They both seem to work fine, Are both correct?
Regards

Acording to BASCOM HELP the page size should be 512 Words and therefore Maxwordbit=8



According to Xmega256A3U datasheet the page size should be 256 Words and therefore Maxwordbit=7

[/img]
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Mon Nov 02, 2020 1:51 pm    Post subject: Reply with quote

the $lib is not needed. it is included automatic.

getreg can also be replaced by R0
like : bResetCause=R0

this since registers can be accessed as a byte in recent versions

'it does not work' : make sure to try different reset caused like bod, WD, etc.


the location is Z1:Z8 thus a value of 8 is correct

_________________
Mark
Back to top
View user's profile Visit poster's website
hzz

Bascom Member



Joined: 20 Feb 2007
Posts: 314

spain.gif
PostPosted: Fri Nov 20, 2020 7:32 pm    Post subject: SOLVED! Reply with quote

I have been able to reproduce the error in the lab and I can confirm that it is a Brownout problem.
With BOD disable is easy to make the chip to behave unpredictably and erase the app when the input voltage is between 2 and 3V
With BOD enabled the chip always seems to behave as expected.

Thanks again for your good ideas.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum