Gabriel Caffese wrote: >=20 > Hello everyone, >=20 > Does anynoe have sample code for learning to use 16F627=B4s USAR= T ?? > Any help//code would be appreciated. >=20 > Thanks.- ; =09Title "RS232 TEST" ; =09list P =3D 16F628 ; =09include "P16F628.inc" ; ; CRYSTAL SPEED =3D 4000000Hz ; =09errorlevel -(305), -(302), -(306) ; ; ------------------ ; CONFIGURATION FUSE ; ------------------ ; =09__CONFIG _CP_OFF & _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _BODEN_OFF & _LVP_ON & _MCLRE_ON ; ; -------------------- ; USER RAM DEFINITIONS ; -------------------- ; =09CBLOCK 0x20 RxHold =09ENDC ; ; probably not needed, but I do it anyway ; ; RX=09RB1=09IN ; TX=09RB2=09OUT HI =09org 0000h Start=09movlw b'00000000' =09movwf PORTA =09movlw b'00000100' =09movwf PORTB =09bsf STATUS,RP0 =09movlw b'00000000' =09movwf TRISA =09movlw b'00000010' =09movwf TRISB =09bcf STATUS,RP0 ; ; ----------------------- ; DISABLE THE COMPARATORS ; ----------------------- ; =09movlw b'00000111'=09=09; disable comparators =09movwf CMCON ; ; ---------------- ; INITIALISE USART ; ---------------- ; Boot Baud Rate =3D 9600, No Parity, 1 Stop Bit ; =09bsf STATUS,RP0 =09movlw d'25'=09; 9600 baud =09movwf SPBRG =09movlw b'00100100' ; brgh =3D high (2) =09movwf TXSTA=09; enable Async Transmission, set brgh =09movlw b'10010000' ; enable Async Reception =09clrf STATUS=09; RAM Page 0 =09movwf RCSTA =09; wait a short while before using =09call Receive=09; wait for incoming byte =09movlw '1'=09; send "16F628" =09movwf TXREG =09movlw '6' =09movwf TXREG =09call TransWt =09movlw 'F' =09movwf TXREG =09movlw '6' =09movwf TXREG =09call TransWt =09movlw '2' =09movwf TXREG =09movlw '8' =09movwf TXREG Here=09goto Here ; ; ------------------------------------ ; WAIT UNTIL RS232 IS FINISHED SENDING ; ------------------------------------ ; TransWt=09bsf STATUS,RP0 WtHere=09btfss TXSTA,TRMT ; TX complete if hi =09goto WtHere =09bcf STATUS,RP0=09; RAM Page 0 =09return ; ; --------------------------- ; RECEIVE CHARACTER FROM UART ; --------------------------- ; This routine does not return ; until a character is received. ; Receive=09nop btfss PIR1,RCIF=09; check for received data goto Receive movf RCREG,W movwf RxHold=09; tempstore data return --=20 Best regards Tony mICros http://www.bubblesoftonline.com mailto:sales@bubblesoftonline.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics