Hello everyone, this will be my first post.
I am using PIC16F77A to connect to a PC via UART but hyperterminal displays only 3 types of characters each time i push the push button: 1 unknown character, a dot and a space. My initial output should be 0 then incremented by 1 each time the push button is pressed.
Details:
The language used is PIC Basic Pro, Complier: MicroCode Studio Version 4.0, Assembler: Microchip/mpasm suite, MPLAB IDE v8.66
i used a uart to establish connection with a PC, Windows 7.
Coding:
INCLUDE “modedefs.bas” ‘ Serial communication mode definition file
DEFINE OSC 20 ‘ Oscillator speed is set to 20MHz
TRISB = %11111111
TRISC = %10000000 ‘ RC.7 => USART RX pin set to input
PortC = 0
SPBRG = 25 ‘ Baud Rate = 9600
‘ Variable definition
‘ ===================
‘
DataOut var byte ‘ use to store TXREG content
DataIn var byte ‘ use to store RCREG content
DataIn = 0
DataOut = 0
mainloop:
TXSTA = $24 ‘ enable transmit and SPBRGH = 1
RCSTA = $90 ‘ Enable USART and continuous receive
datain = DataOut ‘ Get data
IF (PortB.7 = 1) THEN
DataOut = DataIn + 1
PAUSE 1000
DataIn = DataOut
TXREG = DataOut ‘ Transmit Data
HIGH PortD.2
PAUSE 2000
LOW PortD.2
ENDIF
GOTO mainloop
END
Bookmarks