View previous topic :: View next topic |
Author |
Message |
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Sat Sep 08, 2018 7:46 pm Post subject: "warm" reset doesn't work properly in assembly |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sat Sep 08, 2018 8:11 pm Post subject: works fine |
|
|
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 |
|
|
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Sat Sep 08, 2018 9:48 pm Post subject: |
|
|
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 |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun Sep 09, 2018 10:06 am Post subject: |
|
|
- 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 |
|
|
KenHorse
Joined: 16 Jul 2004 Posts: 523
|
Posted: Sun Sep 09, 2018 6:23 pm Post subject: |
|
|
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)
And in the startup part of the program that starts after boot, I added
(sometimes I need a kick to remind me about the simple way to fix issues, thanks) |
|
Back to top |
|
|
|