SERIAL ROUTINE PROBLEM

Discussion in 'Embedded Systems and Microcontrollers' started by twister, Apr 26, 2009.

  1. twister

    Thread Starter Member

    Mar 31, 2009
    15
    0
    I am trying to have serial communication in 16F88 over hardware UART. However when i tried the code below, it just halt there and nothing happened.

    I declared the temp1 as follows:
    Code ( (Unknown Language)):
    1.     cblock            0x20
    2.     tmp1
    3.     endc
    And the serial communication as follows:
    Code ( (Unknown Language)):
    1. store_Ah:
    2.     mov16    dd+2,AmpHours
    3.     call     Serial_sent
    4.  
    5. Serial_sent:
    6.    banksel      SPBRG
    7.    movlw      .25                  ; 9.6kbps
    8.    movwf      SPBRG
    9.    movlw      b'00100100'      ; brgh = high (2)
    10.    movwf      TXSTA            ; enable Async Transmission, set brgh
    11.  
    12.    ; Provide a settling time for startup
    13.    banksel      tmp1
    14.    clrf       tmp1
    15.    settle
    16.    decfsz       tmp1, f
    17.    goto       settle
    18.  
    19.  
    20.    ; Send a character through the UART
    21. loop
    22.    movf AmpHours, w
    23.    call Send
    24.    movf AmpHours+1, w
    25.    call Send
    26.    goto      $
    27.  
    28. ;----------------------
    29. ; SEND function
    30. ;----------------------
    31. Send
    32.    banksel      TXREG
    33.    movwf       TXREG            ; Send data which has been stored in W
    34.  
    35. trans_wt
    36.    banksel      TXSTA
    37.    btfss       TXSTA, TRMT         ; Loop until data is sent
    38.    goto      trans_wt      
    39.    return
    with baud rate 9600. AmpHours as a 16 bits words.
     
Loading...