gnupic: simulating pic 101 flasher


Previous by date: 18 Nov 2006 16:59:48 +0000 Re: [gnupic] gpasm macros/defines, Tamas Rudnai
Next by date: 18 Nov 2006 16:59:48 +0000 gpsim & Mandriva 2007, Pete
Previous in thread:
Next in thread:

Subject: simulating pic 101 flasher
From: "Maxim Wexler" ####@####.####
Date: 18 Nov 2006 16:59:48 +0000
Message-Id: <a0811460611180859q36f8696bi7803cfcdbe5fa6c9@mail.gmail.com>

Hello group,

Here's a simple led flasher from the web adapted for gpsim:

; File CHASER.ASM
; Blinks LEDs on outputs (Port B) in a rotating pattern.
; Reverses direction if port A, Bit 0, is high.
    LIST P=16f84
    include "p16f84.inc"
;    include <p16f84.inc>
;    __config _RC_OSC & _WDT_OFF & _PWRTE_ON
; Give names to 2 memory locations (registers)
J     equ H'1F' ; J = address hex 1F
K     equ H'1E' ; K = address hex 1E


; Program
    org 0 ; start at address 0

    ;simulate gnd
    tris PORTA
    clrf PORTA

    ; Set Port B to output and initialize it.
    movlw B'00000000' ; w := binary 00000000
    tris PORTB ; copy w to port B control reg
    movlw B'00000001' ; w := binary 00000001
    movwf PORTB ; copy w to port B itself
    bcf STATUS,C ; clear the carry bit
    ; Main loop. Check Port A, Bit 0, and rotate either left
    ; or right through the carry register.
mloop:
    ; is this necessary?
;    btfss PORTA,0 ; skip next instruction if bit=1
    goto m1
    rlf PORTB,f ; rotate port B bits to left
    goto m2
m1:
    rrf PORTB,f ; rotate port B bits to right
m2:
    ; Waste some time by executing nested loops
    movlw D'2' ;  suitable for very slow simulation
    movwf J ; J := w
jloop:     movwf K ; K := w
kloop:     decfsz K,f ; K := K-1, skip next if zero
goto     kloop
decfsz     J,f ; J := J-1, skip next if zero
goto     jloop
goto     mloop ; do it all again
end

Heres the stc file modeled after mod_test.stc:

# Script for testing modules
#
# The purpose of this script is to load a simple
# program for a PIC (16F84), load the gpsim module library,
# and illustrate how modules can be connected to pics.


load s chaser.cod

# load the gpsim module library. Not that this is a 'shared library'.
# If the library fails to load then 1) it's not installed (try installing
# gpsim) 2) or the path to library is not available (see the documentation
# on modules).

module library libgpsim_modules.so

# display all of the modules that are in the library:
# module list

# load modules from the module library and give them names

module load led D0
module load led D1
module load led D2
module load led D3
module load led D4
module load led D5
module load led D6
module load led D7

# create nodes that can connect the Pic and the leds.

node Cat
node An0
node An1
node An2
node An3
node An4
node An5
node An6
node An7

attach Cat porta0 D0.Cat
attach An0 portb0 D0.An0
attach Cat porta0 D1.Cat
attach An1 portb1 D1.An1
attach Cat porta0 D2.Cat
attach An2 portb2 D2.An2
attach Cat porta0 D3.Cat
attach An3 portb3 D3.An3
attach Cat porta0 D4.Cat
attach An4 portb4 D4.An4
attach Cat porta0 D5.Cat
attach An5 portb5 D5.An5
attach Cat porta0 D6.Cat
attach An6 portb6 D6.An6
attach Cat porta0 D7.Cat
attach An7 portb7 D7.An7


Here's the error msgs:

***ERROR: syntax error, unexpected LITERAL_STRING_T, expecting EOLN_T while
parsing:
'D0.Cat'
 Last command: attach Cat porta0 D0.Cat

***ERROR: syntax error, unexpected LITERAL_STRING_T, expecting EOLN_T while
parsing:
'D1.Cat'
 Last command: attach Cat porta0 D1.Cat

***ERROR: syntax error, unexpected LITERAL_STRING_T, expecting EOLN_T while
parsing:
'D2.Cat'
 Last command: attach Cat porta0 D2.Cat

***ERROR: syntax error, unexpected LITERAL_STRING_T, expecting EOLN_T while
parsing:
'D3.Cat'
 Last command: attach Cat porta0 D3.Cat

***ERROR: syntax error, unexpected LITERAL_STRING_T, expecting EOLN_T while
parsing:
'D4.Cat'
 Last command: attach Cat porta0 D4.Cat

***ERROR: syntax error, unexpected LITERAL_STRING_T, expecting EOLN_T while
parsing:
'D5.Cat'
 Last command: attach Cat porta0 D5.Cat

***ERROR: syntax error, unexpected LITERAL_STRING_T, expecting EOLN_T while
parsing:
'D6.Cat'
 Last command: attach Cat porta0 D6.Cat

***ERROR: syntax error, unexpected LITERAL_STRING_T, expecting EOLN_T while
parsing:
'D7.Cat'
 Last command: attach Cat porta0 D7.Cat

My thinking here was to use a0 as common ground(like mod_test) since a led
is a led whether a discrete part or part of pkg like a 7-seg display, no?

Maxim

Previous by date: 18 Nov 2006 16:59:48 +0000 Re: [gnupic] gpasm macros/defines, Tamas Rudnai
Next by date: 18 Nov 2006 16:59:48 +0000 gpsim & Mandriva 2007, Pete
Previous in thread:
Next in thread:


Powered by ezmlm-browse 0.20.