PICcoder.co.uk Forum  


::post new topic::
<< Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>
Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2006/08/23 16:40 By: Mat Status: Admin  
Karma: 7  
Posts: 211
graph
Congrats , btw its meant to be yellow!

There is very little information around on the PIC firmware, and the best source for this is the files themselves, read the headers!

As for the DLL dont worry about it, treat it as a black box, with inputs and outputs, your life will be much simpler!!

Mat
reply | quote

Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2006/08/24 15:57 By: Marco Status: Visitor  
 
Hi.

I've been modifying the code in both sides. In PIC, in the ServiceRequest I was only doing something like this (and made /* */ in all other present code):
dataPacket.CMD=0xEE;
dataPacket._byte[1]='A';
dataPacket._byte[2]='B';
counter=0x03;
if(!mUSBGenTxIsBusy())
USBGenWrite((byte*)&dataPacket,counter);
So, I espected that time to time (since there is a loop in the main) the PIC sent those bytes as a format of update_LED to the PC.

In the PC side my intention was looking into the read buffer, second to second, if there was something. Something like:
if (_MPUSBRead(myInPipe, (void*)receive_buf, ExpectedReceiveLength, (uint*)RecvLength, 1000) == 1). I didn't want to write, just read.And everytime I run this code I get "Attempted to read or write protected memory. This is often an indication that other memory is corrupt.". My question is: is there any treatment to this kind of exception in the _MPUSBWrite? Since the only thing that I'm not doing is writting to PIC.

Thanks.
reply | quote

Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2006/08/24 22:43 By: Marco Status: Visitor  
 
Other question is about the dataPacket enum in the service request (user.h). In the third page of the article you refer that there is available an id of 256. So, my only concerns are making my own command to avoid matching the others CMD defined and the "address" must be bettween 0x00-0xFF right?

Thanks for all help.
Marco
reply | quote

Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2006/08/31 09:29 By: Marco Status: Visitor  
 
Hi Mat. I figered it out with the last 2 posts.

I would like to make a question about this code.There are application notes from microchip for USB use as a rs232 replacement. Is this the intention of PICDEM board wich this code is based? If so, that should mean that we were limeted to rs323 max baudrate? But from our configuration bits we are at 12Mbps with USB right? I might be confusing what they mean with rs232 replacemen...

Best Regards, and thanks.
reply | quote

Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2006/08/31 18:26 By: nobody Status: Visitor  
 
well yes, you CAN make the PIC act as a virtual RS232 COM port, but that's not what is being done in this project, nor is it the only thing the PICDEM board is meant for.

This demonstration is setting it up as a custom USB device with the microchip driver, that uses interrupt transfers(of the format described in the article) containing whatever you want.
reply | quote

Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2006/09/09 00:23 By: belzebuth974 Status: Visitor  
 
Hi,
I'm a total newbie to usb, found this fundamental article that make things more clear for me...
i've a question, when i read the c# code, i can see the following :

DWORD RecvLength=3;
send_buf[0] = 0x32; //Command for LED Status
send_buf[1] = (byte)led;
send_buf[2] = (byte)(State?1:0);
if (SendReceivePacket(send_buf,3,receive_buf,&RecvLength) == 1)

it seems that the pic should return 3 bytes but you said that in the case of a led status modification, only one byte should be returned (i.e. the 0x32 value) and here it said that 3 bytes must be returned ???? did i missed something ?
i understand that the content of RecvLength is modified during the call to SendReceivePacket and this should not induce an error but for my mind peace can you explain ?

The same strange thing is in
DWORD RecvLength=(byte)2;
send_buf[0] = 0xEE; //Command for DO_SUM
send_buf[1] = (byte)num1;
send_buf[2] = (byte)num2;
if (SendReceivePacket(send_buf,4,receive_buf,&RecvLength) == 1)
{
Temp = receive_buf[1];
}

it looks like 4 byte should be sent but only 3 are initialized, so isn't the size of the sended packet is 3 ?? if i refer to your article RecvLength is part of the sended packet and then the number 4 is correct, but in this case the above lines are false because in the updateled case the length of the packet is also 4.

what did i don't understand ???

thanks
reply | quote

Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2006/09/18 20:45 By: je_aleph Status: Visitor  
 
Hi!
I´ve been using the Matt´s API in C# for a school´s project, and it works excellent. I´ve working in a data adquisition system (well, a oscilloscope) based on your´s project and Jim´s project. I´ve working hard specially in the code for the PIC. If you want to know more about my project you can send an email to : je_aleph@yahoo.com.mx

I have a some doubts:

-Where did you (Matt) find information about the functions in the mpusbapi.dll to program your C# API? And who writes the file "funciones.txt"? The both dll´s form the project are from Microchip or did you program someone?

-Did you have a problem if a use for my project?

-Why Jim use a 12MHz Crystal and you use a 20MHz??

Thanks for your time!!
reply | quote

Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2006/09/28 15:44 By: evandude Status: Visitor  
 
if you download the MCHPFSUSB software package from microchip (admittedly, actually locating the file on their website is a hassle), the source code for mpusbapi.dll is given, in borland C++, and in there you can easily see all the available functions.

you can use a number of different oscillator speeds (multiples of 4MHz), you just need to make sure to select the right divider value in the configuration when you actually program the device. internally, the PIC takes the external clock, divides it down to 4MHz, then uses the PLL to generate 96MHz from there, then divided to 48MHz, for the USB hardware. The program then runs at 48MHz as well, at least the way things are set up in this case. As long as the divider is set right for 12 or 20 MHz, (divider of 3 or 5, respectively) the internal result is 4MHz and everything else is the same.
reply | quote

Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2007/02/01 12:38 By: Henrik Status: Visitor  
 
Help needed

I use the picdem FS USB - with visualstudio.net...

anyways, everything starts ok, I can update a LED or use the ADD - but after this first command, the board goes into a state, where D1 and D2 flashes rapidly in sync - and I have to reprogam, can't even reset.

any ideas?

Henrik
reply | quote

Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2007/02/01 12:44 By: Henrik Status: Visitor  
 
Henrik wrote:
Help needed

I use the picdem FS USB - with visualstudio.net...

anyways, everything starts ok, I can update a LED or use the ADD - but after this first command, the board goes into a state, where D1 and D2 flashes rapidly in sync - and I have to reprogam, can't even reset.

any ideas?

Henrik



No need... I'm stupid... Suspend....
reply | quote

Re:Basic USB - Using Microchip Stack and C#.Net
Date: 2007/02/02 09:41 By: Mat Status: Admin  
Karma: 7  
Posts: 211
graph
Glad you got it all sorted...
Mat
reply | quote

<< Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>
::post new topic::