I have a problem trying to use other port pins along with OWIN and OWOUT




When I try to make a port pin high, (on the same port as OWIN and OWOUT), the pin only remains on for about 20 US, which is probably about the time to complete the loop (using the attached program).

I am not very familar with OWIN and OWOUT . . . Does the command change all the pins back and forth from input to output, etc on that particular port? The SERIN2 command works fine, using a pin on the same port. When I change to another port
(PORTB in this case), everything is fine, the output remains on. I am using a simple test in the attached program, eventually I will be turning the output on and off depending on temperature.

I tried using the LAT command on the port pin, thinking it might be a read - modify - write problem, and get a "bad data type" error trying to compile.

The program is a modified version of one of Bruce's for the DS18B20. The program works just fine. I'm using a 16f876A running at 4 MHz.

I have commented the problem areas surrounded by a !!!!!!!!!!!!!!!! boundary



Code:
'****************************************************************
'*  Name    : DSB1820                                           *
'*  Author  : K. STUEMPGES ( VIA Bruce Reynolds)                *           
'*  Date    : 27 OCT 2011                                       *
'*  Version : 1.0                                               *
'*  Notes   : MODIFIED FROM BRUCE REYNOLDS PROGRAM              *
'*          : TO USE WITH A PIC 16F676A                          *
'*          : A RELAY WILL BE USED TO CYCLE THE INVERTER        *
'*          : USED ON THE FREEZER  (ON - OFF WITH HYSTERESIS)   *
'*          : THE FREEZER TEMP WILL BE FROM 0 TO 15 DEGREES F   *
'****************************************************************

DEFINE      OSC 4           ' INTERNAL OSCILLATOR

TRISC = 000000
TRISB = 010000
Comm_Pin    VAR    PORTC.0      ' One-wire Data-Pin "DQ"
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
RELAY       VAR PORTC.6      ' OUTPUT TO DRIVE THE RELAY
'
'   THIS IS THE OUTPUT THAT WILL NOT STAY HIGH USING ANY OTHER PORT C PIN
'   IT WORKS FINE USING PORT B
'
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
DISP        VAR PORTC.3      ' SERIAL LCD OUTPUT
ALARM       VAR PORTB.3      ' OUTPUT TO SOUND ALARM
SWITCH      VAR PORTB.4      ' TOGGLE SWITCH INPUT
Busy        VAR BIT         ' Busy Status-Bit
R_Temp      VAR    WORD        ' RAW Temperature readings
TempC       VAR WORD        ' Temp in deg C
TempF       VAR WORD        ' Temp in deg F
Float       VAR WORD        ' Holds remainder for + temp C display
Cold_Bit    VAR R_Temp.Bit11' Sign-Bit for +/- Temp. 1 = Below 0 deg C
Real_Cold   CON 1           ' Define Real_Cold = 1
Deg         CON 223         ' Data to display Deg ° symbol
Sign        VAR BYTE        ' +/- sign for temp display
Dummy       VAR BYTE        ' Dummy for Div32
CLR         CON 1           ' CLEAR DISPLAY
LINE1       CON 128         ' FIRST LCD LINE
LINE2       CON 192         ' SECOND LCD LINE
LINE3       CON 148         ' THIRD LCD LINE
LINE4       CON 212         ' FOURTH LCD LINE
INS         CON 254         ' LCD COMMAND MODE PARAMTER
BAUD        CON 84          ' LCD BAUD COMMAND


        SEROUT2 DISP,BAUD,[INS,CLR] ' clears the display


Start_Convert:
    OWOUT   Comm_Pin, 1, [$CC, $44]' Skip ROM search & do temp conversion 
        
Wait_Up:
    OWIN    Comm_Pin, 4, [Busy]    ' Read busy-bit
    IF      Busy = 0 THEN Wait_Up  ' Still busy..?, Wait_Up..!
    OWOUT   Comm_Pin, 1, [$CC, $BE]' Skip ROM search & read scratchpad memory
    OWIN    Comm_Pin, 2, [R_Temp.Lowbyte, R_Temp.Highbyte]' Read two bytes / end comms
    GOSUB   Convert_Temp
    GOTO    Start_Convert
    
Convert_Temp:                 ' +32.0 to +257 F 
    IF      Cold_Bit = Real_Cold THEN Yikes ' If Cold_Bit = 1, it's below "0" deg C
    Sign  = "+"
    Dummy = 625 * R_Temp      ' Multiply to load internal registers with 32-bit value
    TempC = DIV32 10          ' Use Div32 value to calculate precise deg C
    Dummy = 1125 * R_Temp
    TempF = DIV32 100
    IF TempF >6795 THEN ' Over 99.5 deg F..?
       TempF = TempF + 3200
SEROUT2 DISP,BAUD, [INS,LINE1, " Temp = ",Sign,DEC TempF DIG 4,_
       DEC TempF DIG 3,DEC TempF DIG 2,Deg," F  "]           
       
       
   
    ELSE
       TempF = TempF + 3200
  SEROUT2 DISP,BAUD, [INS,LINE1, " Temp = ",Sign,DEC TempF DIG 3,_
       DEC TempF DIG 2,Deg," F  "]       
              
    ENDIF
    TempC  = (R_Temp & $0FF0) >> 4 ' Mask middle 8-bits, shift into lower byte
    'Float = ((R_Temp.Lowbyte & $0F) * 625) ' Lower 4-bits of result * 625
  SEROUT2 DISP,BAUD, [INS,LINE2, " Temp = ",Sign,DEC TempC,Deg," C  "] 
  
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    RELAY = 1
'
'   THIS OUTPUT ONLY STAYS HIGH FOR APROX 20 US.  
'   IT WILL REMAIN ON USING ANY PIN ON PORTB
'
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
    RETURN

Yikes:                      ' Display full range -C to -F conversion
    Sign   = "-"            ' Display - symbol for negative temp
    Dummy  = 625 * ~R_Temp+1' Multiply to load internal registers with 32-bit value
    TempC  = DIV32 10       ' Use Div32 value to calculate precise deg C
    TempF  = ~R_Temp / 16   ' Begin conversion from -C to deg +/-F
    IF TempF >=18 THEN      ' Check for -degrees F "-18 C = -0.4 F"
       TempF   = ((((TempF + 50) * 9) /5) -122) ' -C to -F below -17 deg C
      SEROUT2 DISP,BAUD, [INS,LINE1, " Temp = ",Sign, DEC TempF,Deg," F  "]
      
      SEROUT2 DISP,BAUD, [INS,LINE2, " Temp = ",Sign,DEC TempC dig 4,_
      dec TempC dig 3,Deg," C  "]

    
    ELSE                    ' Else result = +deg F
       TempF   = ((((-TempF + 50) * 9) /5) -58)' -C to +F below 32.0 deg F to -17 deg C
     SEROUT2 DISP,BAUD, [INS,LINE1, " Temp = ","+",DEC TempF,Deg," F  "] 
     SEROUT2 DISP,BAUD, [INS,LINE2, " Temp = ",Sign,DEC TempC dig 4,_
     dec TempC Dig 3,Deg," C  "]
     
      
    ENDIF  
    
    RETURN   
    
    END