Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] mplab simulator problem

Status
Not open for further replies.

Resistor123

Newbie level 5
Joined
Apr 3, 2006
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,326
I am trying to simulate one on the examples (using pic 16F690).

The program should make Port C , bits 0,1,2,3 light (hi) one at a time.

Only Port C, bits 2 and 3 light bits 0 and 1 are off (lo) all the time (using the simulator). Why?

The program is:
Code:
; PICkit 2 Lesson 3 - "Rotate"
;
; Extends Lesson 2 to sequence through the display LEDs.
;
; *******************************************************************
; * See Low Pin Count Demo Board User's Guide for Lesson Information*
; *******************************************************************
; * NOTE: The PIC16F690 requires the AC162061 header for debugging  *
; *******************************************************************

#include <p16F690.inc>
     __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)

     cblock 0x20
Delay1              ; Assign an address to label Delay1
Delay2
Display             ; define a variable to hold the diplay
     endc
     
     org 0
Start:
     bsf       STATUS,RP0          ; select Register Page 1
     clrf      TRISC               ; make IO PortC all output
     bcf       STATUS,RP0          ; back to Register Page 0
     movlw     0x08
     movwf     Display
MainLoop:
     movf      Display,w           ; Copy the display to the LEDs
     movwf     PORTC
OndelayLoop:
     decfsz    Delay1,f            ; Waste time.  
     goto      OndelayLoop         ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
     decfsz    Delay2,f            ; The outer loop takes and additional 3 instructions per lap * 256 loops
     goto      OndelayLoop         ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
                                   ; call it a two-tenths of a second.
     
     bcf       STATUS,C            ; ensure the carry bit is clear
     rrf       Display,f
     btfsc     STATUS,C            ; Did the bit rotate into the carry?
     bsf       Display,3           ; yes, put it into bit 3.
     goto      MainLoop
     end
 
Last edited by a moderator:

Check the ANSEL and ANSELH registers. I haven't looked at the data sheet but it's possible they are configured by default to analog mode.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top