12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    First let me say, this is an awesome thread. I have been meaning to read it from the beginning, but I am a slow reader.

    LEDave, WDT in the snippet you just posted works like this:
    Assuming PBP knows you are using the WDT, clear WD is sprinkled around the program for you to keep from resetting the chip. But to get to these, the program must run.

    @sleep basically stops the program and the chip just, well sleeps. Because of this, the WDT never gets cleared. The WD can wake up the PIC, so when WDT overflows, the PIC wakes up and resumes where it left off. So this is how the WDT is associated with the counter.

    Hope this helps
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Bert,
    will this make it work as expected?
    Code:
    WHILE COUNTER <= 2      ' 4.608sec Loop time (Loop for 30 mins = 781)
          INTCON.0 = 0
         @ SLEEP
        CLEARWDT
         COUNTER=COUNTER+1
         'IF  GPIO.3= 0  THEN COUNTS 'Bird at box (it's not dark) so continue counting
    WEND
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Dave, sorry for being only clear as mud with my explaination. I ment to say : because of this, the WD never gets cleared WHILE SLEEPING. When the pic is asleep, WDT overflows thus waking up the PIC.

    I tried to quickly look over the program a few posts up, but I don't have a good feel for it yet. I don't think adding the CLRWDT will help only because when the pic wakes, it should be a long time (~2sec) before the next overflow.

    I did notice when @SLEEP is used elsewhere in the program, the line following is @NOP. Maybe this is needed to give the pic a chance to get the sleep from its eyes? I would try using @NOP right after the @SLEEP and see if this works.

    I have never used any of the power saving modes before, but if the pic needs a nop upon waking up, it may be ignoring the counter=counter+1. Therefore the while is never satisified.

    In any event,if the NOP is needed, adding CLRWDT may solve the problem, we just won't know why it did.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  4. #4
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Hi Bert

    Thanks for your input and welcome to the thread. I was heading towards the CLRWDT after reading this (quite an interesting website):

    http://www.hobbyprojects.com/pic_tut...utorial13.html

    Well here's the section of code as it stands:

    Code:
    DARK:   
          'INTCON.0 = 0    ' Clear int on change flag
                           ' It could be night time...It might only be a cloud though...   
                           ' so back to sleep / wake / sleep for half an hour..zwzwzw
          
          COUNTER=0        ' clear before entry
    WHILE COUNTER <= 2     ' 4.608sec Loop time (Loop for 30 mins = 781)
         INTCON.0 = 0      ' Clear int on change flag
         @ SLEEP
         @ NOP 
         CLEARWDT
         COUNTER=COUNTER+1
         'IF  GPIO.3= 0  THEN COUNTS 'Bird at box (it's not dark) so continue counting
    WEND     
                       
        if  GPIO.4= 0  then ENCODE  ' It really ia dark so carry on and transmit VISITS
        
        'IF  GPIO.4= 1  THEN Main  '(changed from return) It's not dark after all so carry_on_sleeping_counting 
        
    Encode:  
        E_OUT=1     ' Turn transmitter on
    What happens now is when the push button on GPIO.4 is pressed (and held down) After a count of 9 seconds approx (I was expecting a count of two to give half that time) the TX board led lights but still nothing is transmitted.

    The program still doesn't seem to get to encode and transmit, frustrating, any other thoughts?

    Dave

  5. #5
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Bert

    As an aside to the problem, earlier on in the program we have:

    Code:
    Main:    
        ' Read port to clear missmatch, if with no buttons pressed, then
        ' clear int-on-change flag & snooze until wake up on change. This
        ' conserves battery power on the demo board with 3V coin cell.
        
      IF GPIO.3= 1 AND GPIO.4= 1 THEN ' Nothing has happened so SLEEP
           E_OUT=0       ' Disable transmitter
           INTCON.0 = 0  ' No Inputs detected or it's still light so clear int on change flag
           @ SLEEP       ' and start snoozin..zzzzzzzzzzz indefinatly
           @ NOP         ' Do nothing for 1st instruction on wake-up
      ELSE  
       'IF  GPIO.3=0 THEN GOSUB COUNTS 'Bird detected at box - GOTO LABEL COUNTS   
       IF  GPIO.4=0 THEN DARK   'It's got dark? or just cloudy - GOTO LABEL DARK
      ENDIF     
      GOTO MAIN          'Back to sleep / continue counting
    Does this mean that using a WDT and a SLEEP command to save power are kind of mutually exclusive? The SLEEP command turns the PIC off (saving power) then the WDT turns the PIC back on again 4.6seconds later in our case? The above code would keep looping on and off until a button is pressed or the 3v cell goes flat?

    Dave
    Last edited by LEDave; - 5th April 2011 at 23:24.

  6. #6
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    Have spent several interesting but largely fruitless hours trying to make some progress with the program.

    However if I jump passed the COUNTER / WDT routine the TX & RX work fine which is good to know.

    Here's the code for it:

    Code:
          COUNTER=0        ' clear before entry
    WHILE COUNTER <= 2     ' 4.608sec Loop time (Loop for 30 mins = 781)
         INTCON.0 = 0      ' Clear int on change flag
         @ SLEEP
         @ NOP 
         CLEARWDT
         COUNTER=COUNTER+1
    One thought does occur to me though, at the start of the program the PIC is placed into SLEEP mode, only to be woken on INTERRUPT.

    Code below.

    Code:
    IF GPIO.3= 1 AND GPIO.4= 1 THEN ' Nothing has happened so SLEEP
           E_OUT=0       ' Disable transmitter
           INTCON.0 = 0  ' No Inputs detected or it's still light so clear int on change flag
           @ SLEEP       ' and start snoozin..zzzzzzzzzzz indefinatly
           @ NOP         ' Do nothing for 1st instruction on wake-up
           CLEARWDT
      ELSE  
       'IF  GPIO.3=0 THEN GOSUB COUNTS 'Bird detected at box - GOTO LABEL COUNTS   
       IF  GPIO.4=0 THEN   encode 'DARK 'Encode 'DARK   'It's got dark? or just cloudy - GOTO LABEL DARK
    However, GPIO.4 must be pressed and held down (simulating night time) which causes the wake up from SLEEP interrupt, the program then moves down to the COUNTER / WDT loop. I think I might have found a problem here though. For the COUNTER / WDT loop to work and give a 4.6sec test delay the PIC must go into SLEEP mode, if GPIO.4 is continually held down simulating night time and hence causing an INTERRUPT from SLEEP (continually, even resetting the interrupt won't help as button continually pressed) then my thinking says the COUNTER /WDT loop will never work because the PIC is always being woken up.

    A bit garbled I know, sorry, but am I onto something.

    Dave

  7. #7
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default Re: 12f675_fuse_about_to_blow!

    I'm having a problem getting the rfpic transmitter to Tx when I want it to. I've set up an ON INTERRUPT with DISABLE - RESUME - ENABLE and have the INTCON & IOC set at:

    Code:
    INTCON = %00001000 & IOC = %00011000
    What happens is, when buttons GPIO3/4 are pressed (and released)the RFEN led after a 5sec delay briefly flashes but no data is sent. If GPIO.3/4 are pressed and held down after 10 secs the RFEN led lights up the five seconds later (button still held down) data is Tx'd, the button is then released and five seconds later the RFEN led goes out.

    What I'd like is for the buttons GPIO.3/4 to be pressed, ON INTERRUPT runs then five seconds later after the delay loop the data is Tx'd. Does anyone have any idea on what's going wrong?

    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
     
        DEFINE OSC 4
        DEFINE OSCCAL_1K 1
        DEFINE NO_CLRWDT 1    
     
        SYMBOL D_OUT = GPIO.2 ' RF serial data output
        SYMBOL E_OUT = GPIO.5 ' RF transmitter enable output
     
        ON INTERRUPT GOTO  Delay
     
        DAT_OUT  VAR BYTE   ' Holds 8-bit data byte
        CHK_SUM  VAR BYTE   ' Holds calculated checksum of outbound data
        VISITS   VAR WORD   ' Loop variable (300 for test)
        I        VAR word   ' Delay Loop Count value  
        BAUD     VAR WORD   ' Holds baud rate
     
        ' Constants
        PreAmble CON $A5    ' 10100101 preamble
        Synch    CON "~"    ' 01111110 synch byte
        N4800    CON 188    ' 4800 bps 
        N2400    CON 16780  ' 2400 bps
        GUARD    CON 5      ' 5mS guard time pause
     
     
        ' hardware init 
        GPIO = 0            ' Everything off on boot
        ' GPIO.2=data out, GPIO.5=RF enable, GPIO.3,4 = Bird_visit_count / It's dark..maybe
        TRISIO = %00011011  '
        ANSEL = 0           ' Disable A/D
        INTCON = %00001000   ' Enable port change wakeup from sleep
        WPU = %00010000     ' pull-up on for GPIO.4 (external pull-up already on GPIO.3)
        IOC = %00011000     ' Wakeup on change enabled for GPIO.3,4
        VRCON = 0           ' Disable internal Vref
        CMCON = 7           ' Disable comparators
        OPTION_REG = 0      ' Pull-ups on 
     
        D_OUT = 0           ' Idles low for inverted serial output
        E_OUT = 0           ' Enable for RF transmitter=0 (transmiter off)
        BAUD = N2400        ' Set baud rate here
     
    Main:
        ' Read port to clear missmatch, if with no buttons pressed, then
        ' clear int-on-change flag & snooze until wake up on change. This
        ' conserves battery power on the demo board with 3V coin cell.
        IF GPIO.3= 1 AND GPIO.4= 1 THEN ' Nothing has happened so SLEEP
           E_OUT=0       ' Disable transmitter
           INTCON.0 = 0  ' No Inputs detected or it's still light so clear int on change flag
        @ SLEEP          ' and start snoozin..zzzzzzzzzzz indefinatly / Waiting for IOC
        @ NOP
        'ON INTERRUPT starts / returns here with Button_press: goes to LABEL - "DELAY":
     
    ENDIF
    Encode: 
     E_OUT=1     ' Turn transmitter on 
        pauseus 25  ' Let transmitter settle
        DAT_OUT = %10101001
     
        'Build checksum of 2 data bytes
        CHK_SUM = (DAT_OUT * 2) 
     
    Transmit:
       'LET VISITS = VISITS / 2  'Just VISITS too not from the box 
        LET VISITS = 300 'Test data number
         SEROUT2 D_OUT,BAUD,[PreAmble,Synch,DAT_OUT,DAT_OUT,CHK_SUM,VISITS.highbyte,VISITS.lowbyte]
         PAUSE GUARD ' 5mS guard time gives decoder time to respond,calculate,change,etc.
         GOTO Main 
     
    disable 
     
    Delay:
    FOR I = 1 TO 5
        PAUSe 1000
    nEXT I 
    INTCON.0 = 0 
    resume : enable 
    goto Main
    Dave

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