owout not working on 16f77 ? (hangs)


Closed Thread
Results 1 to 11 of 11
  1. #1

    Default owout not working on 16f77 ? (hangs)

    no matter what I do, I cannot get owout to work on these 16f77's.

    works on 12f683 (used to read the serial numbers)
    tried it on other 16f's and always worked perfectly.

    this works on 16f917:
    Code:
    x var byte
    
    clear
    start:
    while x < 50
    x = x + 1
    debug "looping",dec2 x,$0d,$0a
    wend
    x=0
    
    debug "attempting one wire out" ,$0d,$0a
    owout portb.2, 1, [$CC, $4E, 0, 0, %01111111]  'set resolution of sensor
    debug "passed one wire out" ,$0d,$0a
    goto start
    but the same thing on 16f77 will hang at the owout command no matter what I do.
    checked ports for analog/comparators (adcon1/ccp1con/ccp2con), switched to all different ports, even the same one driving lcd, different boards,etc..
    I'm starting to think there's some glitch that just makes it not compatible with 16f77?


    I would just use one of the other pics, but I have these old head units (lcd, buttons, etc) that
    have 16f77's on the board.

    stripped down to just this:
    Code:
    @ __CONFIG  _BODEN_ON & _CP_OFF & _PWRTE_ON & _WDT_ON & _HS_OSC
    
    DEFINE OSC 16
    
    ADCON1 = 7
    
    
    	DEFINE LCD_DREG	PORTD
    	DEFINE LCD_DBIT	0
    	DEFINE LCD_RSREG PORTC
    	DEFINE LCD_RSBIT 3
    	DEFINE LCD_EREG	PORTC
    	DEFINE LCD_EBIT	5
    	DEFINE LCD_BITS	8
            DEFINE LCD_LINES 4
    	DEFINE LCD_COMMANDUS 2000
    	DEFINE LCD_DATAUS 50
    	
    
    start:	
    	LCDOUT $fe,1
        Pause 750       ' Wait for LCD to startup
    'lcd width guide   "12345678901234567890"
        Lcdout $fe,1,  "                    " 
        LCDOUT $fe,$94,"                    " 
        LCDOUT $FE,$C0,"    Fridge Alert!   " ' goto start line 3
        lcdout $fe,$D4,"                    " 
        pause 5000
        LCDOUT $FE,1
    
        pause 500
        lcdout $FE,1,"set resolution owout"     
          'OWOUT portb.2, 1, [$CC, $4E, 0, 0, %01111111]  'set resolution of sensor
        lcdout $FE,$D4,"success!"
        pause 5000
    goto start
    stops right after displaying "set resolution owout"..
    nothing, just dead stops.
    (here i commented out the owout line and it proceeds to success etc..)

    Any ideas?

  2. #2
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: owout not working on 16f77 ? (hangs)

    Not used it before but according to PBP manual shouldn't the OWOUT mode be set as say %010 ? Send reset pulse after data.

    OWOUT PORTB.2,%010 , [$CC, $4E, 0, 0, %01111111]
    Last edited by tasmod; - 6th May 2014 at 08:45.
    Rob.

    The moment after you press "Post" is the moment you actually see the typso

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: owout not working on 16f77 ? (hangs)

    using it to communicate with ds18b20 temperature sensors. I've used this mode for them on other pics and it's worked fine.
    can use decimal notation instead of binary (1 for %00000001, 2 for %00000010, etc) and i've tried different modes, listed in both formats as well.
    On 16f917 and 12f683 both work perfectly, but stops dead on the 16f77. Tried every port/pin I could, as well as modes.
    The b port on these units don't have anything connected, I'm stumped.

    Thanks for the reply though.

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: owout not working on 16f77 ? (hangs)

    this is driving me nuts lol... still cant figure out why it hangs on the owout command, no matter how it's done, what port, config settings, etc.. Have no problems at all with it on other pics.

    (ugly but working temp recorder/readout to monitor our flaky fridge)
    Code:
    @ device pic12F683, intrc_osc_noclkout
    @ device pic12F683, wdt_on
    @ device pic12F683, mclr_off
    @ device pic12F683, protect_off
    
    DEFINE OSC 8
    
    OSCCON.0=1    'system clock select bit 1=internal 0=config word
    OSCCON.4=1    'set int osc to 8MHZ
    OSCCON.5=1
    OSCCON.6=1
    ANSEL.3=0     'set all digital
    ANSEL.2=0
    ANSEL.1=0
    ANSEL.0=0
    CMCON0=7      'turn comparators off!
    ADCON0=0      'turn ADC off
    GPIO.7 = 0    'enable weak pullups  'NOTE: this didn't work for one wire or i2c coms.
    WPU = %00111000                     '   had to use external pullup anyways (did I set it wrong?)
    '===========================================   
    DEFINE DEBUG_REGG GPIO         'set debug port to porta
    DEFINE DEBUG_BIT 0             'use pin a0 of porta for debug
    DEFINE DEBUG_BAUD 9600         'set baud rate to 2400
    DEFINE DEBUG_MODE 0            'communicate in true mode
                                   '12f683 is 14bit, no scl/sda defines
    
    SCL var GPIO.4 ' Clock pin 
    SDA var GPIO.5 ' Data pin
    readbutton var GPIO.3
    
    maxsensor con 4
    
    trisio.3 = 1                   ' switch logging/readout stored temps (using mclr pin, mclr disabled)
    
    
    Cold_Bit    VAR Raw.Bit11      ' Sign-Bit for +/- Temp. 1 = Below 0 deg C
    id          var byte[8]        
    ADDR        var WORD           ' 24c32a uses 2 bytes for address (24lc256 as well)
    raw         var word
    records     var word
    recordaddr  var word
    readloops   var word
    readaddr    var word
    tempc       var word
    tempf       var word
    Sign        VAR byte            ' +/- sign for temp display
    fsign       var byte
    sensor      var byte
    hexbyte     var byte
    col         var byte
    busy        var bit
    rsign       var bit
    
    CLEAR
    
    recordaddr = 31998 'store records at end (been writing to address 0 too much)
    ADDR = 2      ' normal start address
    'addr = 31960 'temporary testing eeprom full 
    
    goto start
    
    subC_TO_F:
        'DISABLE ' Necessary if On Interrupt used
        'tempF = tempC * 9
        'tempf = DIV32 5
        'ENABLE ' Necessary if On Interrupt used
        tempf = (tempc */ 461)
    
        IF rsign = 1 THEN 'if the sign bit is "1" is minus C
          IF tempF > 3200 THEN
           fsign="-"
            tempF = tempF - 3200
            'SEROUT2 sSEROUT_PIN,cBAUD,[" -",DEC C/100,".",DEC2 C," C  = -",DEC F/100,".",DEC2 F," F",13]
          ELSE
          fsign="+"
            tempF = 3200 - tempF
            'SEROUT2 sSEROUT_PIN,cBAUD,[" -",DEC C/100,".",DEC2 C," C  = ",DEC F/100,".",DEC2 F," F",13]
          ENDIF
        ELSE
          tempF = tempF + 3200
          fsign = "+"
          'SEROUT2 sSEROUT_PIN,cBAUD,["  ",DEC C/100,".",DEC2 C," C  = ",DEC F/100,".",DEC2 F," F",13]
        ENDIF
    RETURN
      
    GetID:
        Select Case sensor
            Case 1 :LOOKUP hexbyte,[$28,$00,$3E,$D8,$05,$00,$00,$10], col 
            Case 2 :LOOKUP hexbyte,[$28,$E1,$E2,$D6,$05,$00,$00,$64], col 
            Case 3 :LOOKUP hexbyte,[$28,$3C,$75,$D6,$05,$00,$00,$0C], col 
            Case 4 :LOOKUP hexbyte,[$28,$4F,$62,$D8,$05,$00,$00,$F5], col 
            'Case 5 :LOOKUP hexbyte,[], col 
            'Case 6 :LOOKUP hexbyte,[], col 
            'Case 7: LOOKUP hexbyte,[], col 
            'Case 8 :LOOKUP hexbyte,[], col 
            'Case 9 :LOOKUP hexbyte,[], col 
        end select
    return
    
    IDLOOP:
        for hexbyte=0 to 7  'each sensor address is 8 bytes
                gosub getid     'go look up each sensors address
                id[hexbyte]=col 'load the ID array with the retrieved address byte
        next hexbyte
    return 
           
    DisplayTemp:                        ' +32.0 to +257 F 
        IF raw.bit15 = 1 THEN   ' If Cold_Bit = 1, it's below "0" deg C
        rsign = 1
        Sign  = "-"
        else
        sign = "+"
        endif
        raw = abs(raw)
        tempc = raw */ 1600
        'tempf = (tempc */ 461) + 3200
         debug $0D,$0A,"reading : ",dec records
         if readbutton = 1 then debug " - Sensor: ",dec1 sensor
         debug "  ",sign, DEC (tempc / 100), ".", DEC2 tempc, " C "
         gosub subc_to_f 
         
         debug " / ",fsign, DEC (tempf / 100), ".", DEC2 tempf, " F "
    return
    
    
    START:
    
    pause 800
    
    IF readbutton = 0 then readstart
    ReadSensor:
        OWOUT GPIO.2, 1, [$cc,$44] 'skip romcheck (only one sensor), initiate[$44] temperature conversion
    Ckbsy:
        OWIN GPIO.2, 4, [busy]      ' Check for still busy converting
        IF busy = 0 THEN ckbsy  ' Still busy?, then loop
        sensor = sensor + 1
        if sensor = maxsensor+1 then sensor = 1
        gosub idloop
        '=============================================
        'owout GPIO.2,1,[$cc,$BE]   'skiprom (one sensor only) send back scratchpad[$BE] 
        owout GPIO.2,1,[$55,str id\8,$BE]   'instructs sensors to match[$55] this[ID] and start sending back scratchpad[$BE] 
        '=============================================
        OWIN GPIO.2, 2, [Raw.LOWBYTE,Raw.HIGHBYTE]
            if addr > 31997 then
                debug "eeprom full, not stored"
            else
                I2CWRITE SDA,SCL,$A0,ADDR,[raw.lowbyte,raw.highbyte]  
                pause 100
                records = addr / 2
                i2cwrite sda,scl,$A0,recordaddr,[records]
                addr = addr + 2
            endif
       gosub displaytemp
    goto start
    
    readstart:
      readaddr = 0
      i2cread sda,scl,$A0,recordaddr,[records]
      readloops = records*2
    rloop:
        while readaddr < readloops
        pause 50
        I2CREAD SDA,SCL,$A0,readaddr,[raw.lowbyte,raw.highbyte]
        readaddr = readaddr + 2
        records = readaddr / 2
        gosub displaytemp
        IF readbutton = 1 then start 
        wend
    goto start
    
    end
    really frustrating as I really wanted to use one of these 16f77 boxes I have.

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: owout not working on 16f77 ? (hangs)

    Nomad, I'm going out on a limb here but, looking at your code are you sure it's hanging on the OWOUT statement and not the OWIN? I see where you are queing the sensor for a busy signal but what happens if you do not receive any?
    Dave Purola,
    N8NTA
    EN82fn

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: owout not working on 16f77 ? (hangs)

    that code is on the 12f683 and works fine.

    for the 16f77 ive stripped it all down to
    Code:
    @ __CONFIG  _BODEN_ON & _CP_OFF & _PWRTE_ON & _WDT_ON & _HS_OSC
    
    DEFINE OSC 16
    
    ADCON1 = 7
    
    
    start:
    
        pause 500
        debug "owout (start conversio)"     
        OWOUT portb.2, 1, [$CC,$44] 
        debug "success!"
        pause 500
    
    goto start
    I see the start message, but nothing more.
    what really has me is even if there wasn't a device connected, it shouldn't hang on owout, and I can't even think of a condition it could hang at owout. I've found nothing on this being an issue, so I'm just going to have to use a different device.

  7. #7
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: owout not working on 16f77 ? (hangs)

    Your code compiled with PBP3:
    hex.txt
    Just change extension to .hex instead of .txt.

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: owout not working on 16f77 ? (hangs)

    well, it appears I need to upgrade to pbp3. :/
    that bites lol.

    using the 3 demo it didn't hang at the owout.

  9. #9
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: owout not working on 16f77 ? (hangs)

    Look in .mac file which macro is called when compile for 12F, and which for 16F.
    I think that should be same. If it is same, then problem must be in MPASM. So try another version of MPASM...

  10. #10


    Did you find this post helpful? Yes | No

    Default Re: owout not working on 16f77 ? (hangs)

    the 12f683 and 16f77 are both 14bit. ( It works on 16f917, and tried both pm and mpasm prior to posting)
    As I mentioned getting pbp3, my wife gave me that *oh heck no* look, (I just bought some electronic toys).
    So that will have to wait a while.
    I copied the pbp3 pbppic14.lib,.mac,and .ram files to my pbp, and presto, it didn't hang!
    actually had temp readings on the lcd!
    going to compare the ow macros and see what is different from 2.5 to 3 that the 16f77 was choking on when I get time.

    ***Thank You*** for taking the time to compile it, I don't know that I would have went to pbp3 to test on my own.
    problem solved (well, it's working anyways), now to watch other devices wig from the wrong macro file lol

  11. #11
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: owout not working on 16f77 ? (hangs)

    Nomad, Glad to see you got it to work by changing the .lib file.
    Dave Purola,
    N8NTA
    EN82fn

Similar Threads

  1. pic18f4550 hangs.. RX_INT DT_INTS-18.. please help
    By cluster in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th November 2011, 17:32
  2. uC Hangs after second serout command
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th August 2011, 18:57
  3. AC voltage measurement with 16F77
    By MARWEN in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 22nd May 2011, 21:54
  4. PIC HANGS with SERIN and Timeout?
    By koossa in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 18th January 2008, 18:33

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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