Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

"warm" reset doesn't work properly in assembly

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
KenHorse

Bascom Member



Joined: 16 Jul 2004
Posts: 519

blank.gif
PostPosted: Sat Sep 08, 2018 7:46 pm    Post subject: "warm" reset doesn't work properly in assembly Reply with quote

Take the following code:
Code:
$regfile = "m2560def.dat"
$hwstack = 1000
$swstack = 800
$framesize = 600
$crystal = 16000000
$baud = 57600
$baud1 = 57600


$ASM
  jmp &H1FC00                              'hardcoded loader start address
$END ASM

end


I have the Bascom Bootloader installed and it works fine. If I do a "hard" reset (either cycle power or pull the reset line on the AT2560 low), the processor resets and the bootloader sends a 5 "^" as it should. HOWEVER, if I do a reset from the above code, no "^" is sent, only a value of 255 (which the Bascom terminal displays as a space) 5 times.

This didn't happen in earlier versions of Bascom but I very recently had reason to recompile the existing code and noticed this (mis)behavior.

(BASCOM-AVR version : 2.0.8.1 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5319
Location: Holland

blank.gif
PostPosted: Sat Sep 08, 2018 8:11 pm    Post subject: works fine Reply with quote

I have no idea why you use asm instead of GOTO ?
I can guarantee that the GOTO or JMP always works the same for all versions.

I think this is caused by the fact that the bootloader is compiled with an older version. Newer versions use the 2x speed option in order to calculate a better error free baud.
Either recompile the boot loader too, or just remove the 2x flag from the dat file so this option will not be used. This is mentioned on the forum in earlier posts just search for the post.

If you mention earlier versions, do specify exactly which ones, and better give some files for both versions we can test.

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

Bascom Member



Joined: 16 Jul 2004
Posts: 519

blank.gif
PostPosted: Sat Sep 08, 2018 9:48 pm    Post subject: Reply with quote

I would have mentioned which version Bascom was previously used to compile it but I don't know (other than it was sometime in 2012).

In any case, I made the following change to the m2560def.dat file as I am using UART0 for serial com to the outside world:

Code:

U2X0    = 0     ; Double the USART transmission speed




There is no difference in (mis)behavior.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5319
Location: Holland

blank.gif
PostPosted: Sun Sep 09, 2018 10:06 am    Post subject: Reply with quote

- you really need to come up with a version
- then read the history, especial about u2x

here is what i mean :
- when using a serial boot loader compiled with an older version, and when calling it from code (not after a reset) you need to reset the u2x flag in ucsrxA.
Or you can compile both the bootloader and main code with the new version. When you want the old behavior, you can remark the u2x constant in the dat file.

It appears you changed the constant value to 0 which is not a good idea.

Again, and i repeat, there is nothing wrong with JMP, RJMP or GOTO in any of the releases. So if you think otherwise i want to see some good info.

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

Bascom Member



Joined: 16 Jul 2004
Posts: 519

blank.gif
PostPosted: Sun Sep 09, 2018 6:23 pm    Post subject: Reply with quote

Thanks Mark. As the original bootloader is already installed on some units that are already deployed, I opted to leave the bootloader code alone as well as the dat file and added the following to my reset call (and yes, changed it to GOTO as well)



Code:
UCSR0A.U2X = 0


And in the startup part of the program that starts after boot, I added
Code:
UCSR0A.U2X = 1


(sometimes I need a kick to remind me about the simple way to fix issues, thanks)
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
Page 1 of 1

 
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