[bascom] Fusing not working ...


From "Michael W. Akers" <mwakers@home.com>
Date Mon, 27 Sep 1999 15:00:13 -0700

Mark,
Have a section of code that is bothering me, well two actually, that I need 
some advice on.

The first is:
Dim Dispbuff As String * 40                                                   
       <- I get an out of memory error. If I set it for 7 the compiler is 
happy 

This is for use in the second problem spot.
The next is:

' Create temperature word
'   Put Lm75high in high byte position in Lm75temp word.
    mov {Lm75temp+1},{Lm75high}
'   Put Lm75low in low byte position in Lm75temp word.
    mov {Lm75temp},{Lm75low}
' Now strip unused lower bits (least significant 7 bits)
    Rotate Lm75temp , Right , 7
    Dispval = Lm75temp * 0.5                                                  
       <- Every thing works fine to here
    Dispbuff = Fusing(dispval , ###.##)                                       
    <- But program Stops execution here!!!
' Now print the temp to the LCD
    Cls                                                                       
                       <- this part of the code never executes.
    Lcd Dispbuff ; "Deg. C"                                                   
           <-


With Lm75high set to $B01111100 and Lm75low set to &B10000000 the final 
result is 124.5 Deg. C if I have LCD Dispval ; "Deg. C" it prints out 
124.500000 Deg.  On the simulated LCD.

But when using Fusing everything halts!
Any Ideas?

Michael Akers

P.S. Here is the full program. (I'm helping Anders L. with accessing the LM75 
using I2C.
'------------------------------------------------------------------------------
' Program Name           : lm75read.bas
' Program Date           : September 26,1999
' Program Written By     : Michael W. Akers
'                          3800 Vineyard Ave. Apt. #E
'                          Pleasanton, California 94566
'                          Voice: +1 925 484 4750
'                          Email: mwakers@home.com
' Program Purpose        : This program will demonstrate how to interface to,
'                          and communicate With The National Semiconductor 
LM75
'                          Digital Temperature Sensor.
'------------------------------------------------------------------------------
' Programmer           Date        Comments
' -------------------  ----------  
--------------------------------------------
' Michael Akers        09/26/1999  Initial creation of this program.
' Brent Nelson         09/27/1999  Usage uf assemble routines for byte/word
'                                  manipulation. Reduces resource 
requirements.
'------------------------------------------------------------------------------
' Define all subroutines.
' Define variables and constants
    Dim Lm75temp As Word
    Dim Lm75write As Byte
    Dim Lm75read As Byte
    Dim Lm75high As Byte
    Dim Lm75low As Byte
    Dim Dispval As Single
    Dim Dispbuff As String * 40

' Define configurations
    Config Scl = P3.5
    Config Sda = P3.7
    Config I2cdelay = 1
    Config Lcd = 40 * 4
'   Assumption is that the 89C2051 uses Port1 to communicate with the LCD.
' Define Port and pin presets.
' Initialize variables as needed.
    Lm75write = &B10010000
    Lm75read = &B10010001
    Lm75temp = 0
' Program start
Start:
' Gather the temperature data from the LM75.
'   Start the I2C system.
    I2cstart
'   Place the device in readback mode.
    I2cwbyte Lm75read
'   Read the High Byte. And ACK.
    I2crbyte Lm75high , 8
'   Read the Low Byte. And NACK.
    I2crbyte Lm75low , 9
'   Stop the I2C system.
    I2cstop
' This code section to be removed when compiling for actual device.
    Lm75high = &B01111100
    Lm75low = &B10000000
' Create temperature word
'   Put Lm75high in high byte position in Lm75temp word.
    mov {Lm75temp+1},{Lm75high}
'   Put Lm75low in low byte position in Lm75temp word.
    mov {Lm75temp},{Lm75low}
' Now strip unused lower bits (least significant 7 bits)
    Rotate Lm75temp , Right , 7
    Dispval = Lm75temp * 0.5
    Dispbuff = Fusing(dispval , ###.##)
' Now print the temp to the LCD
    Cls
    Lcd Dispbuff ; "Deg. C"
Goto Start