Page 1 of 1

ECIO and use of USB in Flowcode

Posted: Wed Jun 11, 2008 12:02 pm
by Mark
ECIO and use of USB in Flowcode

The ECIO devices are very appealing if we can use the USB to send data back to a PC.

Is this possible?

Is it possible in Flow Code?

If not directly possible is there a work around (via RS232)? Pure USB is not in any case what I suspect many people want, rather a simulated COM port for interfacing via the .NET framework serial port feature.

Self evidently, if a 232USB e-block is required it defeats the whole benefit (for my purposes) of ECIO.

Thanks

Re: ECIO and use of USB in Flowcode

Posted: Wed Jun 11, 2008 12:56 pm
by Benj
Hi Mark

This functionality is on the way. There is currently a HID USB example available from the beta components download section.

http://www.matrixmultimedia.com/Flowcode_Components.php

Re: ECIO and use of USB in Flowcode

Posted: Thu Jul 03, 2008 9:25 am
by MIKE_31
Hi all,

What is the flowcode HID USB example use for ? If i download it in the PIC ,how can i use it ? which connection i need ?

MIKE

Re: ECIO and use of USB in Flowcode

Posted: Thu Jul 10, 2008 5:01 pm
by Benj
Hello Mike

If you download the program onto an ECIO then you should see the mouse pointer on your PC moving in a figure 8. You will need to give the software a few seconds to leave the ECIO bootloader mode and register the USB parameters.

Re: ECIO and use of USB in Flowcode

Posted: Sat Aug 30, 2008 7:57 pm
by kersing
Hi,

I'm trying to create an USB application based on the USB_Mouse example provided in the beta components. After adding the usb_defs.h file to the correct directory I'm able to generate a hex file, however looking at the generated c code I noticed the following lines:
//Start USB interrupts
//Interrupt : Enable USBINT
//failed to generate code for interrupt

It seems something is going wrong, I haven't got a clue at to what I'm doing wrong so I'm hoping you can help me out.

Another issue, I'm trying to get the code to run on the PICDEM FS USB Demo Board which has a different processor. When I set the chip to 18F4550 Flowcode complains about being unable to run one ore more commands in the flowchart. The offending command is 'Enable USBINT'. Am I trying the impossible or doing something wrong? (Hmm, just tried switching to the 18F2455, the device on the ECIO board. Results in the same error)

Best regards,

Jac

Re: ECIO and use of USB in Flowcode

Posted: Sun Aug 31, 2008 9:12 am
by kersing
Hi again!

Solved the issues listed in my previous message. According to the beta components page:
Note: The ECIO definition files that come with Flowcode V3.2.2 do not include the USB interrupt function. Therefore if you are using V3.2.2 or earlier of Flowcode you will need to replace the ECIO FCD files with the later ones. The FCD files are located in the Flowcode V3/FCD directory.
It seems the V3.4.7.48 release has the same problem. Looking at the fcd files included in this release there is no USBINT. Used the zip provided at the beta components page to replace the files and now the generated C code looks fine.

This solved the problem with switching to the 18F4550 as well.

Regards,

Jac

Re: ECIO and use of USB in Flowcode

Posted: Mon Sep 01, 2008 12:20 pm
by Steve
Yes - the addition of the USB interrupt came after the v3.4.7 release and there have not been any new releases since. The latest FCD files for the ECIO and USB devices are attached to this post.

Re: ECIO and use of USB in Flowcode

Posted: Wed Sep 22, 2010 7:13 am
by jawier
Hi all.
Anyone who knows how to use, USBINT in USBSerial for create one interrup when you receive something? :shock:

I've been doing a program to send data, and receiving by interruptions, but continuously the interruption jumps.
In the datasheet of 18f2550 don´t appears anything about usb interrupts in read serial port.

Thanks, good programming. 8)

Re: ECIO and use of USB in Flowcode

Posted: Wed Sep 22, 2010 9:57 am
by Benj
Hello,

You will need to look at the following file to allow the USB interrupt to work correctly.

C:\Program Files\Matrix Multimedia\Flowcode V4\boostc\include\USB\usb_cdc_class.c

Open the file using a text editor and find the line.

void usb_ep_data_out_callback(uns8 end_point, uns8 *buffer, uns16 byte_count)

At the end of this function you can add a call to a Flowcode macro and this should be triggered when ever the USB receives any serial data.

I created a macro called test in Flowcode and then to reference this in the C code I edited the C function to look like this.

Code: Select all

void usb_ep_data_out_callback(uns8 end_point, uns8 *buffer, uns16 byte_count)
{
	uns8 cdc_rx_next;

	// We have some data!
	if (end_point == CDC_DATA_ENDPOINT)
	{	// it's the data end point

		uns8 count;
		for (count = 0; count < byte_count; count++)
		{
			cdc_rx_next = cdc_rx_end + 1;	// get next buffer position
			if (cdc_rx_next == CDC_RX_BUFFER_SIZE)
			{	// if we're at the end
				cdc_rx_next = 0;	// then wrap to the beginning
			}
			if (cdc_rx_next != cdc_rx_start)
			{ // if space in the fifo
				cdc_rx_buffer[cdc_rx_end] = buffer[count]; // put it in
				cdc_rx_end = cdc_rx_next;  // and move pointer along
			} // else... just ignore it, we've lost a byte, no room in the inn
		}

        //ADDED BR - Call to Flowcode Macro "test"
        FCM_test();

	}

}

Re: ECIO and use of USB in Flowcode

Posted: Thu Sep 23, 2010 8:47 am
by jawier
Thanks, today i try it. :P

Re: ECIO and use of USB in Flowcode

Posted: Thu Sep 23, 2010 2:18 pm
by jawier
I have not been able to make it run. The interruption does not run. :cry:
I have not enabled the USBINT because,what do I use Macro?

The USBINT does not enable peripheral interrupts.
Is it good?

Thanks

Re: ECIO and use of USB in Flowcode

Posted: Thu Sep 23, 2010 2:32 pm
by Benj
Hello,

The USBINT interrupt was used by the early beta USB component and should not be used in Flowcode v4 applications unless you are building a USB handler from scratch.

Does the test macro never get called at the moment then?

Re: ECIO and use of USB in Flowcode

Posted: Thu Sep 23, 2010 4:06 pm
by jawier
I mean, if i send something throught hyperterminal, the interrupt shoulbe jump.
I do this:

}

//ADDED BR - Call to Flowcode Macro "test"
FCM_test();

}


But no run.

Is it necesary enable the USBINT?

Yes: My program only do the interrupt, not run the main program.

No: My program is only doing the main program, and don´t jump the interrupt.

Thanks for everything.

Re: ECIO and use of USB in Flowcode

Posted: Fri Sep 24, 2010 8:49 am
by Benj
Hello,

I just tried your program as is and its working great for me. Did you edit the usb_cdc_class.c function like I mentioned above to include the call to FCM_test();

You do not need to enable the USBINT and should never need to use it with the USB components.

Also I noticed that your clock speed in the project options is set to 16MHz. USB runs at 48MHz (12MIPs) so your delays will currently be much shorter then they should be. Changing the clock speed to 48000000 should allow the delays to run at the correct speed.

I've also had a quick look at your config settings and my only suggestion would be to change the USB voltage regulator setting so it is enabled.

Re: ECIO and use of USB in Flowcode

Posted: Mon Sep 27, 2010 7:31 am
by jawier
Yes, you're right.
This run ok, but two questions.
The first,quartz xtal 20MHz preescaller 5 (20/5=4 to PLL) -> (PLL/2=48) ->CPUDIV (no divide selected, then /2 )-> (48/2=16)

The second,therefore, when would be it use the USBINT? :|

Thanks Benj. :P

Re: ECIO and use of USB in Flowcode

Posted: Mon Sep 27, 2010 8:21 am
by Benj
Hello,
The first,quartz xtal 20MHz preescaller 5 (20/5=4 to PLL) -> (PLL/2=48) ->CPUDIV (no divide selected, then /2 )-> (48/2=16)
48/2 is not 16. Also the final divide is /4 so 48/4 = 12MHz.
The second,therefore, when would be it use the USBINT?
The second what? For the USB to work the chip must be running ta the speed of 12MIPs to allow the full speed USB to work correctly.

Re: ECIO and use of USB in Flowcode

Posted: Mon Sep 27, 2010 8:35 am
by jawier
Sorry, 48/3=16 (it is bad in the example).
I write the speed of the program, not the Xtal, Is it good?

My USB run OK and the inerrupt work excellent, then,
What,How,Where, is the use of this USBINT? :idea:

Thank you so much for answered me. :P

Re: ECIO and use of USB in Flowcode

Posted: Mon Sep 27, 2010 11:53 am
by Benj
Hello,

As stated earlier.
The USBINT interrupt was used by the early beta USB component and should not be used in Flowcode v4 applications unless you are building a USB handler from scratch.
You do not need to enable the USBINT and should never need to use it with the USB components.
The program speed must be 48MHz or 12MIPs (48 / 4) to allow full speed USB to work. If your device is working then you have everything setup correctly.

Re: ECIO and use of USB in Flowcode

Posted: Mon Sep 27, 2010 2:05 pm
by jawier
ok.Thanks so much. :P