can't write to port a 16f684

Discussion in 'Embedded Systems and Microcontrollers' started by adrenalina, Jan 6, 2012.

  1. adrenalina

    Thread Starter Active Member

    Jan 4, 2011
    78
    3
    I'm writing a program to move a servo on a 16f684 in assembly and I ran into a very simple problem that I just can't figure out. I am not able to write anything to port a. I'm simulating it with mplab sim and there is no change on port a. I have all of the code written and its just that that is the problem.

    The code below is the beginning of my program. port a is supposed to start cleared, but just to check if it was working I write to it. There is no change bit 0 doesn't go high. I just can't figure out what I'm missing.

    Code ( (Unknown Language)):
    1.  
    2. Start   ;configure ports
    3.         banksel TRISA           ; configure PORTA
    4.         movlw   b'111110'       ; pin 0 only output
    5.         movwf   TRISA
    6.  
    7.         ; configure TMR0
    8.         movlw   0<<T0CS|0<<PSA|b'110'   ; timer mode (T0CS=0), prescaler, 1:128
    9.         banksel OPTION_REG
    10.         movwf   OPTION_REG
    11.  
    12.         ; initialize variables
    13.         movlw   .90
    14.         banksel pos
    15.         movwf   pos             ; default position 90 degrees
    16.         banksel PORTA
    17.         movlw   b'111111'
    18.         movwf   PORTA           ; set servo pin low
    19.  
    20.         ; configure interrupts
    21.         movlw   1<<GIE|1<<T0IE  ; enable timer0 and global interrupts
    22.         movwf   INTCON
    23.  
     
    Last edited: Jan 6, 2012
  2. adrenalina

    Thread Starter Active Member

    Jan 4, 2011
    78
    3
    Problem solved!
    I just remembered to be able to use port a as digital IO you have to disable the comparator and analog input from CMCON0 register and ANSEL register.
     
Loading...