DS1820 with 16f688


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Unfortunately, some bootloaders have chosen to "erase" EEPROM values to 0 instead of the $FF done by hardware. This can be problematic. As long as you know which way your programmer works, it's a definite possibility.
    Hi Darrel,

    Thanks for your most welcomed input as it got me thinking on the right path (I'm hoping). I haven't checked yet if my pickit 2 programmer erases the EEPROM values to 0 or 255 when programming but with the code below it wouldn't really matter. I haven't tried this work a round yet but I can't think of any reasons why it wouldn't work.

    Thanks Again
    jessey

    Code:
    '(2) PIC Config Fuse Definitions for 16f688 
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF & _BOD_ON 
    @ ERRORLEVEL -306
    
    ' Data for house and unit codes
    housetbl data $60,$70,$40,$50,$80,$90,$A0,$B0,$E0,$F0,$C0,$D0
          data $00,$10,$20,$30
    unittbl data 0,$10,$8,$18,$40,$50,$48,$58
    
     EEPROMData94 var BYTE
     Set_Point VAR EEPROMData94
     READ 94, EEPROMData94 
    
     IF Set_Point = 255 THEN
        Set_point = 150  ' Set a default value 
        EEPROMData94 = Set_Point 
        Write 94, EEPROMData94
     ENDIF
    
    IF Set_Point = 0 THEN
        Set_point = 150  ' Set a default value 
        EEPROMData94 = Set_Point 
        Write 94, EEPROMData94
     ENDIF
    
    GOTO Mainloop
    My set point doesn't ever need to be set to 0 or 255 in my program and this routine would prevent the user from setting either of the two there.
    Code:
    Adjust_The_Set_Point: 
      Loop1:
          IF Push_Button1 = Is_Pressed THEN
           IF Set_Point < 255 THEN Set_Point = Set_Point + 1 : Save_Var = Yes 
           IF Set_Point > 254 THEN Set_Point = 254 ' 255 is not allowed 
          ENDIF  
    
          IF Push_Button2 = Is_Pressed THEN
           Set_Point = Set_Point - 1 : Save_Var = Yes 
           IF Set_Point < 2 THEN Set_Point = 1 ' 0 is not allowed 
          ENDIF
    
          IF Push_Button1 = Is_Not_Pressed THEN  
           IF Push_Button2 = Is_Not_Pressed THEN
            RETURN 
           ENDIF 
          ENDIF 
    
       Pause 100  
      
      GOSUB Update_The_Lcd ' just in case a button is held down 
    
      IF a = 0 THEN Loop1 ' a always equals zero, use instead of GOTO... 
         
    RETURN

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hey jessey,

    I guess it's just a matter of semantics, but you may find this interesting.
    Code:
    <font color="#000000"><b>SetPoint   </b><font color="#008000"><b>VAR BYTE </b></font>: <b>SetPoint_DEFAULT  </b><font color="#008000"><b>CON </b></font><font color="#800000"><b>150
    </b></font><b>Threshold  </b><font color="#008000"><b>VAR BYTE </b></font>: <b>Threshold_DEFAULT </b><font color="#008000"><b>CON </b></font><font color="#800000"><b>5
    
    </b></font><font color="#008000"><b>DATA </b></font>@<font color="#800000"><b>94                            </b></font><font color="#0000FF"><b><i>; Start this block of data at EE addr 94
    </i></b></font><b>EE_SetPoint  </b><font color="#008000"><b>DATA </b></font><b>SetPoint_DEFAULT
    EE_Threshold </b><font color="#008000"><b>DATA </b></font><b>Threshold_DEFAULT
    
    </b><font color="#008000"><b>READ </b></font><b>EE_SetPoint</b>, <b>SetPoint               </b><font color="#0000FF"><b><i>; read EE values on powerup
    </i></b></font><font color="#008000"><b>READ </b></font><b>EE_Threshold</b>, <b>Threshold
    </b><font color="#008000"><b>GOTO </b></font><b>Main
    
    </b><font color="#0000FF"><b><i>;----[Save/Restore EEPROM values]------------------------------------------
    </i></b></font><b>Save_SetPoint</b>:                           <font color="#0000FF"><b><i>; write current SetPoint to EEPROM
        </i></b></font><font color="#008000"><b>WRITE </b></font><b>EE_SetPoint</b>, <b>SetPoint          
        </b><font color="#008000"><b>RETURN
    </b></font><b>Default_SetPoint</b>:                        <font color="#0000FF"><b><i>; restore default SetPoint value
        </i></b></font><font color="#008000"><b>WRITE </b></font><b>EE_SetPoint</b>, <b>SetPoint_DEFAULT          
        </b><font color="#008000"><b>READ  </b></font><b>EE_SetPoint</b>, <b>SetPoint
        </b><font color="#008000"><b>RETURN
    </b></font><font color="#0000FF"><b><i>;-----------------
    </i></b></font><b>Save_Threshold</b>:                          <font color="#0000FF"><b><i>; write current Threshold to EEPROM
        </i></b></font><font color="#008000"><b>WRITE </b></font><b>EE_Threshold</b>, <b>Threshold
        </b><font color="#008000"><b>RETURN
    </b></font><b>Default_Threshold</b>:                       <font color="#0000FF"><b><i>; restore default Threshold value
        </i></b></font><font color="#008000"><b>WRITE </b></font><b>EE_Threshold</b>, <b>Threshold_DEFAULT
        </b><font color="#008000"><b>READ  </b></font><b>EE_Threshold</b>, <b>Threshold
        </b><font color="#008000"><b>RETURN
    </b></font><font color="#0000FF"><b><i>;-----------------
    </i></b></font><b>Save_ALL</b>:                                <font color="#0000FF"><b><i>; save ALL values to EEPROM
        </i></b></font><font color="#008000"><b>GOSUB </b></font><b>Save_SetPoint
        </b><font color="#008000"><b>GOSUB </b></font><b>Save_Threshold
        </b><font color="#008000"><b>RETURN
    </b></font><b>Default_ALL</b>:                             <font color="#0000FF"><b><i>; restore ALL default values
        </i></b></font><font color="#008000"><b>GOSUB </b></font><b>Default_SetPoint
        </b><font color="#008000"><b>GOSUB </b></font><b>Default_Threshold
        </b><font color="#008000"><b>RETURN
        
    </b></font><b>Main</b>:
    DT

Similar Threads

  1. DS1820 display with 7-seg 4 digits
    By chai98a in forum Code Examples
    Replies: 12
    Last Post: - 10th April 2008, 14:12
  2. PIC lcd ds1820
    By wchpikus in forum mel PIC BASIC
    Replies: 2
    Last Post: - 24th May 2007, 15:46
  3. Help with 16f688
    By jessey in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 21st October 2006, 00:12
  4. DS1820 again
    By paxmowa in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th January 2006, 15:49
  5. Problem with 16F688 and Hserout
    By DWV in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 19th March 2005, 06:37

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts