View previous topic :: View next topic |
Author |
Message |
Sarek
Joined: 15 Oct 2009 Posts: 72
|
Posted: Wed Feb 02, 2022 12:06 pm Post subject: Bug in QSIN / QCOS |
|
|
I use qsin/qcos to draw an user defined scale with XMege256A3U for a gauge with FT81x.
Everything worked as it should, but after a small modification of my bascom code at a complete different location,
drawing the scale was corrupted.
before modification code
after modification code
So I tried to analyse this problem in AVR-Studio with disassembler.
I could see that qsin is using a lookup table.
So this problem occures if this lookup table overlaps in flash an address n * 1000hex
I think there is a bug in calculating the RAMPZ for reading the lookup table.
Yes I use BASCOM 2.0.8.2, but I tried also with newest version 2.0.8.5, same problem!
(BASCOM-AVR version : 2.0.8.2 , Latest : 2.0.8.5 ) |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Wed Feb 02, 2022 1:21 pm Post subject: |
|
|
in the int_trig.lib
there is this code :
#IF _ROMSIZE > 65536
call _SET_RAMPZ
#ENDIF
put a * before the call :
#IF _ROMSIZE > 65536
* call _SET_RAMPZ
#ENDIF
then save and use lib manager to compile to lbx
if that does not work,
put some code in the lib below the call :
In r0,rampz
sts {bsomevar},r0
then dim a byte named bsomevar and include the lib version using $lib before you call qsin
lib$ "int_trig.lib"
in your code after the call to sqin print the content of the variable.
it should contain the proper 64KB page _________________ Mark |
|
Back to top |
|
|
Sarek
Joined: 15 Oct 2009 Posts: 72
|
Posted: Wed Feb 02, 2022 4:39 pm Post subject: |
|
|
Hello Mark
I tried to change the lib.
But it was not working.
Then I changed the lib a second time, so I can debug with bsomevar.
First it worked, because the change in the basic code moved the complete lookup table to 64kb page 3.
Then I removed some other code, so the lookup table moved in flash a little bit down and it overlaps now 64kb page 2 and 64kb page 3 again.
Same problem again!
I print also out the used 64kb page with bsomevar.
All lookup table accesses were on 64kb page 2.
This is not correct. Some angles must be in 64kb page 2 and others must be in 64kb page 3 ! |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Wed Feb 02, 2022 8:43 pm Post subject: |
|
|
ok, so the page is correct.
after a look it is obvious.
add the code in bold after the addition.
that should fix it.
add r30,r16 ; add offset
adc r31,r17
#IF _ROMSIZE>65536
Brcc _QSINCOS1 ; no 64KB boundery overflow
* In r0, RAMPZ
Inc R0
* Out RAMPZ, R0
_QSINCOS1:
#ENDIF _________________ Mark |
|
Back to top |
|
|
Sarek
Joined: 15 Oct 2009 Posts: 72
|
Posted: Thu Feb 03, 2022 11:33 am Post subject: |
|
|
Now it is working!
I checked also the position of the lookup table and changed my bascom code,
that the table still overlaps 2 pages.
Thank you! |
|
Back to top |
|
|
|