Thanks Archangel, I changed the definitions as you said.
On the other hand, there's a weird problem again: I send a serial bytes of "50" and "55" from 12F675 to 18F2550. 18F2550 is supposed to take the serial data input and send it to PC via USB.
The transmitter code is as follows:
Code:
Include "modedefs.bas" ' Include serial modes
DEFINE OSC 4
CMCON = 7
ANSEL = 0
output GPIO.1
SO var GPIO.1 ' Define serial out pin
B0 Var byte
mainloop:
pause 1
B0=50
Serout SO,N9600,[B0] ' Send character
pause 1
B0=55
Serout SO,N9600,[B0] ' Send character
Goto mainloop ' Forever
End
And on the 18F2550, just trying to read serial input and then send it via USBOUT command:
Code:
DEFINE OSC 48Include "modedefs.bas"
Buffer VAR BYTE[1]
Cnt VAR BYTE
counter VAR WORD
B0 VAR BYTE
ADCON1 = 15 ' Set all I/Os to Digital
CMCON = 7 ' Disable Comparators
Cnt = 1
input PORTA.0
SI var PORTA.0
USBInit ' Initialize USART
Loop2:
Serin SI,N9600,B0
Buffer(0)=B0
Loop1:
USBService
USBOut 3, Buffer, Cnt, loop1
goto Loop2 ' Go and read serial input data again
end
The problem is: when I load the above code into 18F2550, PC doesn't see the virtual COM port. But when I change the code as follows, it works fine:
Code:
DEFINE OSC 48Include "modedefs.bas"
Buffer VAR BYTE[1]
Cnt VAR BYTE
counter VAR WORD
B0 VAR BYTE
ADCON1 = 15 ' Set all I/Os to Digital
CMCON = 7 ' Disable Comparators
Cnt = 1
input PORTA.0
SI var PORTA.0
USBInit ' Initialize USART
Loop2:
Serin SI,N9600,B0
Buffer(0)=B0
Loop1:
USBService
USBOut 3, Buffer, Cnt, loop1
goto Loop1 ' Send the same received serial data again and again to the PC
end
The problem is: I need to read each serial input data and send it to PC via USB on 18F2550. Tried loads of combinations but nothing worked except the latter code above, which sends the data received only once at the start of the program.
Any opinion to overcome this problem?
Bookmarks