I'm totally new to PIC uC. However, I've learned some basic knowledge on assembly language (motorola-68K) before.
I'm going to use the PIC16F877A chip to design a stepper motor controller. There are 4 ports that I'm going to use as an input and output (digital) for my design.
PORTA - 2 bits input -RA0 & RA1
PORTB - 4 bits output - RB0, RB1, RB2, RB3
PORTC - 2 bits input - RC0, & RC1
PORTD - 4 bits output -RD0,RD1, RD2, RD3
below is part of my program.
- CODE: SELECT_ALL_CODE
list p=16f877a
include "p16f877a.inc"
ERRORLEVEL -302 ;remove message about using proper bank
__CONFIG _CP_OFF & _CPD_OFF & _LVP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_OFF & _XT_OSC
Index1 equ b'0001'
org 0x000 ;Reset vector
goto Main
Main
bcf STATUS,RP0
bcf STATUS,RP1
clrf PORTA
bsf STATUS,RP0
movlw 0x06
movwf ADCON1
movlw 0X03
movwf TRISA
bcf STATUS,RP0
bcf STATUS,RP1
clrf PORTB
bsf STATUS,RP0
movlw 0x06
movwf ADCON1
movlw 0X03
movwf TRISB
bcf STATUS,RP0
bcf STATUS,RP1
clrf PORTC
bsf STATUS,RP0
movlw 0x06
movwf ADCON1
movlw 0X00
movwf TRISC
bcf STATUS,RP0
bcf STATUS,RP1
clrf PORTD
bsf STATUS,RP0
movlw 0x06
movwf ADCON1
movlw 0X00
movwf TRISD
movlw Index1
movwf PORTB
movlw Index1
movwf PORTD
end
So my question is:
(1) Am I configure the port correctly?
(2) As you can see that during the last 4 line of the program, I wanted to set the initial value of the PORTB and PORTD to become "0001" in binary. Therefore I expect to see 0x01h value when I run through the simulation by using MPLAB SIM right? But I notice that the value for PORTB & PORTD just doesn't changed and it stay 0x00h all the way during the simulation. Could any one tell me what actually went wrong here?
Thanks!