MPLAB 8.85 problem PORT SETTING AS INPUT

Status
Not open for further replies.

Noman Yousaf

Full Member level 4
Joined
Nov 19, 2003
Messages
208
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,763
i m using MPLAB 8.85.
can anybody tell me that how can i use or change the state of ports my self? is that possible or not.
i just wrote a program to turn on an led by making a port hi but when i make the port line hi, in "SFR register" window it goes lo itself without any action. i m sending the code and screen short of the mplab screen.


SOFTWARE IS AS FOLLOWS.


Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
LIST   P=PIC16F676
                PROCESSOR  16F676
                #include "P16F676.INC"
 
 
        __CONFIG   _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
;THIS IS SIMPLE SOFTWARE TO TURN ON THE LED (PORTC,0)BY CHANGING THE PORTA,5 
                ORG             0
 
                        IN_SW   EQU             5               ;PORTA,5 AS INPUT
 
                        LED             EQU             0               ;PORTC,0 OUTPUT
 
 
 
                        BSF                     STATUS,RP0              ;SELECT BANK1
                        CLRF            TRISC                   ;MAKE PORTC OUTPUT
                        MOVLW           0FFH                    ;MAKE WREG 0FFH
                        MOVWF           TRISA                   ;MAKE PORTA INPUT
                        CLRF            ANSEL                   ;MAKE ALL ADC LINES AS DIGITAL INPUT
 
                        BCF                     STATUS,RP0              ;SELECT BANK0
                        
                        
MAIN
                        BTFSS           PORTA,IN_SW
                        GOTO            MN1
                        BSF                     PORTC,LED
                        GOTO            MAIN
 
MN1
                        BCF                     PORTC,LED
                        GOTO            MAIN
 
 
        END

 
Last edited by a moderator:

When the PC is pointing to 1st instruction in MAIN then you have to set PORTA as 00000001 in SFR window. Also see if you can see IN_SW in variables window. Try to set it there. For better help zip and post your mplab project files.
 

File is attached
please note that porta,5 is input.
 

Attachments

  • TEST_IDE.rar
    384 bytes · Views: 81

File is attached
please note that porta,5 is input.

Hi,

You need to use Mplab, Debugger , Stimulus - a simple example is shown with your code in the screenshot.

Just Step though your code and Fire the change to pin RA5.

See Mplabs Help, Mplab Sim , Stimulus.

This link is also helpful
**broken link removed**
 

Attachments

  • 000036.jpg
    101 KB · Views: 98
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…