Menu

10F320 MCLRE SLEEP

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

    Anobium - 2015-11-16

    @Kieth. Please send me me a personal message with your contact email. I will let you have the latest v0.95 build.

     
  • Keith

    Keith - 2015-11-17

    4Anobium. Morning, I now have an updated GCB.exe latest build, but for the life of me I cannot remember what I have to do to have IDE talk to my PIC2 or PIC3 programmer. Still that is a problem for some other time.

    After installing the new GCB.exe last night I had another read through the Microchip 10F202 datasheet, not that I’m any wiser for it but something seemed to point me to the #config MCLRE= which is normally in the OFF mode.

    Tried that out this morning, but that is not the answer. As it as it resets the entire device on an input which is not really what I’m looking for.

    Do you still want to see my coding effort ? (no laughing please!)

    Regards
    Keith

     
  • Keith

    Keith - 2015-11-17

    (psst. I'm not Mick!)

    This code is a simple latching switch for a battery powered module for a young lad with learning difficulties. It works quite well but I need to make it go to sleep when it switched off.

    ;Chip Settings
     #chip 10F202,4
    #config MCLRE=OFF, CP=OFF, WDT=OFF, OSC=INTRC
    
    
    'Defines (Constants)
    #define Mag_Input GPIO.3
    #define  activity_led GPIO.2
    #define Forward_Output GPIO.0
    #define Reverse_Output GPIO.1
    
    
    '
    '      Pinout Data 10F202
    '             --------
    '       GPO -|1      6|- GP3
    '       VSS -|2      5|- VDD
    '       GP1 -|3      4|- GP2
    '             --------
    
    
    
    dir GPIO b'01000'               'Ports 0, 1, 2, & 4 Output Port 3 Input
    
    
    
    
    call Initialise
    
    Switch_Count = 0
    flag_swap = 0
    flag = 0
    Mag_Input = 0
    
    Main:
    
    
    If Mag_Input = 1 Then
       Wait 500 ms
       flag = 0
       call Flag_on
    End If
    
    If Mag_Input = 0 Then
       Wait 500 ms
       flag = 1
       Call Flag_on
    End If
    
    
    goto main
    
    
    sub Flag_on
    if flag = 1 then
       flag_swap =1
    end if
    
    if flag = 0 and flag_swap = 1 then
       flag_swap = 0
       Sw_next = 1
    call Switch
    end if
    
    end sub
    
    
    
    Sub Switch
    if Sw_next = 1 and Switch_Count = 0 then
        set Forward_Output on:Set activity_led On
        Sw_next = 0
        Switch_Count = 1
        goto Main
    end if
    
    if Sw_next = 1 and Switch_Count = 1 then
       set Forward_Output off:Set activity_led Off
        Switch_Count = 0
    
    ' asm SLEEP
    
        goto Main
    end if
    
    
    end sub
    
    
    'Initialise
    
    Sub Initialise
        count = 0
    For init = 0 To 2
        Set activity_led on
        Wait 200 ms
        Set activity_led Off
        Wait 200 ms
    
    Next
           set Forward_Output off
    End Sub
    

    Sorry but I don't seem to be able to stop the first few lines of code displaying in huge characters. I did work it a while back but for the life of me I cannot remeber !

     

    Last edit: Anobium 2015-11-17
  • Anobium

    Anobium - 2015-11-17

    Which port do have the switch to raise from sleep? It is gpio.3 ? As all the other ports are inputs.

    PS... I edited your posting.... have a looksy.

     
  • Keith

    Keith - 2015-11-17

    Yes, GPIO 3 is the Switch.

    How did you sort out my posting... ? as I said, I couldn't remember what it was..

    I have sorted my IDE to write to my PICkit2 by deleting the appropriate rem statement in the flashpic batch file, but I am struggling to get my PICkit3 to work. No big cheese though – I can live with it like that.
    Regards

    Keith, (AKA Mick)

     
  • Anobium

    Anobium - 2015-11-17

    You may need to read the ports prior to sleep. I have read this before.

    readallports = GPIO
    SLEEP
    

    And, to fix the posting. If you edit it again, and, review the tilders - this fixes it.

     
  • Keith

    Keith - 2015-11-17

    The instruction 'readallports compiles okay, but the chip still falls int a coma to where only a power up restart brings it back to life

    Unless I doing something stupid (again) or haven't put it into the right place:

    if Sw_next = 1 and Switch_Count = 0 then
    set Forward_Output on:Set activity_led On
    Sw_next = 0

    Switch_Count = 1
    goto Main
    

    end if

    if Sw_next = 1 and Switch_Count = 1 then
    set Forward_Output off:Set activity_led Off
    Switch_Count = 0

    readallports = GPIO
        SLEEP
    
    goto Main
    

    end if

    Regards
    Keith

     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.