Project MyUSB

Go To Last Post
57 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You're welcome, Torby. The next version of MyUSB will be a little better documented in the demos, so that should help out a little -- but really, you need to know *something* about USB to use it properly.

The official MyUSB support channel is here: http://groups.google.com/group/m...

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

I am not able to figure a problem using MyUSB. I have a program with three interrupts timer1 overflow, uart rx complete, uart tx complete. I need to see stuff received at the uart on the PC using USB so I am using USBtoserial demo. In the main USBtoserial.c when I add my task like this:


TASK(CDC_Task)
{
	if (USB_IsConnected)
	{
          {
          //My Task
          }
          /* Select the Serial Tx Endpoint */
		Endpoint_SelectEndpoint(CDC_TX_EPNUM);

		/* Check if the Tx buffer contains anything to be sent to the host */
		if (Tx_Buffer.Elements)
		{
			/* Wait until Serial Tx Endpoint Ready for Read/Write */
			while (!(Endpoint_ReadWriteAllowed()));
			
			/* Check before sending the data if the endpoint is completely full */
			bool IsFull = (Endpoint_BytesInEndpoint() == CDC_TXRX_EPSIZE);
			
			/* Write the transmission buffer contents to the recieved data endpoint */
			while (Tx_Buffer.Elements && (Endpoint_BytesInEndpoint() < CDC_TXRX_EPSIZE))
			  Endpoint_Write_Byte(Buffer_GetElement(&Tx_Buffer));
			
			/* Send the data */
			Endpoint_ClearCurrentBank();

			/* If a full endpoint was sent, we need to send an empty packet afterwards to terminate the transfer */
			if (IsFull)
			{
				/* Wait until Serial Tx Endpoint Ready for Read/Write */
				while (!(Endpoint_ReadWriteAllowed()));

				/* Send an empty packet to terminate the transfer */
				Endpoint_ClearCurrentBank();
			}
		}	
}
}



ISR(TIMER1_OVF_vect)
{

	GPIOR0 |= (1<<0);
	
}






ISR(USART1_TX_vect)
{
	 GPIOR0 |= (1<<2);
}





ISR(USART1_RX_vect)
{
	/* Character recieved, store it into the buffer */
	Buffer_StoreElement(&Tx_Buffer, UDR1);

	if( (!FE1) | (!DOR1) | (!UPE1) )			// If there is framing error
	{
		i--;									// Send same address again
		GPIOR0 |= (1<<1);
	
	}
	else
	{
		GPIOR0 |= (1<<1);
		
	}
}

When I try this I get an error when I try to open hyperterminal which says, check your port settings,cannot open port.But in the device manager I can see that the driver is properly installed.But if I take out my task from there and just use it as it is and send data to Uart , then there is no problem at the hyperterminal and I can see all the data at the UART.
Can anyone please let me know what the problem is.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If everything else is identical to the original demo, then the host is probably complaining that you are not doing anything with the Host->Device packets in the RX endpoint. Even if you aren't doing anything with them, you still need to check for them and clear the packets, otherwise the host will assume the device has stopped responding.

You also need to keep all the control endpoint code, including the code which sets the "EVENT_HANDLER(USB_UnhandledControlPacket)" event handler or the host will complain that it cannot set the required port settings.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh ok.I actually removed the host to device part because I did not want that function. I will put it back again.But I do have the "EVENT_HANDLER(USB_UnhandledControlPacket)" part. Now when I replaced the entire "my task" part with "setting a bit in PORTB" ,it works fine, I mean the hyperterminal is ok with it.So does it mean the program is not able to execute the CDC_Task part as often as it is supposed to because of the overhead of "mytask" part?
Thanks Dean.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now I replaced back the host to device part too but still the hyperterminal problem persists.But if I change "mytask" to a trivial function like "PORTB |= (1<<1);" , the system functions.Any suggestions?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can anyone suggest what the problem could be?

Pages