Flowcode V3 PIC USB Pack Released

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Flowcode V3 PIC USB Pack Released

Postby Benj » Mon Oct 27, 2008 2:12 pm

We have just released V1 of the Flowcode V3 USB Pack. To download the pack simply click on the link at the bottom of the page and fill out the online form.

Image

The Flowcode USB Pack allows for communications between a PC and a USB enabled PICmicro device to be established and utilized in a very simple manner. The Pack includes three new Flowcode components to provide three different methods of connecting to a PC via USB.


USB Serial - Replaces the old RS232 COM port.
USB Slave - Allows for direct microcontroller control via a DLL library.
USB HID - Creates a human interface to the PC.


The USB pack has support for the following microchip PICmicro devices:

18F2450, 18F2455, 18F2550, 18F4450, 18F4455, 18F4550


The following Matrix products are also supported by the USB Pack:

Formula Flowcode, ECIO28, ECIO40, MIAC, EB006 Multiprogrammer*, HP488 Dev board*

* When used with a EB055, a compatible crystal and a USB enabled PICmicro device.


The following Microchip products are also supported by the USB Pack:

PICDEM FS USB Demo Board


Included in the Pack:

USB serial Flowcode component
USB slave Flowcode component
USB HID Flowcode component
Flowcode example files
Installation guide
Component help files
VB interface examples
Labview interface examples


You can download the USB Pack by following the link below and filling out the form.
http://www.matrixmultimedia.com/FlowcodeUSBPack.php

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby Benj » Tue Nov 04, 2008 1:14 pm

The USB pack has now been updated to include a Flowcode target definition for the Microchip PICDEMUSB board.

To install the USB pack simply follow the instructions inside the installation folder. The Microchip PICDEMUSB board can be selected by selecting the MCHP_FSUSB as the target in Flowcode. When compiling your code to the chip using the Microchip definition file the Microchip bootloader program will be launched automatically.

The hex file that is generated by Flowcode will have to be loaded manually as the Microchip tool does not support command line parameters.

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby Benj » Fri Nov 07, 2008 5:03 pm

There is now a short powerpoint presentation on the advantages and usage of the USB pack available from here.

http://www.matrixmultimedia.com/softwar ... tation.ppt

manish12
Posts: 2
Joined: Tue Jan 20, 2009 10:59 am
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby manish12 » Tue Jan 20, 2009 11:03 am

what should be the ex xtal for this usb pack flowcode.

it will generate 48Mhz but , from 8mhz or 4 mhz .

what ex xtal should i connect , according to the get 48mhz. ?

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby Benj » Tue Jan 20, 2009 12:38 pm

Hello

You can use the following crystal speeds with the USB pack: 4, 8, 12, 16, 20, 24, 40, 48MHz

Your configuration settings should then match these settings to get the USB to run correctly.

USB Clock Selection - clk src from 96MHz PLL/2
CPU Sys CLK Select - no divide
OCS Select - Match the value of your crystal
Oscillator - HS: HS+PLL, USB-HS
USB Voltage Regulator - Enabled
Watchdog timer - Disabled

Other options can be enabled or disabled at will. However be careful with the protect options and ensure that they are all set to disabled otherwise you can lock up your chip so it cannot be reprogrammed.

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby kersing » Mon Mar 02, 2009 10:35 pm

Hi,

Created a very simple program with the USB Slave. Used the properties of the component to set the 'Name' and 'Manufacturer'. When I connect the device to a Linux box the values are not shown, the output is:

Code: Select all

  bcdDevice            0.01
  iManufacturer           1
  iProduct                2
  iSerial                 0
  bNumConfigurations      1


Where I expect to see something like (random device on the bus):

Code: Select all

  bcdDevice            1.00
  iManufacturer           1 Justcom Technology
  iProduct                2 USB KVM Switch
  iSerial                 0
  bNumConfigurations      1


The slave does receive and send data.

Is this a known error with a work-around?
(Am using an ECIO-28)

Best regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby Benj » Tue Mar 03, 2009 9:22 am

Hello

The USB Slave requires a driver. How did you manage to install the driver on the Linux machine?

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby kersing » Tue Mar 03, 2009 12:21 pm

Hi Ben,

There is no need for a driver to be able to show information on connected devices on Linux. The OS has a convenient 'lsusb' command to list information on devices connected. To be able to talk to the simple function I've implemented I'm using libusb with a simple C program. So there is no need for a (kernel) driver.

Best regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby Benj » Tue Mar 03, 2009 12:40 pm

Hello Jac

Ok thats fantastic I can see I will have to look deeper into this. Can the Microchip dll file still be used to control the USB opertaions? Im guessing that all of the device information is actually stored into the driver then. If you look in the USBpack library "Flowcode V3/BoostC/Include/USB" you should be able to edit the Slave device enumeration settings to control the way the device looks to the Linux box.

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby kersing » Tue Mar 03, 2009 1:25 pm

Hi Ben,

The DLL is not used on Linux. The information 'lsusb' normally uses is stored in a text file on the system (manufacturer id and device id information). In the verbose mode lsusb requests additional information from the device. That is the information stored in the unicode strings as set in the component properties pane. The beta USB component provided the information correctly. I've been using a heavily modified version (to provide USB slave functions, not HID) of the beta component since august/september last year.

FYI, the lsusb verbose output for the PIC with the modified beta component:

Code: Select all

Bus 007 Device 005: ID 16d0:0033 The-Box Development, Temperature Probe
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x16d0 The-Box Development,
  idProduct          0x0033 Temperature Probe
  bcdDevice            0.01
  iManufacturer           1 The-Box Development
  iProduct                2 Temperature Probe
  iSerial                 3 00000001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xa0
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         0 (Defined at Interface level)
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10

(The device is queried for the iManufacturer, iProduct and iSerial strings)
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby Benj » Tue Mar 03, 2009 2:46 pm

Ok thats fantastic. Our PPP programming software uses a technology similar to the USB slave component and therefore we may be able to offer support for our PICmicro hardware in Linux based systems without much work. Do you have example C code for interfacing to the libusb software?

I will look into why the details are not being displayed correctly with the USB slave component.

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby kersing » Tue Mar 03, 2009 11:33 pm

Ben,

The information not being available seems to have something to do with it being declared "rom char *MX_...". If I change usb_config_dll.c to use a static or const char array for the MX_... and hard code the length (or use array element 0 as it contains the length) the information becomes available.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby kersing » Tue Mar 03, 2009 11:40 pm

Ben,

I'll get back to you regarding my sample code. Have to clean it. There is some example code available on the internet, http://www.varxec.net/picdem_fs_usb/fsusb_demo.c for instance.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

tantony
Posts: 1
Joined: Wed Mar 04, 2009 8:31 pm
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby tantony » Wed Mar 04, 2009 8:51 pm

Dear developers
I've tried to use Flowcode with FS USB board,
but configuration bits described in MCHP_FSUSB.fcd are:
0=0x20
1=0x0E
2=0x3E
3=0x1E
4=0x00
5=0x81
6=0x81
7=0x00
8=0x0F
9=0x80
10=0x0F
11=0xA0
12=0x0F
13=0x00

while default configuration bits for FS USB boards are:
0=0x24
1=0x0E
2=0x3F
3=0x1E
4=0x00
5=0x81
6=0x81
7=0x00
8=0x0F
9=0xC0
10=0x0F
11=0xA0
12=0x0F
13=0x40
that cause warning message from pdfsusb.exe
that current config in hex file and board defauld settings does not match.
Is it normal?

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby kersing » Mon Apr 06, 2009 11:05 pm

Benj wrote:I will look into why the details are not being displayed correctly with the USB slave component.


Hi Ben,

Did you get around to look at the issue with the details not being displayed?

Looking at the code in usb_config_dll.c (usb_get_descriptor_callback):

Code: Select all

                                case 00:
                                        descriptor_size = sizeof(string_00);
                                        descriptor_ptr = string_00;
                                        break;
                                case 01:
                                        descriptor_size = sizeof(MX_USBMFR);
                                        descriptor_ptr = MX_USBMFR;
                                        break;

The case 00 is being handled correctly. Case 01 is not. MX_USBMFR is declared rom char *, string_00 is uns8 string_00[].

Best regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby Benj » Thu Jun 04, 2009 9:02 am

Hello

The USB pack has now been updated to include support for the 18F2450 and 18F4450 devices.

You can download the contents of the USB pack from here.
http://www.matrixmultimedia.com/FlowcodeUSBPack.php

Flowcode 3.6 users only need to copy the files they do not have to run the installation batch files.
Flowcode 3.4 or earlier it is recommended to upgrade your version of Flowcode to the latest version before downloading the USB pack update and example files.

alazaro
Posts: 20
Joined: Mon Jun 15, 2009 1:06 pm
Location: Lisbon, Portugal
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby alazaro » Thu Jun 25, 2009 5:45 pm

Hi all!
I think I already know the answer for this question... but just to be sure.
Is is possible to use and generate the hex file for the USB component in a free version of the Flowcode?

Thanks,
Γ‚ngela
Regards,
Ângela

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby kersing » Thu Jun 25, 2009 8:57 pm

alazaro wrote:Is is possible to use and generate the hex file for the USB component in a free version of the Flowcode?


No it is not. Only the professional version has the USB components. (http://www.matrixmultimedia.com/datashe ... 4-60-1.pdf lists all versions and the limitations)

Regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

alazaro
Posts: 20
Joined: Mon Jun 15, 2009 1:06 pm
Location: Lisbon, Portugal
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby alazaro » Wed Jul 08, 2009 1:15 pm

Hello everyone!

I'm trying to pass data from the PC the ECIO40 in runtime using the USB connection. I'm looking for your examples, USB PACK, and I would like to know if I can pass more than 30-32 bytes to the ECIO at the same time using the ECIO_Transmit(...) function.

One more thing, when I use this function I'll be able to pass 32 bytes in both directions? I mean, would I be able to pass 32 bytes to the ECIO and receive 32 bytes back, just calling this function once?

Thanks in advanced!

Regards,
Γ‚ngela
Regards,
Ângela

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby Benj » Wed Jul 08, 2009 4:15 pm

Hello Γ‚ngela

The USB slave component is currently limited to 32 bytes in and 32 bytes out. This means one transaction can have a maximum of 64 bytes.

You should be able to edit this if needed by using the customized code in V4 or by editing the component code file in V3.

You are looking for the defines section which looks similar to this.

#define USB_EP1_OUT_ADDR 0x0530

and

#define USB_EP1_IN_SIZE 32
#define USB_EP1_OUT_SIZE 32

You could try the following and it should work though I have not tested it.

#define USB_EP1_OUT_ADDR 0x0550

and

#define USB_EP1_IN_SIZE 64
#define USB_EP1_OUT_SIZE 64

You may be able to go as high as 128 or 256 just remember to update the EP1_OUT_ADDR appropriatley.

If your working on V3 and editing the component code by hand then remember to take a backup and restart Flowcode after you have saved your changes.

alazaro
Posts: 20
Joined: Mon Jun 15, 2009 1:06 pm
Location: Lisbon, Portugal
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby alazaro » Thu Jul 09, 2009 2:04 pm

Thanks Ben!

That solution works for 64 bytes but not for 128 or 256.

When I try to compile I get this error:

Error: Failed to allocate memory for var 'buffer_1_out' at address:0x00000590 crosses RAM banks

Is there another file that I can change in order to be able to trasnmit 128, 256, 512 bytes at a time?
I think that the way the RAM is organized I only can pass 64 bytes tops. But I would like to pass much more...

Any clue?

Thanks in advanced,

Regards,
Γ‚ngela
Regards,
Ângela

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby Benj » Thu Jul 09, 2009 4:38 pm

Hello Γ‚ngela

Ok you could try this.

#define USB_EP0_OUT_ADDR 0x0480
#define USB_EP0_IN_ADDR 0x0488
#define USB_EP1_IN_ADDR 0x0500
#define USB_EP1_OUT_ADDR 0x0580

#define USB_EP1_IN_SIZE 128
#define USB_EP1_OUT_SIZE 128

You could always sacrifice some of your incoming buffer to allow for a bigger outgoing buffer or visa versa.

The free USB memory space can hold up to 464 bytes for the incoming and outgoing buffers. This would allow for a buffer of 256 and a buffer of 208. or two buffers of 208 if they have to be the same size.

alazaro
Posts: 20
Joined: Mon Jun 15, 2009 1:06 pm
Location: Lisbon, Portugal
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby alazaro » Fri Jul 10, 2009 11:18 am

Hi Ben!

Thanks for your reply....

I've tryed to do that but a new problem appears!
When I used the followed defines,

#define USB_EP0_OUT_SIZE 8
#define USB_EP0_OUT_ADDR 0x0480
#define USB_EP0_IN_SIZE 8
#define USB_EP0_IN_ADDR 0x0488

I cannot established a USB connection.. the device is not recognized so I cannot transmit anything to the ECIO...

you said:

The free USB memory space can hold up to 464 bytes for the incoming and outgoing buffers. This would allow for a buffer of 256 and a buffer of 208. or two buffers of 208 if they have to be the same size.


any more ideia in order to be able to transmit 256 or 208 bytes at the same time?

I'm sorry to upset you one more time with this issue.

Regards,
Γ‚ngela
Regards,
Ângela

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby kersing » Fri Jul 10, 2009 11:33 am

Hi Γ‚ngela,
Please check the file pic_usb.c in the boostc/include/USB subdirectory of your flowcode installation. In the function usb_handle_reset you might find the lines:
// EP0 OUT
bd0out.count = 8; // 8 byte buffer
bd0out.addr = 0x0500;
and
// EP0 IN
bd0in.count = 8; // 8 byte buffer
bd0in.addr = 0x0508;

If the addresses 0x0500 and 0x0508 are listed you will have to change them to USB_EP0_OUT_ADDR and USB_EP0_IN_ADDR.

Best regards,

Jac


(Hi Ben,

Has an update for the USB Pack been released to allow shifting the EP0 addresses from 0x500 and 0x508?)
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Flowcode V3 PIC USB Pack Released

Postby Benj » Fri Jul 10, 2009 11:35 am

Hello Γ‚ngela

Ok I think this problem relates to a recent fix. You will need to browse to the "Flowcode V3/BoostC/Include/USB/" folder and open the pic_usb.c file.

In here you will find the function "void usb_handle_reset()" towards the bottom of the file.

Find the following sections of code.

Code: Select all

bd0out.count = 8;   // 8 byte buffer
bd0out.addr = 0x0500;


and

Code: Select all

bd0in.count = 8;   // 8 byte buffer
bd0in.addr = 0x0508;



Now replace with the following.

Code: Select all

bd0out.count = USB_EP0_OUT_SIZE;   // 8 byte buffer
bd0out.addr = USB_EP0_OUT_ADDR;


and

Code: Select all

bd0in.count = USB_EP0_IN_SIZE;   // 8 byte buffer
bd0in.addr = USB_EP0_IN_ADDR;


This should fix your USB library and allow my previous define values to work.