Roches
Domoticz en ESP8266, goede combo!!!
Ik heb een 18F2550 als USB-compoort gemaakt.
De USBPOLL van de 18F2550 werkt goed, want externe controle ingebouwd via een led die aan gaat op het moment dat de PIC aan de USB gestoken wordt en pas weer uit gaat als een goede connectie is gemaakt.
Daarna gaat dezelfde led knipperen ten teken dat de USB-connectie werkt en klaar is voor actie...
Windows herkent de VID en PID en maakt er netjes een COM-poort van.
Alleen geeft de driver dan de foutmelding "CODE 10 Device start niet"
Reeds diverse drivers geprobeert.
Op mijn vorige computer Q6600 met Windows7 64bit werkte het wel, maar met m'n nieuwe i7 2600K en Windows7 64bit krijg ik het niet meer werkend.
Op internet gezocht, maar nog niks concreets gevonden.
Wie van jullie heeft de oplossing?
[Bericht gewijzigd door Roches op (25%)]
Roches
Domoticz en ESP8266, goede combo!!!
Toch nog ff een kick....
Even voor de volledigheid mijn code hierbij:
'
' Programma om RS232-DATA van en naar de USB-Poort te sturen
' voor de treinbaansturing van Roche & Frans
'
' Uses transmit and receive detection using the CARRY flag (STATUS.0)
'
' Communicate via the serial terminal set to the com port that the USB connects too.
'
Device = 18F2550 ' Choose a device with on-board full speed USB
XTAL = 48 ' Set the oscillator speed to 48MHz (using a 20MHz crystal)
REMINDERS = OFF ' Disable all reminders
USB_DESCRIPTOR = "CDCDESC_MIJN.INC" ' Point to the CDC DESCRIPTOR file (located in the INC\USB_18 folder)
Dim PP0 As Byte SYSTEM ' USBPOLL status return
Dim VAR1 As Word ' General purpose variable
Dim ARRAY1[32] As Byte ' Used to hold some output characters
Dim OUT_BUFFER As String * 32 ' Used to hold some output characters
Dim IN_BUFFER As String * 32 ' Used to hold some input characters
Dim MIJN_BUFFER As String * 32
Dim RSCOUNT As Byte
Dim INCOUNT As Byte
Dim LIJN As Byte
Dim KOLOM As Byte
Dim Karakter As Byte
Symbol CARRY_FLAG = STATUS.0 ' High if microcontroller does not have control over the DP buffer
Symbol TRNIF = UIR.3 ' Low if USB Busy
' -----------------------------------------------------------------------
HSERIAL_BAUD = 38400 ;Transmissiesnelheid van de data over de bus
HSERIAL_RCSTA = %10010000 ;Bit7:Enable serial port / Bit4:Continu ontvangen
HSERIAL_TXSTA = %00000000 ;Bit5:Transmitpin uitgeschakeld (TXEN (Transmit ENable) = 0)
' Variabelen en Constanten
Symbol Baud2400I = 16780 ;2400 Baud Inverted (baudrate voor SEROUT)
Symbol Baud38400I = 16390
'------------------------------------------------------------------------
' The main program loop starts here
DelayMS 200 ' Wait for things to stabilise
ALL_DIGITAL = True ' Set PORTA and PORTD to digital mode
Clear ' Clear all RAM before we start
Input PORTC.6 ' CLEAR LCD
RCSTA = %00000000 ;Zet USART uit, anders ontvangt deze zijn eigen verzonden data
SerOut PORTC.6, Baud38400I, [0x00, "LCDCC"] ;Geinverteerd verzenden (vanwege BC547)
RCSTA = %10010000 ;Schakel USART weer in, zodat de PIC weer data kan ontvangen
Input PORTC.6 ;Maak TX poort hoog-ohmig door er een ingang van te maken
DelayMS 500
TRISA = %00000000
High PORTA.0
Repeat ' \
USBPoll ' Wait for the USB interface to become attached
Until PP0 = %00000110 ' /
Low PORTA.0
StrN ARRAY1 = " ARRAY BUFFER\n\r" ' Fill the array with NULL terminated characters
OUT_BUFFER = " STRING BUFFER\n\r" ' Fill the string with NULL terminated characters
INCOUNT = 0
VAR1 = 0 ' Reset the counting variable
While 1 = 1 ' Create an infinite loop
NEWDATA:Clear MIJN_BUFFER
Clear INCOUNT
Clear Karakter
Repeat ' Wait for USB input
NODATA: If RSCOUNT = 0 Then Toggle PORTA.0
Low PORTA.1
Clear INCOUNT
Clear Karakter
HSerIn 1, NOWUSB, [Karakter] ' Ga naar NOWUSB als er na 1 ms geen karakter is ontvangen...
High PORTA.1
If INCOUNT = 0 Then
If Karakter <> 0x0D Then
MIJN_BUFFER[0] = Karakter
INCOUNT = 1
Repeat
HSerIn 3, BRKIN, [ Karakter ]
MIJN_BUFFER[INCOUNT] = Karakter
INCOUNT = INCOUNT + 1
Until Karakter = 0x0D
MIJN_BUFFER[INCOUNT] = 0x0D
INCOUNT = 0
RSCOUNT = 1
BRKIN: Break
End If
MIJN_BUFFER[INCOUNT] = 0x0D
End If
NOWUSB: RSCOUNT = RSCOUNT + 1
USBIn 3, IN_BUFFER, Auto, NODATA ' Poll the USB and Receive some data from endpoint 3
Until CARRY_FLAG = 0 ' Keep looking until data is able to be received
Repeat
USBOut 3, MIJN_BUFFER, Auto ' Poll the USB and Transmit the buffer from endpoint 3
Until CARRY_FLAG = 0 ' Keep trying if the microcontroller does not have control over the buffer
Repeat : Until TRNIF = 1 ' Wait for completion before transmitting anything else
' If RSCOUNT = 1 Then GoTo NEWDATA
High PORTA.0
RCSTA = %00000000 ;Zet USART uit, anders ontvangt deze zijn eigen verzonden data
SerOut PORTC.6, Baud38400I, ["LCD", 0x01, 0x01,"USB BUFFER", DEC4 RSCOUNT, 0x0D] ;Geinverteerd verzenden (vanwege BC547)
RCSTA = %10010000 ;Schakel USART weer in, zodat de PIC weer data kan ontvangen
Input PORTC.6 ;Maak TX poort hoog-ohmig door er een ingang van te maken
RCSTA = %00000000 ;Zet USART uit, anders ontvangt deze zijn eigen verzonden data
SerOut PORTC.6, Baud38400I, ["LCD", 0x02, 0x01, MIJN_BUFFER, 0x0D] ;Geinverteerd verzenden (vanwege BC547)
RCSTA = %10010000 ;Schakel USART weer in, zodat de PIC weer data kan ontvangen
Input PORTC.6 ;Maak TX poort hoog-ohmig door er een ingang van te maken
RCSTA = %00000000 ;Zet USART uit, anders ontvangt deze zijn eigen verzonden data
SerOut PORTC.6, Baud38400I, ["LCD", 0x03, 0x01, IN_BUFFER, 0x0D] ;Geinverteerd verzenden (vanwege BC547)
RCSTA = %10010000 ;Schakel USART weer in, zodat de PIC weer data kan ontvangen
Input PORTC.6 ;Maak TX poort hoog-ohmig door er een ingang van te maken
Clear IN_BUFFER ' Then clear the buffer for the next time
__USBOUT_BUFFER = " USB BUFFER\n\r" ' Place characters directly into the USB TX buffer string
'
' MIJN EIGEN TOEVOEGING INBUFFER TERUGSTUREN NAAR USBPOORT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' Repeat
' USBOut 3, MIJN_BUFFER, Auto ' Poll the USB and Transmit the buffer from endpoint 3
' Until CARRY_FLAG = 0 ' Keep trying if the microcontroller does not have control over the buffer
' Repeat : Until TRNIF = 1 ' Wait for completion before transmitting anything else
' MIJN EIGEN TOEVOEGING INBUFFER TERUGSTUREN NAAR USBPOORT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Low PORTA.0
Wend ' Go wait for the next buffer input
TEXT_STRING: CData " CODE MEMORY BUFFER\n\r",0
Als jullie de CDC-descriptor-file ook nodig hebben moet je het even zeggen, dan post ik deze ook...
Stan1
Read the fuc.... manual and read the fuc.... datasheet! {Proton IDE: V2.0.1.2 / Proton Compiler: V3.5.4.5}
Als jullie de CDC-descriptor-file ook nodig hebben moet je het even zeggen, dan post ik deze ook...
Dat zou handig zijn
Roches
Domoticz en ESP8266, goede combo!!!
Bij deze dan ook de CDC-descriptor...
LIST
;
; This file contains a set of descriptors for a CDC Virtual serial com interface.
;
#DEFINE __EP0_BUFF_SIZE 32 ; 8, 16, 32, or 64 (8)
#DEFINE __MAX_NUM_INT 1 ; For tracking Alternate Setting
#DEFINE __MAX_EP_NUMBER 3 ; UEP3
#DEFINE __NUM_CONFIGURATIONS 1
#DEFINE __NUM_INTERFACES 2
#DEFINE __MODE_PP _PPBM0
#DEFINE __UCFG_VAL _PUEN | _TRINT | _FS | __MODE_PP ; Set bus for Full Speed
#DEFINE __USB_USE_CDC ; Inform the rest of the library subroutines that we're using a CDC interface
; CDC
#DEFINE __CDC_COMM_INTF_ID 0
#DEFINE __CDC_COMM_UEP UEP2
#DEFINE __CDC_INT_BD_IN __ep2Bi
#DEFINE __CDC_INT_EP_SIZE 8
#DEFINE __CDC_DATA_INTF_ID 1
#DEFINE __CDC_DATA_UEP UEP3
#DEFINE __CDC_BULK_BD_OUT __ep3Bo
#DEFINE __CDC_BULK_OUT_EP_SIZE 128 ; 128 byte output buffer. Note maximum of 128 (128)
#DEFINE __CDC_BULK_BD_IN __ep3Bi
#DEFINE __CDC_BULK_IN_EP_SIZE 128 ; 128 byte input buffer. Note maximum of 128 (128)
; ------------------------------------------------------------------------------
; This table is polled by the host immediately after USB Reset has been released.
; These fields are application dependent to be modified to meet your specifications.
;
__DeviceDescriptor
retlw (__EndDeviceDescriptor - __DeviceDescriptor) / 2 ; bLength Length of this descriptor
retlw __DSC_DEV ; bDescType DEVICE
dt 0x10, 0x01 ; bcd USB Revision 1.10 low byte, high byte
retlw __CDC_DEVICE ; bDeviceClass
retlw 0x00 ; bDeviceSubClass
retlw 0x00 ; bDeviceProtocol
retlw __EP0_BUFF_SIZE ; bMaxPacketSize for EP0
dt 0xD8, 0x04 ; idVendor - 0x04D8 is Microchip VENDOR ID low byte, high byte
dt 0x0A, 0x00 ; idProduct Product ID low byte, high byte WAS 0A, 00
dt 0x00, 0x00 ; bcd Device Device release number low byte, high byte
retlw 0x01 ; iManufacturer Manufacturer string index
retlw 0x02 ; iProduct Product string index
retlw 0x03 ; iSerialNumber Device serial number string index
retlw __NUM_CONFIGURATIONS ; bNumConfigurations
__EndDeviceDescriptor
; ------------------------------------------------------------------------------
; This table is retrieved by the host after the address has been set.
; This table defines the configurations available for the device.
; See section 9.6.2 of the Rev 1.0 USB specification (page 184).
; These fields are application dependent to be modified to meet your specifications.
;
; Configuration pointer table
__USB_CD_Ptr
__Configs
db Low ___Config1, High ___Config1
db Low ___Config1, High ___Config1
; Configuration Descriptor
___Config1
retlw 9 ; bLength Length of this descriptor
retlw __DSC_CFG ; bDescType CONFIGURATION
__Config1Len
retlw Low ((__EndConfig1 - ___Config1) / 2) ; Length of this configuration
retlw High ((__EndConfig1 - ___Config1) / 2)
retlw __NUM_INTERFACES ; bNumInterfaces Number of interfaces IN this configuration
retlw 0x01 ; bConfigValue Configuration Value
retlw 0x02 ; iConfigString Index for this configuration
retlw 0x80 ; bmAttributes
retlw 0x50 ; Max power consumption (2X mA)
; Interface Descriptor
retlw 9 ; bLength Length of this descriptor
retlw __DSC_INTF ; bDescType INTERFACE
retlw 0 ; Interface number
retlw 0 ; Alternate setting
retlw 1 ; Number of endpoints in this interface
retlw __COMM_INTF ; Class code
retlw __ABSTRACT_CONTROL_MODEL ; Subclass code
retlw __V25TER ; Protocol code
retlw 0 ; Interface string index
; CDC Class-Specific Descriptors
retlw 5 ; bFNLength (USB_CDC_HEADER_FN_DSC)
retlw __CS_INTERFACE ; bDscType
retlw __DSC_FN_HEADER ; bDscSubType
dt 0x10, 0x01 ; bcd CDC low byte, high byte
retlw 4 ; bFNLength (USB_CDC_ACM_FN_DSC)
retlw __CS_INTERFACE ; bDscType
retlw __DSC_FN_ACM ; bDscSubType
retlw 2 ; bmCapabilities
retlw 5 ; bFNLength (USB_CDC_UNION_FN_DSC)
retlw __CS_INTERFACE ; bDscType
retlw __DSC_FN_UNION ; bDscSubType
retlw __CDC_COMM_INTF_ID ; bMasterIntf
retlw __CDC_DATA_INTF_ID ; bSaveIntf0
retlw 5 ; bFNLength (USB_CDC_CALL_MGT_FN_DSC)
retlw __CS_INTERFACE ; bDscType
retlw __DSC_FN_CALL_MGT ; bDscSubType
retlw 0 ; bmCapabilities
retlw __CDC_DATA_INTF_ID ; bDataInterface
; Endpoint Descriptor
retlw 7 ; bLength (USB_EP_DSC)
retlw __DSC_EP ; bDscType
retlw _EP02_IN ; bEPAdr
retlw 3 ; bmAttributes (_INT)
retlw Low (__CDC_INT_EP_SIZE) ; wMaxPktSize
retlw High (__CDC_INT_EP_SIZE)
retlw 2 ; bInterval
; Interface Descriptor
retlw 9 ; bLength Length of this descriptor
retlw __DSC_INTF ; INTERFACE descriptor type
retlw 1 ; Interface Number
retlw 0 ; Alternate Setting Number
retlw 2 ; Number of endpoints in this intf
retlw __DATA_INTF ; Class code
retlw 0 ; Subclass code
retlw __NO_PROTOCOL ; Protocol code
retlw 0 ; Interface string index
; Endpoint Descriptors
retlw 7 ; bLength (USB_EP_DSC)
retlw __DSC_EP ; bDscType
retlw _EP03_OUT ; bEPAdr
retlw 2 ; bmAttributes (_BULK)
retlw Low (__CDC_BULK_OUT_EP_SIZE) ; wMaxPktSize
retlw High (__CDC_BULK_OUT_EP_SIZE)
retlw 0 ; bInterval
retlw 7 ; bLength (USB_EP_DSC)
retlw __DSC_EP ; bDscType
retlw _EP03_IN ; bEPAdr
retlw 2 ; bmAttributes (_BULK)
retlw Low (__CDC_BULK_IN_EP_SIZE) ; wMaxPktSize
retlw High (__CDC_BULK_IN_EP_SIZE)
retlw 0 ; bInterval
__EndConfig1
; String pointer table
__USB_SD_Ptr
__Strings
db Low __String0, High __String0
db Low __String1, High __String1
db Low __String2, High __String2
db Low __String3, High __String3
db Low __String4, High __String4
__String0
retlw (__String1 - __String0) / 2 ; Length of string
retlw __DSC_STR ; Descriptor type 3
dt 0x09, 0x04 ; Language ID (0x0409 as defined by Microsoft)
__String1
retlw (__String2 - __String1) / 2
retlw __DSC_STR
dt 'R', 0, 'S', 0, '-', 0, 'P', 0, 'r', 0, 'o', 0, 'd', 0, 'u', 0, 'c', 0, 't', 0, 'i', 0, 'o', 0, 'n', 0, 's', 0
__String2
retlw (__String3 - __String2) / 2
retlw __DSC_STR
dt 'P', 0, 'I', 0, 'C', 0, ' ', 0, 'T', 0, 'O', 0, ' ', 0
dt 'U', 0, 'S', 0, 'B', 0, ' ', 0, 'C', 0, 'D', 0, 'C', 0
__String3
retlw (__String4 - __String3) / 2
retlw __DSC_STR
dt 'V', 0, '1', 0, '.', 0, '1', 0, 'F', 0, 'S', 0
__String4
retlw (__String5 - __String4) / 2
retlw __DSC_STR
dt 'C', 0, 'f', 0, 'g', 0, '1', 0
__String5Ook in de installatie-file's van de driver de PID en VID toegevoegd.
Roches
Domoticz en ESP8266, goede combo!!!
Ik hoop toch dat er nog iemand een idee heeft....
(edit 4 dagen later)
Heb het probleem opgelost door over te stappen op een HID-device, wat wel werkt.
Het is alleen veel werk om het in visual-basic 2010 om te zetten naar HID.
Op de PIC is het eigenlijk alleen een andere descriptor-file gebruiken.