Problem about serial communication how to send a byte(127) from PC to PIC?
Hi...guys, nice to meet u here,guys...i am facing a problem about serial communication, the PIC i am using is PIC 16F874A model
Here, i got a problem about serial communication how to send a byte(127) from PC to PIC, at the same time, PC will receive 127,127,127,127...continuosly or non-stop?
This is my code, and the compiler i am using is Microcode PicBasic Pro
My code:
INCLUDE "modedefs.bas" 'include serout defines
DEFINE OSC 4
TRISB =%00000001 'port b=output except pin 1 (RX) is input
TRISC = %10111000 ' set output for pwm portc.2
RX var word
RY var word
RZ var word
temp var word
CCP1CON = %00001111 'turns PWM mode on, clears lowest two bits of duty cycle
high PORTB.2
main:
PIE1.5 = 1
INTCON = %11000000
ON INTERRUPT GoTo handler
'-------- interrupt start --------'
disable
handler:
serin PORTB.0, T2400, RX, RY, RZ 'Receive menu number
if (RX != "1") AND (RY != "2") and (RZ!= "7") then error
RX = RX - $30
RY = RY - $30
RZ = RZ - $30
temp=(RX*100)+(RY*10)+(RZ*1)
gosub speed
speed: pwm PORTC.1,temp,100
serout PORTB.1,T2400,[#temp,100]
resume
enable
ERROR: RX = RX - $30
RY = RY - $30
RZ = RZ - $30
temp=(RX*100)+(RY*10)+(RZ*1)
clear
gosub speed