picbasic +12c508a+soft_stack error


Closed Thread
Results 1 to 37 of 37

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Tim's compiled to 15 words.

    Here's 13 ...   Note: LED's go to VDD
    Code:
        list      p=16F628A
        #include "P16F628A.inc"
        errorlevel  -302        ; suppress message 302 from list file
        __CONFIG _CP_OFF & _BODEN_ON & _MCLRE_ON & _WDT_ON & _PWRTE_ON & _LVP_OFF & _INTOSC_OSC_NOCLKOUT
    
        clrf    PORTB         ; PORTB all 0's
        bsf	    STATUS,RP0    ; Bank 1
        bcf	    OPTION_REG, 0 ; 1:64 prescaler to WDT
        bcf     TRISB, 0      ; set RB0 to output
        bsf     STATUS, C     ; set carry flag for rotation
    Loop
        btfss   TMR2, 3       ; switch Left/Right every 8 times
        rlf	    TRISB,F       ; rotate Left across TRISB
        btfsc   TMR2, 3
        rrf     TRISB,F       ; rotate Right across TRISB
        btfsc   STATUS, C     ; No sleep if output rotated into carry
        sleep                 ; nite nite
        incf    TMR2          ; Timer2 used for it's 00 value on reset.
        goto    Loop          ; Repeat
    EDIT: Rats!
    While it works in MPSIM, it's not going to do it on the real thing.
    Time for a breadboard.

    <br>
    DT

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    OK, ignore the last one. That's what I get for using a simulator.

    This is 14 WORDS, 1 less than Tim's.
    At least it beats him

    Code:
        list      p=16F88
        #include "P16F88.inc"
        errorlevel  -302        ; suppress message 302 from list file
        __CONFIG  _CONFIG1, _XT_OSC & _CP_OFF & _BODEN_ON & _MCLR_ON & _WDT_ON & _PWRTE_ON & _LVP_OFF
    
        clrf    PORTB         ; PORTB all 0's
        bsf     STATUS,RP0    ; Bank 1
        bcf     OPTION_REG, 0 ; 1:64 prescaler to WDT
        bcf     TRISB, 0      ; RB0 output
    Loop
        sleep                 ; nite nite
    
        btfss   SPBRG,0       ; SPBRG used for it's 00 reset value   
        rlf     TRISB,F       ; rotate Left across TRISB
        btfsc   SPBRG,0
        rrf     TRISB,F       ; rotate Right across TRISB
        
        btfss   TRISB, 7      ; At LED7? - go the other way
        incf    SPBRG,F
        btfss   TRISB, 0      ; At LED0? - go the other way
        incf    SPBRG,F 
        
        goto    Loop          ; Repeat
    LED's go to VDD.
    Tested, working on 16F88, should be the same (except configs) on 16F628A.
    <br>
    DT

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    yup.. hence why i never trust sim...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Nice work DT.

    Here's one at 13 words.
    Code:
      list      p=16F628A
      #include "P16F628A.inc"
      errorlevel  -302
      __CONFIG _CP_OFF & _BODEN_ON & _MCLRE_OFF & _WDT_ON & _PWRTE_ON & _LVP_OFF & _INTOSC_OSC_NOCLKOUT
    
       clrf  PORTB        ; clear port
       bsf   STATUS,RP0   ; Bank 1
       bcf   TRISB,0      ; RB0 = output
       bcf   OPTION_REG,0 ; 1:64 prescaler to WDT
    
    Left
       sleep             ; go to sleep for 64 * 18mS ~1 second
       rlf   TRISB,F     ; rotate bit across portb from lsb to msb
       btfsc TRISB,7    
       goto  Left
    	
    Right
       sleep          ; go to sleep for 64 * 18mS ~1 second
       rrf   TRISB,F  ; rotate bit across Portb from msb to lsb
       btfsc TRISB,0
       goto  Right
       goto  Left     ; now rotate back to the left.
    	
       End
    Last edited by Bruce; - 19th December 2007 at 19:17.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Oh Yeah! Very nice Bruce.

    Now that's going to be hard to beat.
    If you don't hear from me for a month.
    You'll know what happened.
    DT

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Oh Yeah! Very nice Bruce.

    Now that's going to be hard to beat.
    If you don't hear from me for a month.
    You'll know what happened.
    I just checked on my '628A on my breadboard...about a ba-zillion times...
    I set up code/hardware to do nothing but RESET, and put Port B onto a bank of LEDs, Vdd on the other side of the LED.
    EACH time, Port B came up ZERO...no LEDs lit up, until I set a TRIS bit for output.
    So, my submission...
    Coming in at 12 bytes...

    Code:
      list      p=16F628A
      #include "P16F628A.inc"
      errorlevel  -302
      __CONFIG _CP_OFF & _BODEN_ON & _MCLRE_OFF & _WDT_ON & _PWRTE_ON & _LVP_OFF & _INTOSC_OSC_NOCLKOUT
    
    ;   clrf  PORTB        ; clear port - not required on my breadboard, might be different on others
       bsf   STATUS,RP0   ; Bank 1
       bcf   TRISB,0      ; RB0 = output
       bcf   OPTION_REG,0 ; 1:64 prescaler to WDT
    
    Left
       sleep             ; go to sleep for 64 * 18mS ~1 second
       rlf   TRISB,F     ; rotate bit across portb from lsb to msb
       btfsc TRISB,7    
       goto  Left
    	
    Right
       sleep          ; go to sleep for 64 * 18mS ~1 second
       rrf   TRISB,F  ; rotate bit across Portb from msb to lsb
       btfsc TRISB,0
       goto  Right
       goto  Left     ; now rotate back to the left.
    	
       End

    Somebody else check this out and see what happens.
    As I stated, maybe it's my breadboard, maybe it's my 628A (I've only got 1 left), maybe it's the rise time on my PSU.

    EDIT: Datasheet says that the port registers come up in an unknown state. Apparently, in this case, I now know my state...
    Last edited by skimask; - 19th December 2007 at 21:23.

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    It might work on one series, but I wouldn't count on it as being reliable across the board.
    I have seen various PICs come up with totally random values in port latches at POR, so
    you really do need to clear portb latches first if it's to be reliable.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  2. Optimizing DIV
    By skimask in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 22nd September 2008, 05:58
  3. pbp245 compliation error
    By Woodzy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 25th July 2006, 06:59
  4. 16F88 Compile error
    By Toley00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd November 2005, 01:22
  5. Compiler/Assembler Error
    By LT_Pic in forum General
    Replies: 7
    Last Post: - 21st July 2005, 10:47

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