running MPLAB simulation

Thread Starter

sanwa

Joined Jan 18, 2009
36
Well guys ....
How do I run simulation in MPLAB for .asm code?
I just have the one on make files and build...
Sorry i am new to MPLAB...
 

Thread Starter

sanwa

Joined Jan 18, 2009
36
I was testing my code on UART:
Rich (BB code):
    list            p=16F88, r=DEC
    errorlevel        -302
    #include         <p16f88.inc>

    __config         _CONFIG1, _BODEN_OFF & _WDT_OFF & _LVP_OFF & _MCLR_OFF & _PWRTE_ON & _INTRC_IO

;----------------------
; DECLARE VARIABLES
;----------------------

cblock            0x20
tmp1
endc

;----------------------
; START
;----------------------
    org         0
main
    banksel        CMCON
    movlw         7
    movwf         CMCON                ; CMCON = 7 set comperators off

    banksel        ANSEL
    clrf        ANSEL

    banksel        TRISA
    clrf        TRISA
    clrf        TRISB

    banksel        SPBRG
    movlw        0x19                ; 0x19=9600 bps (0x0C=19200 bps)
    movwf        SPBRG
    movlw        b'00100100'            ; brgh = high (2)
    movwf        TXSTA                ; enable Async Transmission, set brgh

    banksel        RCSTA
    movlw         b'10010000'            ; enable Async Reception
    movwf        RCSTA


    ; Provide a settling time for startup
    banksel        tmp1
    clrf         tmp1
settle
    decfsz         tmp1, f
    goto         settle


    ; Send a character through the UART
loop
    movlw        'A'
    call        send

    movlw        'B'
    call        send

    goto        $

;----------------------
; SEND function
;----------------------
send
    banksel        TXREG
    movwf         TXREG                ; Send data which has been stored in W

trans_wt
    banksel        TXSTA
    btfss         TXSTA, TRMT            ; Loop until data is sent
    goto        trans_wt        
    return

    end
I am refering to section 18.7 which using USART/UART. I followed the steps...I get this message when i build it:

Rich (BB code):
UART-W0004: Attempt to receive data when Port pin direction for UART is set to an output (0).
Am i correct or....?
 

t_n_k

Joined Mar 6, 2009
5,455
From Section 11 of PIC16F88 user guide

"Bit SPEN (RCSTA<7>) and bits TRISB<5,2> have to
be set in order to configure pins, RB5/SS/TX/CK and
RB2/SDO/RX/DT, as the Universal Synchronous
Asynchronous Receiver Transmitter."

From what I can see in your .asm code you've only cleared TRISB ....
 

t_n_k

Joined Mar 6, 2009
5,455
One of the annoying things about PIC programming is the occasional imponderable - particularly with port lines.

I am using a PIC18Fxxx to transmit data - no receive required.

In the PIC18F case it is the TRISC register bits 6 & 7 that are equivalent to to TRISB bits 5 & 2.

I normally just configure USART port TRISC to 0xC0 without much consideration.

If I clear my TRISC [bits 6 & 7 low] - transmission stops altogether.

If I set TRISC to 0x40 [bit 6 high] I don't get transmission.

If I set TRISC to 0x80 or 0xC0 [bit 7 high - bit 6 don't care] transmission starts.

It looks like the bit for RX/DT or RB2/SDO/RX/DT in your case must be set for transmit to occur.

Go figure ...?:confused:
 

t_n_k

Joined Mar 6, 2009
5,455
Sorry - ignore that last post. I was looking at the wrong code. The module involved does receive data. Disabling the receive line would cause it to stop anyway.

I can't explain your problem.
 
Top