Menu

10F320 MCLRE SLEEP

CaptnJB
2015-09-24
2015-11-17
1 2 > >> (Page 1 of 2)
  • CaptnJB

    CaptnJB - 2015-09-24

    Hey All,

    I have some new 10F320's that I'm playing with. I can't get them to come out of SLEEP with MCLRE like I can on the 200's. Simple program that I snagged from another post to try. What am I missing? Do I need to update WPUEN and WPUA3? GIE?

    Power on, battery, LED lights 1 second, out, sleep, never wakes with change on MCLRE/porta.3

    Any insight?

    Thanks,
    CaptnJB

    ~~~~~
    ;Chip Settings

    chip 10F320,4

    config OSC=INTOSC, WDTE=OFF, MCLRE=OFF

    ;Interrupt Handlers
    On Interrupt ExtInt0 Call wake_up

    dir gpio.0 out
    dir GPIO.3 IN
    main:
    set gpio.0 on
    wait 1 s
    set gpio.0 off
    wait 1 s
    asm sleep
    nop
    goto main

    Sub wake_up
    End Sub


     

    Last edit: Anobium 2015-09-24
  • Anobium

    Anobium - 2015-09-24

    Can you please edit the 10f320.dat file please?

    There is an error in the datasheet.

    Change as follows.

    RAM=64
    

    to

    RAM=32
    

    and also,

    [FreeRAM]
    60:7F
    

    to

    [FreeRAM]
    40:7F
    
     

    Last edit: Anobium 2015-09-24
  • CaptnJB

    CaptnJB - 2015-09-24

    Hey Anobium and whoever else may have some insight,

    I had already changed the FreeRAM, but I did change the RAM= and it is still the same. It will not wake from SLEEP. I have tried MCLRE (GPIO.3) through a 10k and with a jumper to Vdd. This circuit is going to be powered by a 3v lithium battery so I don't have any caps in the circuit.

    I have tried using TRIS and option code as well, I just can't get this thing to wake up.

    Can anyone else replicate?

    Thanks,
    CaptnJB

     
  • CaptnJB

    CaptnJB - 2015-09-24

    N/C <=== PIN1 PIN8 ==> 10K ==> Switch ==> Vdd
    Vdd <=== PIN2 PIN7 ==> Vss
    N/C <=== PIN3 PIN6 ==> N/C
    N/C <=== PIN4 PIN5 ==> + LED - ==> Vss

    Vdd +3V
    Vss GND/NEG

     
  • Anobium

    Anobium - 2015-09-25

    Unless I am missing something RA2 is the External interrupt.

    N/C <=== PIN3 should be connect to something to raise the external event.

     
  • CaptnJB

    CaptnJB - 2015-09-29

    Sorry it took so long. Just now testing it out. won't wake up using any pin.

    I've set GIE 0, WPUA2 1, WPUEN 0 as well. I'm lost here. Any ideas?

     
  • Anobium

    Anobium - 2015-09-29

    Please post a zip of your source and the asm as an attachment. I can look at this later this week.

     
  • CaptnJB

    CaptnJB - 2015-09-30

    The code is above and the ASM is generated by GCBasic. No changes other than what I have tried with no success.

    ;Chip Settings

    chip 10F320,4

    config OSC=INTOSC, WDTE=OFF, MCLRE=OFF

    ;Interrupt Handlers
    On Interrupt ExtInt0 Call wake_up

    dir gpio.0 out
    dir GPIO.3 IN
    main:
    set gpio.0 on
    wait 1 s
    set gpio.0 off
    wait 1 s
    asm sleep
    nop
    goto main

    Sub wake_up
    End Sub**

     
  • CaptnJB

    CaptnJB - 2015-09-30

    I even changed GPIO (10F2XX) to PORTA.X to be more compatible. The LED lights for one second as coded either way, then sleep. Then it doesn't wake again.

     
  • Rikki

    Rikki - 2015-10-01

    Hi

    Try directly modifying the interrupt using assembler.
    Add these lines before the sleep instruction.
    I have done this in the code below

    bsf 0bx0,7 ' force global interrupts on
    bsf 0bx0,4 ' force external interrupt, portA.2
    bcf 0bx0,1 ' force clear external interrupt flag
    bcf 0bx0,0 ' force clear interrupt-on-change flag

    ;Chip Settings
    #chip 10F320,4
    #config OSC=INTOSC, WDTE=OFF, MCLRE=OFF
    
    ;Interrupt Handlers
    On Interrupt ExtInt0 Call wake_up
    
    dir gpio.0 out
    dir GPIO.3 IN
    main:
    set gpio.0 on
    wait 1 s
    set gpio.0 off
    wait 1 s
    
    bsf 0bx0,7  ' force global interrupts on
    bsf 0bx0,4  ' force external interrupt, portA.2
    bcf 0bx0,1  ' force clear external interrupt flag
    bcf 0bx0,0  ' force clear interrupt-on-change flag
    
    asm sleep
    nop
    goto main
    
    Sub wake_up
    End Sub
    ---
    
     

    Last edit: Rikki 2015-10-01
  • Anobium

    Anobium - 2015-10-03

    I have some devices coming from Microchip. Should be here Tuesday, next week.

    I have just tested on 16f1938 and everything works as expected. I have tested on a scope to ensure I get the correct LED timing as shown in the program below. I have made one change to ensure the oscillator is operational.

    ~~~~~
    #chip 16f1938, 4
    #config Osc = intOSC, MCLRE_ON, PLLEN_OFF, VCAPEN_OFF

    ;Interrupt Handlers
    On Interrupt ExtInt0 Call wake_up

    dir porta.0 out
    dir portb.0 IN
    main:
    repeat 4

        set porta.0 on
        wait 1 s
        set porta.0 off
        wait 1 s
    
      end Repeat
    

    asm sleep
    nop
    wait while OSCSTAT = 0
    goto main

    Sub wake_up
    set porta.0 on
    wait 2 s
    End Sub

     

    Last edit: Anobium 2015-10-03
  • Anobium

    Anobium - 2015-10-07

    Chris Rogers resolved this!

    add in your code.

    ANSELA = 0

    This is a feature we will have to resolve in the next release.

     
  • Anobium

    Anobium - 2015-10-07

    This is working here. Chris was 4500klm away, but with the power of the internet and chat! Between us it is resolved. But, Chris found the error. WINNER!!!!

    ;Chip Settings
    #chip 10F320,4
    #config OSC=INTOSC
    
    ;Interrupt Handlers
    On Interrupt ExtInt0 Call wake_up
    ANSELA = 0
    
    dir gpio.0 out
    dir GPIO.2 IN
    main:
    set gpio.0 on
    wait 1 s
    set gpio.0 off
    wait 1 s
    asm sleep
    nop
    goto main
    
    Sub wake_up
    
    End Sub
    
     

    Last edit: Anobium 2015-10-07
  • Anobium

    Anobium - 2015-10-08

    Please try this file here place the file in your GCB@Syn\GreatCowBasic\include\lowlevel folder. This should over write an existing file.

    Then, please remove ANSELA = 0 from the source and test.

    Let us know.

     
  • Anobium

    Anobium - 2015-10-08

    I just tested the following. I have added the powermgt also.

    ~~~~~
    ;Chip Settings

    chip 10F320,4

    config OSC=INTOSC

    ;Interrupt Handlers
    On Interrupt ExtInt0 Call wake_up

    VREGPM1 = 1
    dir gpio.0 out
    dir GPIO.2 IN
    main:
    set gpio.0 on
    wait 1 s
    set gpio.0 off
    wait 1 s
    asm sleep
    nop
    goto main

    Sub wake_up

    End Sub

     
  • CaptnJB

    CaptnJB - 2015-10-08

    would MCLRE=off alter it?

     
    • Anobium

      Anobium - 2015-10-08

      We have found a bug. The download should fix the issue.

       
    • Anobium

      Anobium - 2015-10-08

      The issue was the ADCON0 register was called ADCON on the 10F32x, which meant the tests of set the ANSEL was failing in system.h.

      MCRLE does not seeem to have impact on the test rig I have here. I did get the chips through yesterday, very fast.

      I have done some basic current checks and the current is reduced during sleep.

       
  • Keith

    Keith - 2015-11-16

    Hello again, I apologise in advance for adding something which might appear to be very simple to a high level thread but this is giving me one hell of a headache and here is the only place on the forum I can find any mention relative to the problem I have.

    I have written some code for a latching switch using my favourite little beastie 10F0202 and I am really pleased with it being one of my more successful projects. As it is a battery powered project it consumes some 320µA in standby which is quite frugal but what I want to do is send it to sleep.

    Inserting the instruction ‘SLEEP’ after a timeout works a treat reducing the current consumption down to a mere 6 µA which is absolutely wonderful.

    The problem I have is that the chip will not waken on an input but appears to fall into a coma to where only a hard power on reset will bring it back to life.

    I have read somewhere that I need to read the state of all the ports, but that is above my programming skills.

    From the four available ports I have GPIO 0, 1 and 3 set as outputs and GPIO3 set as an input.

    Any help would be really appreciated as I cannot find anything relative to using SLEEP anywhere apart from on the Microchip 10F202 Programming Guide, but that talks in a level of understanding well above mine.

    Many thanks in advance

    Keith

     
  • Anobium

    Anobium - 2015-11-16

    Hello Mike.

    What version of GCB please? Can you attach your code?

     
    • Keith

      Keith - 2015-11-16

      Hello, is the reply to me? If so I'm using SynWrite 6.5. v1030

      Keith

       
  • Anobium

    Anobium - 2015-11-16

    @Kieth. Sorry. What version of GCB? the version is shown when you compile your program. Is it v0.94?

     
  • Keith

    Keith - 2015-11-16

    Sorry, I'm having one of those 'Senior Moments' I don't seem to be able to find the GCB Version Number.
    All I get when I compile at the bottom of the page in the dialogue box is:

    20:39:55 G@Stool-COMPILE/ASSEMBLE, processing D:\GCB@Sym\G@Stools\makeHEX.bat

     
  • Anobium

    Anobium - 2015-11-16

    @@Keith. What is date and time of gcbasic.exe?

     
  • Keith

    Keith - 2015-11-16

    17/12/2014 22:35

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.