View previous topic :: View next topic |
Author |
Message |
Anselm68
Joined: 29 Jan 2010 Posts: 5
|
Posted: Fri Jan 29, 2010 10:18 am Post subject: Attiny84 and shiftout Problem |
|
|
Hi,
i have a big problem with this code.
If i test it at the simulator, all seems to be okay. (the variable Sendedaten contains the right value)
But if i start it at real hardware, he sends the wrong value with shiftout.
This is checked with my Logicport-analyzer.
I´ve made a big bunch of test and shrinked my code to find the problem.
And now, after more than 12h testing, i´m helpless.
If i use single variables instead of doubles, the output is okay.
But i really need doubles......
Code: |
$regfile = "attiny84.dat" 'verwendeter Prozessor
$crystal = 8000000 'eingebauter Oszillator
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 'default Use 40 For The Frame Space
'******* Kommunikation *********
Ce Alias Portb.0
Dta Alias Porta.3
Clk Alias Porta.7
Config Ce = Input
Config Dta = Input
Config Clk = Input
Dim Sendedaten As Integer
Declare Sub Rechnung
Dim R As Double 'Widerstand in Ohm
Dim X As Double 'Arbeitsvariable
Dim Tempc As Double 'Temperatur in °C als Double
Dim Istwert As Single 'Bascom Krampf-Variable (zur Typenumwandlung notwendig)
'***** Basisdaten *****
Const A = 0.0039083 'erste Korrekturwert
Const B = 0.0000005775 '2te Korrektuwert
'**********************
Const X2 = 0.00001527480889 'Berechneter Zwischenwert (A²)
Const X3 = 0.000001155 'Berechneter Zwischenwert (2 * B)
Const X4 = 0.00000231 'Berechneter Zwischenwert (4 * B)
'------------------------------------------------------------
Declare Sub Kommunikation
'*************************************************************************
Do
Call Rechnung
If Pinb.0 = 0 Then Call Kommunikation
Loop
'**************************************************************************
Sub Kommunikation
Config Dta = Output
Config Clk = Output
Clk = 1
Dta = 1
Waitus 10
Sendedaten = Int(Istwert)
Shiftout Dta , Clk , Sendedaten , 0 , 16 , 10
Config Dta = Input
Config Clk = Input
End Sub Kommunikation
'**************************************************************************
Sub Rechnung 'Alle Variablen sind vom Typ DOUBLE
R = 107.79
X = R / 100 'Schritt 1.
X = 1 - X 'Schritt 2.
X = X * X4 'Schritt 3 & 4
X = X + X2 'Schritt 5.
X = Sqr(x) 'Schritt 6.
X = A - X 'Schritt 7.
X = X / X3 'Schritt 8.
Tempc = X 'Temperatur in °C
Istwert = Tempc 'Double in single umwandeln
Istwert = Istwert * 1000 'aufbereiten fürs versenden
End Sub Rechnung
|
First he send 6986, and then 13973 all the time.
It looks like a stack overflow or something, but a lot of try´s with different settings does´nt help.
Could someone give me some hints?
sincerly Anselm |
|
Back to top |
|
|
Anselm68
Joined: 29 Jan 2010 Posts: 5
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Jan 29, 2010 12:23 pm Post subject: |
|
|
In the dat file there is an entry _HWMUL
But it is not checked for in the double.lib
I will add the SW MUL and discuss it with Josef. _________________ Mark |
|
Back to top |
|
|
Anselm68
Joined: 29 Jan 2010 Posts: 5
|
Posted: Fri Jan 29, 2010 12:37 pm Post subject: |
|
|
Thx for your quick fix,
now it works fine.
Anselm |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Fri Jan 29, 2010 12:44 pm Post subject: |
|
|
Anselm,
Quote: | Thx for your quick fix,
now it works fine.
Anselm |
Would you tell us, how it was fixed and how it works now for you ?
As far I can see, there is no emulation of the mnemonics MUL/MULS in the double library, that's why the use of double will not work in your code with this peculiar µC.
And that's why _HWMUL, which is a flag to tell the compiler the capabilities of the µC, is not taken care of in the double lib.
But this also means that till Mr. Voegel has included a software emulation for the doubles, there is no fix possible other than using singles, doubles will still not work.
This would be the way to go for you, and imho that's in the moment the only way.
So that's why I'm curious to learn how alone Mark's message fixed it for you. You got that fast a new Double Lib ? I want one too
Ludwig |
|
Back to top |
|
|
Anselm68
Joined: 29 Jan 2010 Posts: 5
|
Posted: Fri Jan 29, 2010 1:30 pm Post subject: |
|
|
Yes,
I´ve send a errorreport to support @ mcs......
Mark has send a new double.lib to me.
I dont know whether Mark wants to public release this new Lib here.
I think with a new release, it will be shared.
Anselm |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Fri Jan 29, 2010 2:29 pm Post subject: |
|
|
Quote: | Mark has send a new double.lib to me. |
Wow, that's what I call good service |
|
Back to top |
|
|
|