vili.chaudhary
New Member
Hi Mike,
I have finally managed to finish my phase part as well .
I was hoping to get some suggestions on my last section. Basically after getting 3 bytes of data [two mag and one phase], I now have to transfer the data to the PC via USB.
My supervisor has already provided me with a USB-PC interfacing board [this -:
https://www.ftdichip.com/Documents/DataSheets/Modules/DS_UM232R.pdf
I have attached a schematic of the USB circuit as well.
He told me that it's very easy to use. It takes the serial input from the PIC [USART] and transfers the data to PC.
So my task is to transfer the two dummy values [any binary/hex values] to the PC using a USART and check the values on PC using "Hyperterminal software".
I have read some information on USART and attempted a simple code. I would really really appreciate it if you could advice me on the code or any changes I need in the code.
Many thanks.
Vili
I have finally managed to finish my phase part as well .
I was hoping to get some suggestions on my last section. Basically after getting 3 bytes of data [two mag and one phase], I now have to transfer the data to the PC via USB.
My supervisor has already provided me with a USB-PC interfacing board [this -:
https://www.ftdichip.com/Documents/DataSheets/Modules/DS_UM232R.pdf
I have attached a schematic of the USB circuit as well.
He told me that it's very easy to use. It takes the serial input from the PIC [USART] and transfers the data to PC.
So my task is to transfer the two dummy values [any binary/hex values] to the PC using a USART and check the values on PC using "Hyperterminal software".
I have read some information on USART and attempted a simple code. I would really really appreciate it if you could advice me on the code or any changes I need in the code.
Many thanks.
Vili
Code:
;16f877a USART test routine
;
;TEST CIRCUIT:
;**********************************************************
__config _LVP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF & _BODEN_OFF & _DEBUG_OFF
list p=16f877a
include "p16f877a.inc"
errorlevel -302
;******* Start at the reset vector
org 0x000
goto Start
Start
org 0x010
clrf PORTC
bsf STATUS,RP0 ;bank 1
bcf STATUS,RP1
;****************************************************
movlw b'00000011'
movwf TRISC ;portc [5-0] outputs** <6,7> set for RX/TX
;**********************************************
movlw d'25' ; Set Baud rate
movwf SPBRG
movlw b'00100100' ; 8-bit transmit, transmitter enabled,
movwf TXSTA ; asynchronous mode, HIGH speed mode
bcf STATUS,RP0 ; Go to Bank 0
bsf RCSTA,SPEN ;**** Serial ENABLED
bsf PIR1,TXIF ;**Set interrupt
;**********************************************
Main
movlw 0x0f
movwf TXREG
;********************************************
Wait
btfsc PIR1,TXIF
goto Wait ;/**********TXIF will get clear by loading TXREG
goto Buffer
;/*********Ready to load another 8-bit value??*****
Buffer
btfss TXSTA,TRMT
goto Buffer
goto Nextvalue
;/********Next value to be transmit*****
Nextvalue
movlw 0xff
movwf TXREG
Wait1
btfsc PIR1,TXIF
goto Wait1 ;/******TXIF will get clear by loading TXREG
goto Buffer1
;/**************
Buffer1
btfss TXSTA,TRMT
goto Buffer1
goto Main
END