rubisharmax
- 10th June 2012, 07:50
Hi,
I'm trying to read data incoming to the 18F2550 using Serin and then send the read data using USBOut to the PC as follows:
DEFINE OSC 48
Include "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
Loop1:
Serin SI,N9600,B0
Buffer(0)=B0
Loop2:
USBService
USBOut 3, Buffer, Cnt, Loop2
goto Loop1 ' Go and read serial input data again
end
This code does not work, 18F2550 is not even recognized as a USB CDC device. I'm sure of the hardware and the usage of CDC, and also that serial data exists in the relevant pin. The error seems to occur only when I use Serin and Usbout in the same code as above. How can I change the code to make it work properly?
Best regards,
I'm trying to read data incoming to the 18F2550 using Serin and then send the read data using USBOut to the PC as follows:
DEFINE OSC 48
Include "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
Loop1:
Serin SI,N9600,B0
Buffer(0)=B0
Loop2:
USBService
USBOut 3, Buffer, Cnt, Loop2
goto Loop1 ' Go and read serial input data again
end
This code does not work, 18F2550 is not even recognized as a USB CDC device. I'm sure of the hardware and the usage of CDC, and also that serial data exists in the relevant pin. The error seems to occur only when I use Serin and Usbout in the same code as above. How can I change the code to make it work properly?
Best regards,