gnupic: Thread: Gpsim and PIC port question


[<<] [<] Page 1 of 1 [>] [>>]
Subject: Gpsim and PIC port question
From: Phil ####@####.####
Date: 6 Feb 2004 12:22:42 -0000
Message-Id: <200402062138.52351.phil@spiderweb.com.au>

Hello everyone,

First, I'd like to congratulate the developers of this excellent debugging 
application. It's quite amazing, now to my question.

I'm trying to debug the follow code snippet which actually works except for an 
odd bug after the second wait loop. My debugging efforts are hampered because  
gpsim does not display the state of the port.

Also, during debugging, gpsim falls through the first loop no matter whether 
the input is high or not. The opposite occurs at the second wait; gpsim never 
passes out of the loop. During normal operation the PIC does wait for the 
inputs to change.

Is this a failing of gpsim or, more likely, a lack of understanding on my 
part?

This is part of the initialising code:

        bsf         STATUS,RP0    ; Select Register Bank 1
        movlw    b'00000001'   ;Port A0 input, the rest outputs
        movwf    TRISA
        movlw    0x06
        movwf    ADCON1        ; set porta to digital i/o
        bcf          STATUS,RP0  ; select Register Bank 0

And this is what I'm trying to debug:

wait  btfsc      PORTA, 0       ;wait for A0 to go low
        goto       wait

        useful code here between the loops

wait2  btfss    PORTA, 0       ;wait for A0 to go high again
 	goto       wait2

The PIC that I'm using is a 16F876A and I have told gpsim that I'm using a 
16F873 because the 16F876A is not supported in version 0.21.0.

Is the problem my code, gpsim or my use of gpsim?

-- 
Regards,
Phil.


Subject: Re: Gpsim and PIC port question
From: James Cameron ####@####.####
Date: 6 Feb 2004 13:06:27 -0000
Message-Id: <20040206123523.GB27255@us.netrek.org>

G'day Phil,

Would you happen to have given any stimulus files to gpsim, or are you
letting it run freely?  Without any input to the contrary, gpsim will
assume PORTA remains zero.

So of course the simulated code will loop at wait2.

-- 
James Cameron    ####@####.####     http://quozl.netrek.org/
Subject: Re: Gpsim and PIC port question
From: Scott Dattalo ####@####.####
Date: 6 Feb 2004 14:41:24 -0000
Message-Id: <Pine.LNX.4.44.0402060552450.14968-100000@ruckus.brouhaha.com>

On Fri, 6 Feb 2004, James Cameron wrote:

> G'day Phil,
> 
> Would you happen to have given any stimulus files to gpsim, or are you
> letting it run freely?  Without any input to the contrary, gpsim will
> assume PORTA remains zero.
> 
> So of course the simulated code will loop at wait2.

Thanks James,

This is the answer I would've given too.

There are several examples scattered in various places illustrating how 
stimuli can be used. (One of my action items in the current gpsim clean up 
is to collect these into something more useful.)

Perhaps the easiest stimulus you could create is one where you steal a 
spare I/O pin on your PIC and tie it to your PORTA-0 pin. There's an 
example in the gpsim help. Type 'help attach' at the gpsim command line. 
The 'attach' command is used to connect nodes to stimuli. 

gpsim> node pin2pin_test
gpsim> attach pin2pin_test porta0 portb0
gpsim> node
Node List
pin2pin_test
	porta0
	portb0
gpsim> 

Now, you can write code in your PIC application that toggles PortB-0 and 
it will drive PortA-0 (assuming portb-0 is an output...)

---

Another option is to forget stimuli and to manually set the state of the 
I/O pin. At the command line:

gpsim> x porta 1

This will set porta to the value of 1.

Or from the gui, you can double click on the I/O pin in the breadboard 
window.

Scott

[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.