Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Strange, not sure if a bug or just me.

Help
lhatch
2013-01-09
2013-05-30
  • lhatch
    lhatch
    2013-01-09

    The BASIC and  .ASM below.  Search for ~~   to see the lines in question or bug.  I kill the two line and assembled by hand for now.

    #chip 12F675, 4
    #config osc = int
    #define TRIG GPIO.0                'INPUT pin from infinias
    #define R1 GPIO.1                  'R1 pulse to turn on
    #define R2 GPIO.2                  'R2 pulse to turn off
    Dir TRIG In
    Dir R1 Out
    Dir R2 Out
    'R1 pulse is ON  R2 is off
    Dim last as bit
    top:
        if TRIG = on then
           last=on
           set R1 on
           wait 1500 msec
           set R1 off
        else
           last=off
           set R2 on
           wait 1500 msec
           set R2 off
        end if
        do until TRIG <> last
        loop
    goto top
         
    end
    ************************************************************************************   THE ASM
    ;Program compiled by Great Cow BASIC (0.9 19/7/2011)
    ;Need help? See the GCBASIC forums at http://sourceforge.net/projects/gcbasic/forums,
    ;check the documentation or email w_cholmondeley at users dot sourceforge dot net.
    ;********************************************************************************
    ;Set up the assembler options (Chip type, clock source, other bits and pieces)
     LIST p=12F675, r=DEC
    #include <P12F675.inc>
     __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF
    ;********************************************************************************
    ;Set aside memory locations for variables
    DELAYTEMP   EQU 32
    DELAYTEMP2  EQU 33
    SysWaitTempMS   EQU 34
    SysWaitTempMS_H EQU 35
    SYSBITVAR0  EQU 36
    ;********************************************************************************
    ;Vectors
        ORG 0
        goto    BASPROGRAMSTART
        ORG 4
        retfie
    ;********************************************************************************
    ;Start of program memory page 0
        ORG 5
    BASPROGRAMSTART
    ;Call initialisation routines
        call    INITSYS
    ;Start of the main program
        banksel TRISIO
        bsf TRISIO,0
        bcf TRISIO,1
        bcf TRISIO,2
    TOP
        banksel GPIO
        btfss   GPIO,0
        goto    ELSE1_1
        bsf SYSBITVAR0,0
        bsf GPIO,1
        movlw   220
        movwf   SysWaitTempMS
        movlw   5
        movwf   SysWaitTempMS_H
        call    Delay_MS
        bcf GPIO,1
        goto    ENDIF1
    ELSE1_1
        bcf SYSBITVAR0,0
        bsf GPIO,2
        movlw   220
        movwf   SysWaitTempMS
        movlw   5
        movwf   SysWaitTempMS_H
        call    Delay_MS
        bcf GPIO,2
    ENDIF1
    SysDoLoop_S1                                                   <---------------------------------~~
        goto    SysDoLoop_S1                           <---------------------------------~~
    SysDoLoop_E1
        clrw
        btfsc   GPIO,0
        xorlw   255
        btfsc   SYSBITVAR0,0
        xorlw   255
        btfsc   STATUS,Z
        goto    SysDoLoop_E1
        goto    TOP
        goto    BASPROGRAMEND
    BASPROGRAMEND
        sleep
        goto    BASPROGRAMEND
    ;********************************************************************************
    Delay_MS
        incf    SysWaitTempMS_H, F
    DMS_START
        movlw   142
        movwf   DELAYTEMP2
    DMS_OUTER
        movlw   1
        movwf   DELAYTEMP
    DMS_INNER
        decfsz  DELAYTEMP, F
        goto    DMS_INNER
        decfsz  DELAYTEMP2, F
        goto    DMS_OUTER
        decfsz  SysWaitTempMS, F
        goto    DMS_START
        decfsz  SysWaitTempMS_H, F
        goto    DMS_START
        return
    ;********************************************************************************
    INITSYS
        bcf ADCON0,ADON
        bcf ADCON0,ADFM
        banksel ANSEL
        clrf    ANSEL
        movlw   7
        banksel CMCON
        movwf   CMCON
        clrf    GPIO
        return
    ;********************************************************************************
     END
    
     
  • lhatch
    lhatch
    2013-01-11

    To make it shorter/clearer.  BUMP…  help…

    This part of the GCBASIC code from above (first post).

    do until TRIG <> last 
    loop
    

    generates  below ASM code  (see italics, that part should not be there, I have to remove it and gasm it by hand.

    [i]SysDoLoop_S1
        goto SysDoLoop_S1 
    [/i]
    SysDoLoop_E1
        clrw 
        btfsc GPIO,0 
        xorlw 255 
        btfsc SYSBITVAR0,0 
        xorlw 255 
        btfsc STATUS,Z 
        goto SysDoLoop_E1 
        goto TOP
    
     
  • Frank
    Frank
    2013-01-12

    It does appear to be a bug. It produces the same assembly even in the latest update from 5/11/12.

    To avoid having to edit the assembly by hand you can change the do loop to -

        do
        loop until TRIG <> last
    

    That seems to compile okay. Alternatively if you stick an assembly nop in the original loop that also compiles alright.

        do until TRIG <> last
            nop
        loop
    
     
  • lhatch
    lhatch
    2013-01-12

    Federon

    Yea, I think I will throw a wait or sleep or something in there I guess.  It is not time critical.  Thanks for testing it.